Esempio n. 1
0
 def collide_map(self):
     if self.dir == 1:
         col = map[1].mask.get_at(self.rect.midright)
     else:
         col = map[1].mask.get_at(self.rect.midleft)
     if col:
         # self.undo_update()
         particle.animated_effect(
             "hit",
             self.rect.topleft if self.dir == -1 else self.rect.topright)
     return col
Esempio n. 2
0
    def collide_sprite(self, sprite):
        # cases to quickly return false to speed up collision checking
        if sprite.rect.top > self.rect.top or sprite.rect.bottom < self.rect.bottom:
            return False

        if dir == 1:
            if sprite.rect.left > self.rect.right:
                return False
        elif dir == -1:
            if sprite.rect.right < sprite.rect.left:
                return False

        col = pygame.sprite.collide_rect(self, sprite)
        if col:
            particle.animated_effect(
                "hit",
                self.rect.topleft if self.dir == -1 else self.rect.topright)
        return col
Esempio n. 3
0
    def _jump(self):
        """Internal jump method.

        Called inside the regular jump method, which may
        be modified by perks.

        :return: True if jump is successful, False if not
        """

        # only jump off the ground, multiple jumps
        # are handled in the external jump() method
        if self.grounded:
            # set the velocity to one upwards
            self.velocity.y = -JUMP_HEIGHT
            # play particle effect
            particle.animated_effect("jump", self.rect.move(-8, 0).topleft)
            self.grounded = False
            self.jumps = 1
            return True
        return False
Esempio n. 4
0
    def _jump(self):
        """Internal jump method.

        Called inside the regular jump method, which may
        be modified by perks.

        :return: True if jump is successful, False if not
        """

        # only jump off the ground, multiple jumps
        # are handled in the external jump() method
        if self.grounded:
            # set the velocity to one upwards
            self.velocity.y = -JUMP_HEIGHT
            # play particle effect
            particle.animated_effect("jump", self.rect.move(-8, 0).topleft)
            self.grounded = False
            self.jumps = 1
            return True
        return False
Esempio n. 5
0
 def post_jump(self, player):
     if not player.grounded and player.jumps <= self.amount:
         player.velocity.y = -JUMP_HEIGHT
         particle.animated_effect("jump", player.rect.move(-8, 0).topleft)
         player.jumps += 1