コード例 #1
0
    def __init__(self, pipes):
        super(NewGameState, self).__init__()
        self.pipes = pipes

        self.flappy = Flappy(0.2, 0.4)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)

        self.ground = GroundManager()
コード例 #2
0
    def __init__(self):
        super(IntroState, self).__init__()

        self.flappy = Flappy(0.5, 0.65)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)
        self.ground = GroundManager()

        # create the pipes here to avoid generation (stutter) in FlappyFlying State
        self.pipes = PipeManager()
コード例 #3
0
    def __init__(self, pipes):
        super(NewGameState, self).__init__()
        self.pipes = pipes

        self.flappy = Flappy(0.2, 0.4)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)

        self.ground = GroundManager()
コード例 #4
0
    def __init__(self):
        super(IntroState, self).__init__()

        self.flappy = Flappy(0.5, 0.65)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)
        self.ground = GroundManager()

        # create the pipes here to avoid generation (stutter) in FlappyFlying State
        self.pipes = PipeManager()
コード例 #5
0
class IntroState(GamestateTemplate):
    '''
    This is the first state the game starts into.
    From here, the game moves into a NewGameState.

    It serves as an introduction/banner state.
    It features a banner HUD, flappy idle animation, and ground animation.
    NOTE: The HUD is setup by the Display as it's listening for gamestate changes.
    '''

    # the keys used to go from IntroState to NewGameState
    START_KEYS = [
        pygame.K_SPACE,
        pygame.K_UP
    ]

    def __init__(self):
        super(IntroState, self).__init__()

        self.flappy = Flappy(0.5, 0.65)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)
        self.ground = GroundManager()

        # create the pipes here to avoid generation (stutter) in FlappyFlying State
        self.pipes = PipeManager()

    # @Override
    def state_controls(self, event):
        if event.key in self.START_KEYS:
            debugger("IntroState: state_controls: Pressed a START key")
            self.state_instance.current_state = NewGameState(self.pipes)
            return True  # state has changed, do not call state_update
        return False

    # @Override
    def state_update(self, delta_t):
        self.flappy.idle_animation(delta_t)
        self.ground.update(delta_t)

        # returning what we actually want to draw
        return [self.flappy_group, self.ground]
コード例 #6
0
class NewGameState(GamestateTemplate):
    '''
    This is the second state in which the game runs.
    From here, the game moves into a FlappyFlyingState.

    It moves Flappy to his default position in an idle animation.
    The HUD displays the state (New Game) and the controls to get started.
    '''

    # the keys used to go from NewGameState to FlappyFlyingState
    START_KEYS = [
        pygame.K_SPACE,
        pygame.K_UP
    ]

    def __init__(self, pipes):
        super(NewGameState, self).__init__()
        self.pipes = pipes

        self.flappy = Flappy(0.2, 0.4)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)

        self.ground = GroundManager()

    # @Override
    def state_controls(self, event):
        if event.key in self.START_KEYS:
            debugger("NewGameState: state_controls: Pressed a START key")
            self.state_instance.current_state = FlappyFlyingState(self.flappy, self.pipes, self.ground)
            return True  # state has changed, do not call state_update
        return False

    # @Override
    def state_update(self, delta_t):
        self.flappy.idle_animation(delta_t)
        self.ground.update(delta_t)

        # returning what we actually want to draw
        return [self.flappy_group, self.ground]
コード例 #7
0
class IntroState(GamestateTemplate):
    '''
    This is the first state the game starts into.
    From here, the game moves into a NewGameState.

    It serves as an introduction/banner state.
    It features a banner HUD, flappy idle animation, and ground animation.
    NOTE: The HUD is setup by the Display as it's listening for gamestate changes.
    '''

    # the keys used to go from IntroState to NewGameState
    START_KEYS = [pygame.K_SPACE, pygame.K_UP]

    def __init__(self):
        super(IntroState, self).__init__()

        self.flappy = Flappy(0.5, 0.65)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)
        self.ground = GroundManager()

        # create the pipes here to avoid generation (stutter) in FlappyFlying State
        self.pipes = PipeManager()

    # @Override
    def state_controls(self, event):
        if event.key in self.START_KEYS:
            debugger("IntroState: state_controls: Pressed a START key")
            self.state_instance.current_state = NewGameState(self.pipes)
            return True  # state has changed, do not call state_update
        return False

    # @Override
    def state_update(self, delta_t):
        self.flappy.idle_animation(delta_t)
        self.ground.update(delta_t)

        # returning what we actually want to draw
        return [self.flappy_group, self.ground]
コード例 #8
0
class NewGameState(GamestateTemplate):
    '''
    This is the second state in which the game runs.
    From here, the game moves into a FlappyFlyingState.

    It moves Flappy to his default position in an idle animation.
    The HUD displays the state (New Game) and the controls to get started.
    '''

    # the keys used to go from NewGameState to FlappyFlyingState
    START_KEYS = [pygame.K_SPACE, pygame.K_UP]

    def __init__(self, pipes):
        super(NewGameState, self).__init__()
        self.pipes = pipes

        self.flappy = Flappy(0.2, 0.4)  # passing X, Y to Flappy
        self.flappy_group = pygame.sprite.RenderUpdates(self.flappy)

        self.ground = GroundManager()

    # @Override
    def state_controls(self, event):
        if event.key in self.START_KEYS:
            debugger("NewGameState: state_controls: Pressed a START key")
            self.state_instance.current_state = FlappyFlyingState(
                self.flappy, self.pipes, self.ground)
            return True  # state has changed, do not call state_update
        return False

    # @Override
    def state_update(self, delta_t):
        self.flappy.idle_animation(delta_t)
        self.ground.update(delta_t)

        # returning what we actually want to draw
        return [self.flappy_group, self.ground]