Exemple #1
0
    def __update_input(self, delta_time):
        update_input()

        if pressed(InputType.QUIT):
            self.__quit_game()
        if pressed(InputType.TOGGLE_FULLSCREEN):
            self.__toggle_fullscreen()

        if self.no_spam and pressing(InputType.TOGGLE_DEBUG):
            toggle_debugging()
            self.no_spam = False

        if not pressing(InputType.TOGGLE_DEBUG):
            self.no_spam = True
Exemple #2
0
 def __update_input(self, delta_time):
     if pressed(InputType.RESET):
         self.__reset()
Exemple #3
0
    def _update_input(self, delta_time):
        if self.attacked:
            return

        if not self.pause and pressing(
                InputType.LEFT) and not pressing(InputType.RIGHT):
            self.velocity.x -= self.lateral_acceleration
            if self.velocity.x < -self.move_speed:
                self.velocity.x = -self.move_speed

            if not self.jumping:
                self.sprite.set_frame(self.walk_animation.current_frame, 6)

            self.direction = Direction.LEFT

        elif not self.pause and pressing(
                InputType.RIGHT) and not pressing(InputType.LEFT):
            self.velocity.x += self.lateral_acceleration
            if self.velocity.x > self.move_speed:
                self.velocity.x = self.move_speed

            if not self.jumping:
                self.sprite.set_frame(self.walk_animation.current_frame, 6)

            self.direction = Direction.RIGHT

        elif ((not pressing(InputType.LEFT) and not pressing(InputType.RIGHT))
              or (pressing(InputType.LEFT) and pressing(InputType.RIGHT))):
            if self.grounded:
                self.velocity.lerp(Vector2(0, self.velocity.y),
                                   self.ground_friction)
            else:
                self.velocity.lerp(Vector2(0, self.velocity.y),
                                   self.air_friction)

            if self.velocity.x > -0.1 and self.velocity.x < 0.1:
                self.velocity.x = 0

            self.sprite.set_frame(0, 6)

        if not self.grounded:
            if self.velocity.y < 0:
                self.sprite.set_frame(6, 6)
            if self.velocity.y > 0:
                self.sprite.set_frame(7, 6)
        else:
            if self.velocity.x == 0:
                if pressing(InputType.UP):
                    self.sprite.set_frame(8, 6)
                if pressing(InputType.DOWN):
                    self.sprite.set_frame(9, 6)

        if self.direction == Direction.LEFT:
            self.sprite.flip_horizontally(True)
        elif self.direction == Direction.RIGHT:
            self.sprite.flip_horizontally(False)

        if pressed(InputType.A) and self.grounded and not self.jumping:
            self.__jump(delta_time)
            self.jumping = True

        if self.jumping and self.velocity.y < -self.jump_initial_velocity / 2 and not pressing(
                InputType.A):
            self.velocity.y = -self.jump_initial_velocity / 2
            self.jumping = False

        if pressed(InputType.X):
            self.attempt_block_shift = True
Exemple #4
0
    def update(self, delta_time, scene_data, manager):
        if pressed(self.button):
            self._queue_next_scene(manager)

            if scene_data.actor != None:
                self._move_entity_to_next_scene(scene_data.actor, manager)