def __init__(self): base.setBackgroundColor(0, 0, 0) # Sets the background color to black to make it easier to see things. base.disableMouse() # Turns off the default mouse camera controls. base.camera.setPos(0, -7.5, .75) # Moves the camera back so we can see the models we load. self.inputManager = InputManager() # Creates an input manager so we can get user input. taskMgr.add(self.inputTask, "Input Task") # Adds the input task that monitors for user input to the task manager so it will # run every frame. self.setupLight() # Calls the setupLight method to create out lighting environment. render.setShaderAuto() # Turns on Panda3D's automatic shader generation. self.modelRoot = render.attachNewNode("Model Root") # Creates a base NodePath for all the models to be children of. # This will be the NodePath we rotate to see the model from various angles. self.setupModels() # Calls the method that sets up the models. self.modelRoot.writeBamFile("RedCycle.bam")
def __init__(self): base.disableMouse() # Turns off the default mouse-camera controls in Panda3D. base.setBackgroundColor(0, 0, 0) # Sets the background to black. self.inputManager = InputManager() # Creates an InputManager to handle all of the user input in the game. self.track = Track() # Creates the track the cycles will race on. self.cycle1 = Cycle(self.inputManager, self.track, 1, "Bert", ai=False) self.cycle2 = Cycle(self.inputManager, self.track, 2, "Ernie") # Creates one uncontrolled cycle, and one player controlled cycle. taskMgr.doMethodLater(10, self.debugTask, "Debug Task") # Tells the debugTask to run once every ten seconds. The debug task is a good # place to put various data print outs about the game to help with debugging. self.filters = CommonFilters(base.win, base.cam) filterok = self.filters.setBloom(blend=(0, 0, 0, 1), desat=-0.5, intensity=3.0, size=2) render.setShaderAuto()
def __init__(self): base.disableMouse() # Turns off the default mouse-camera controls in Panda3D. base.setBackgroundColor(0, 0, 0) # Sets the background to black. self.inputManager = InputManager() # Creates an InputManager to handle all of the user input in the game. taskMgr.doMethodLater(10, self.debugTask, "Debug Task") # Tells the debugTask to run once every ten seconds. The debug task is a good # place to put various data print outs about the game to help with debugging. self.filters = CommonFilters(base.win, base.cam) filterok = self.filters.setBloom(blend=(0, 0, 0, 1), desat=-0.5, intensity=3.0, size=2) render.setShaderAuto() # Turns on Panda3D's automatic shader generation. self.menuGraphics = loader.loadModel("../Models/MenuGraphics.egg") self.fonts = { "silver": loader.loadFont("../Fonts/LuconSilver.egg"), "blue": loader.loadFont("../Fonts/LuconBlue.egg"), "orange": loader.loadFont("../Fonts/LuconOrange.egg") } self.race = Race(self.inputManager) self.race.createDemoRace() self.createStartMenu()
def __init__(self): base.disableMouse() # Turns off the default mouse-camera controls in Panda3D. base.setBackgroundColor(0, 0, 0) # Sets the background to black. self.inputManager = InputManager() # Creates an InputManager to handle all of the user input in the game. #taskMgr.doMethodLater(10, self.debugTask, "Debug Task") # Tells the debugTask to run once every ten seconds. The debug task is a good # place to put various data print outs about the game to help with debugging. self.filters = CommonFilters(base.win, base.cam) filterok = self.filters.setBloom(blend=(0, 0, 0, 1), desat=-0.5, intensity=3.0, size=2) # Creates a bloom filter that will integrate with the Glow maps applied to objects to create # the halos around glowing objects. render.setShaderAuto() # Turns on Panda3D's automatic shader generation. self.menuGraphics = loader.loadModel("../Models/MenuGraphics.egg") # Loads the egg that contains all the menu graphics. self.fonts = { "silver": loader.loadFont("../Fonts/LuconSilver.egg"), "blue": loader.loadFont("../Fonts/LuconBlue.egg"), "orange": loader.loadFont("../Fonts/LuconOrange.egg") } # Loads the three custom fonts our game will use. preloader = Preloader(self.fonts) hud = HUD(self.fonts) # Creates the HUD. self.race = Race(self.inputManager, hud) self.race.createDemoRace() # creates an instance of the race class and tells it to # start a demo race. self.createStartMenu() # creates the start menu. musicMgr = base.musicManager self.music = musicMgr.getSound( "../Sound/Loveshadow-Takin_Yo_Time_(The_Wingman_Mix).wav") self.music.setLoop(True) self.music.setVolume(.5) self.music.play()
def __init__(self): base.disableMouse() # Turns off the default mouse-camera controls in Panda3D. base.setBackgroundColor(0, 0, 0) # Sets the background to black. self.inputManager = InputManager() # Creates an InputManager to handle all of the user input in the game. self.track = Track() # Creates the track the cycles will race on. self.cycle1 = Cycle(self.inputManager, self.track, 1, "Bert", ai=False) self.cycle2 = Cycle(self.inputManager, self.track, 2, "Ernie") # Creates one uncontrolled cycle, and one player controlled cycle. taskMgr.doMethodLater(10, self.debugTask, "Debug Task")
def __init__(self): base.disableMouse() # Turns off the default mouse-camera controls in Panda3D. cursor = loader.loadModel("../Models/Cursor.egg") # Loads the 2D image and polygon that will be used to replace # the default windows mouse cursor in game. cursor.reparentTo(render2d) # Parents the cursor to the render2d node. render2d is used instead # of aspect2d because using aspect2d would result in the cursor being unable # to reach the farther edges of the window. cursor.setBin("gui-popup", 100) # The cursor is added to the gui-popup bin to ensure that it is rendered on top # of everything else on the screen. cursor.hide() # By default, the cursor will not be visible. props = WindowProperties() # Creates a WindowProperties object, which stores a wide variety of window settings. props.setCursorHidden(True) # Sets the WindowProperties object to hide the default mouse cursor. base.win.requestProperties(props) # Tells the default window to use the altered properties in the WindowProperties object. base.mouseWatcherNode.setGeometry(cursor.node()) # Attaches the loaded custom cursor to the mouse so that will follow mouse movement. Note # that this behavior is frame rate dependant, and low frame rates could cause problems with it. base.setBackgroundColor(0, 0, 0) # Sets the background to black. self.inputManager = InputManager() # Creates an InputManager to handle all of the user input in the game. #taskMgr.doMethodLater(10, self.debugTask, "Debug Task") # Tells the debugTask to run once every ten seconds. The debug task is a good # place to put various data print outs about the game to help with debugging. self.filters = CommonFilters(base.win, base.cam) filterok = self.filters.setBloom(blend=(0, 0, 0, 1), desat=-0.5, intensity=3.0, size=2) # Creates a bloom filter that will integrate with the Glow maps applied to objects to create # the halos around glowing objects. render.setShaderAuto() # Turns on Panda3D's automatic shader generation. self.menuGraphics = loader.loadModel("../Models/MenuGraphics.egg") # Loads the egg that contains all the menu graphics. self.fonts = { "silver": loader.loadFont("../Fonts/LuconSilver.egg"), "blue": loader.loadFont("../Fonts/LuconBlue.egg"), "orange": loader.loadFont("../Fonts/LuconOrange.egg") } # Loads the three custom fonts our game will use. preloader = Preloader(self.fonts) # starts the preloader. hud = HUD(self.fonts) # Creates the HUD. self.race = Race(self.inputManager, hud, cursor) self.race.createDemoRace() # creates an instance of the race class and tells it to # start a demo race. self.createStartMenu() # creates the start menu. musicMgr = base.musicManager self.music = musicMgr.getSound( "../Sound/Loveshadow-Takin_Yo_Time_(The_Wingman_Mix).wav") self.music.setLoop(True) self.music.setVolume(.5) self.music.play()