Пример #1
0
    def update(self, delta_time):
        _x = ScoreManager.playerX - self.center_x
        _y = ScoreManager.playerY - self.center_y
        d = math.sqrt(_x ** 2 + _y ** 2)

        self.shooting_timer -= delta_time
        self.change_x = 0
        self.change_y = 0

        if d <= SHORT_DISTANCE_MIN:
            if d <= SHOOTING_DISTANCE_MAX:
                if self.shooting_timer <= 0:
                    self.bullet_controller.shoot_bullet(self.center_x, self.center_y, _x / d, _y / d, 3)
                    self.shooting_timer = 2
                    SoundsManager.play_sound('shooting')

            if d <= SHOOTING_DISTANCE_MIN:
                self.change_x = _x * self.speed / d
                self.change_y = _y * self.speed / d

        self.physics_engine.check(self.map.walls_layer)
        self.physics_engine.check(self.map.collidable_objects_layer)

        self.physics_engine.resolve()
        self.physics_engine.update()

        self.bullet_controller.update(delta_time)
Пример #2
0
 def on_hit(self):
     if self.timer == 0:
         self.timer = MAX_TIMER
         if self.health > 0:
             self.health -= 1
         else:
             self.remove_from_sprite_lists()
     self.update_colour()
     SoundsManager.play_sound("destroy")
Пример #3
0
 def on_hit(self):
     ScoreManager.score +=1
     SoundsManager.play_sound('coins')
     super().on_hit()
Пример #4
0
 def on_hit(self):
     if ScoreManager.health < MAX_HEALTH:
         ScoreManager.health += 1
         SoundsManager.play_sound("hearts")
     super().on_hit()
Пример #5
0
 def on_hit(self):
     ScoreManager.gem_score += 1
     super().on_hit()
     SoundsManager.play_sound('gems')
Пример #6
0
 def on_hit(self):
     event_name = "ON_DOOR_{}_OPEN".format(self.door_id)
     EventManager.emit(event_name)
     SoundsManager.play_sound('coins')
     self.remove_from_sprite_lists()
Пример #7
0
 def on_hit(self):
     ScoreManager.gameIsActive = False
     SoundsManager.play_sound("win")
     print("I've finished the level")
Пример #8
0
 def on_hit(self):
     SoundsManager.play_sound("stars")
     print("I've found a star")
     super().on_hit()
Пример #9
0
 def on_hit(self):
     ScoreManager.invincibilityTimer = MAX_INVINCIBILITY_TIMER
     ScoreManager.isInvincible = True
     SoundsManager.play_sound("invincible")
     super().on_hit()