Skip to content

Commit da9802e

Browse files
committed
feat: damage by wall
1 parent bfb92af commit da9802e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

game/components/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def end(self, seconds: int) -> None:
176176
)
177177
pygame.display.flip()
178178

179-
pygame.time.wait(2000)
179+
pygame.time.wait(5000)
180180
self.game.state = GameState.MENU
181181
self.game.reset()
182182
self.game.main_menu()

game/components/player.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ def _handle_boundary_collision(self, damage_amount: int) -> None:
159159
:param damage_amount: Le montant de dégâts à infliger
160160
:type damage_amount: int
161161
"""
162-
self.damage(damage_amount)
162+
if not self.isInvincible or time() - self.beginInvincible >= 1:
163+
self.isInvincible = True
164+
self.beginInvincible = time()
165+
self.damage(damage_amount)
163166
self.position.x = max(
164167
0,
165168
min(
@@ -226,7 +229,6 @@ def damage(self, amount: int) -> None:
226229
self.health -= amount
227230
self.damage_timestamp = int(time())
228231
self.time_to_heal += int(2 + (1 * self.health_regen))
229-
230232
if self.health <= 0:
231233
self.health = 0
232234
self.game.state = GameState.GAME_OVER

0 commit comments

Comments
 (0)