Exemplo n.º 1
0
    def switch(self, name):
        """Switch to a new screen by saving the current state, and then
            restoring the specified state."""

        State.save(State.name)
        State.prev_name = State.name
        State.restore(name)
Exemplo n.º 2
0
    def add_object(self, screen, object, amount=1, pos=None, group=None):
        """Add one or more instances of an object to a screen."""

        # Switch the game state to the desired screen first.
        State.restore(screen)

        # Create the specified amount of instances of this object.
        for i in range(0, amount):
            State.screen.add_object(object, group, pos)
Exemplo n.º 3
0
    def run(self, screen):
        """Main game loop."""

        State.running = True
        State.restore(screen)
        while State.running:
            State.clock.tick()
            if State.clock.update_ready():
                self.update()
            if State.clock.frame_ready():
                self.draw()
Exemplo n.º 4
0
    def add_object(self, screen, object, amount=1, pos=None):
        """Add one or more instances of an object to a screen."""

        State.restore(screen)
        State.screen.add_object(object, amount, pos)
        State.save(screen)