Пример #1
0
    def die(self):
        self.lives -= 1

        if self.lives > 0:
            play_sound(constants.DIE_SOUND_FILE)
        else:
            play_sound(constants.GAMEOVER_SOUND_FILE)
Пример #2
0
    def process_enemies(self, enemies):
        hit_list = pygame.sprite.spritecollide(self, enemies, False)

        if len(hit_list) > 0 and self.invincibility == 0:
            play_sound(constants.HURT_SOUND_FILE)
            self.hearts -= 1
            self.invincibility = int(0.75 * constants.FPS)
Пример #3
0
    def jump(self, blocks):
        self.rect.y += 1

        hit_list = pygame.sprite.spritecollide(self, blocks, False)

        if len(hit_list) > 0:
            self.vy = -1 * self.jump_power
            play_sound(constants.JUMP_SOUND_FILE)

        self.rect.y -= 1
Пример #4
0
    def process_coins(self, coins):
        hit_list = pygame.sprite.spritecollide(self, coins, True)

        for coin in hit_list:
            play_sound(constants.COIN_SOUND_FILE)
            self.score += coin.value
Пример #5
0
    def check_flag(self, level):
        hit_list = pygame.sprite.spritecollide(self, level.flag, False)

        if len(hit_list) > 0:
            level.completed = True
            play_sound(constants.LEVELUP_SOUND_FILE)
Пример #6
0
    def process_powerups(self, powerups):
        hit_list = pygame.sprite.spritecollide(self, powerups, True)

        for p in hit_list:
            play_sound(constants.POWERUP_SOUND_FILE)
            p.apply(self)