Esempio n. 1
0
    def __init__(self, db):

        # Initialize PyGame
        pygame.init()

        self.stateMachine = StateMachine()

        # States
        self.stateMachine.addState("TitleScreen",
                                   TitleScreen(self.stateMachine, db))
        self.stateMachine.addState("Settings", Settings(self.stateMachine))
        self.stateMachine.addState("InGame", InGame(self.stateMachine))
        # Transitions
        self.stateMachine.addTransition("toTitleScreen",
                                        Transition("TitleScreen"))
        self.stateMachine.addTransition("toSettings", Transition("Settings"))
        self.stateMachine.addTransition("toInGame", Transition("InGame"))

        # Set the initial state
        self.stateMachine.setState("TitleScreen")

        # Initialize Managers
        self.eventManager = EventManager(self.stateMachine)
        self.displayManager = DisplayManager(self.stateMachine)
        self.menuManager = MenuManager(self.stateMachine)
Esempio n. 2
0
    def __init__(self, db):

        # Initialize PyGame
        pygame.init()

        self.stateMachine = StateMachine()

        # States
        self.stateMachine.addState("TitleScreen", TitleScreen(self.stateMachine, db))
        self.stateMachine.addState("Settings", Settings(self.stateMachine))
        self.stateMachine.addState("InGame", InGame(self.stateMachine))
        # Transitions
        self.stateMachine.addTransition("toTitleScreen", Transition("TitleScreen"))
        self.stateMachine.addTransition("toSettings", Transition("Settings"))
        self.stateMachine.addTransition("toInGame", Transition("InGame"))

        # Set the initial state
        self.stateMachine.setState("TitleScreen")

        # Initialize Managers
        self.eventManager = EventManager(self.stateMachine)
        self.displayManager = DisplayManager(self.stateMachine)
        self.menuManager = MenuManager(self.stateMachine)
Esempio n. 3
0
class GameEngine(object):
    def __init__(self, db):

        # Initialize PyGame
        pygame.init()

        self.stateMachine = StateMachine()

        # States
        self.stateMachine.addState("TitleScreen",
                                   TitleScreen(self.stateMachine, db))
        self.stateMachine.addState("Settings", Settings(self.stateMachine))
        self.stateMachine.addState("InGame", InGame(self.stateMachine))
        # Transitions
        self.stateMachine.addTransition("toTitleScreen",
                                        Transition("TitleScreen"))
        self.stateMachine.addTransition("toSettings", Transition("Settings"))
        self.stateMachine.addTransition("toInGame", Transition("InGame"))

        # Set the initial state
        self.stateMachine.setState("TitleScreen")

        # Initialize Managers
        self.eventManager = EventManager(self.stateMachine)
        self.displayManager = DisplayManager(self.stateMachine)
        self.menuManager = MenuManager(self.stateMachine)

    # ( Handle Events, Update Game State, Draw Screen )
    def execute(self):
        # Handle events
        self.eventManager.run()
        self.stateMachine.execute()
        self.displayManager.run()
Esempio n. 4
0
class GameEngine(object):

    def __init__(self, db):

        # Initialize PyGame
        pygame.init()

        self.stateMachine = StateMachine()

        # States
        self.stateMachine.addState("TitleScreen", TitleScreen(self.stateMachine, db))
        self.stateMachine.addState("Settings", Settings(self.stateMachine))
        self.stateMachine.addState("InGame", InGame(self.stateMachine))
        # Transitions
        self.stateMachine.addTransition("toTitleScreen", Transition("TitleScreen"))
        self.stateMachine.addTransition("toSettings", Transition("Settings"))
        self.stateMachine.addTransition("toInGame", Transition("InGame"))

        # Set the initial state
        self.stateMachine.setState("TitleScreen")

        # Initialize Managers
        self.eventManager = EventManager(self.stateMachine)
        self.displayManager = DisplayManager(self.stateMachine)
        self.menuManager = MenuManager(self.stateMachine)

    # ( Handle Events, Update Game State, Draw Screen )
    def execute(self):
        # Handle events
        self.eventManager.run()
        self.stateMachine.execute()
        self.displayManager.run()