예제 #1
0
    def __init__(self):
        base.disableMouse()
        # Turns off the default mouse-camera controls in Panda3D.

        cursor = loader.loadModel("Models/Cursor.egg")
        cursor.reparentTo(render2d)
        cursor.setBin("gui-popup", 100)
        cursor.hide()

        props = WindowProperties()
        props.setCursorHidden(True)
        base.win.requestProperties(props)
        base.mouseWatcherNode.setGeometry(cursor.node())

        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")
        # 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, 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()