Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
Move animations to draw thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Virashu committed Feb 20, 2024
1 parent 6d1c876 commit c51f33f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions danmaku/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def update_game(self):
self.player.vx, self.player.vy = vx, vy

self.player.update(self.delta)
self.player.animate((self.player.vx, self.player.vy))

stage = self.levels[self.current_level].stage
stage.update()
Expand All @@ -229,7 +228,7 @@ def update_game(self):
if self.player.collision(enemy):
self.player.get_damage(enemy.damage / 100)
self.bullets += enemy.shoot()
enemy.animate((enemy.vx, enemy.vy))

enemy.update(self.delta)
if (
enemy.y > self.height / 2 and not 0 <= enemy.x < self.game_border
Expand Down Expand Up @@ -278,8 +277,6 @@ def update_game(self):
):
self.drops.remove(drop)

self.background_object.animate()

if len(self.enemies) == 0:
self.next_level()

Expand Down Expand Up @@ -336,11 +333,15 @@ def update(self):

def draw(self):
self.graphics.rectangle((0, 0), (self.width, self.height), (30, 157, 214, 180))

self.background_object.animate()
self.graphics.draw_sprite(self.background_object)

self.player.animate((self.player.vx, self.player.vy))
self.player.draw(self.graphics)

for enemy in self.enemies:
enemy.animate((enemy.vx, enemy.vy))
self.graphics.draw_sprite(enemy)

for bullet in self.bullets:
Expand Down

0 comments on commit c51f33f

Please sign in to comment.