File tree Expand file tree Collapse file tree 4 files changed +6
-107
lines changed
Expand file tree Collapse file tree 4 files changed +6
-107
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def __init__(self) -> None:
1515 pygame .init ()
1616 self .screen : pygame .Surface = pygame .display .set_mode ((SCREEN_WIDTH , SCREEN_HEIGHT ))
1717 self .clock : pygame .time .Clock = pygame .time .Clock ()
18- self .player : Player = None
18+ self .player : Player | None = None
1919 self .enemies : list [Enemy ] = []
2020 self .bullets : list [Bullet ] = []
2121 self .running : bool = True
@@ -45,7 +45,7 @@ def game_loop(self) -> None:
4545 self .draw ()
4646 self .clock .tick (FPS )
4747 self .spawn_enemies ()
48- self .toolbar .update (self .player_health , self .score ) # Update toolbar with live stats
48+ self .toolbar .update (self .score , self .player_health ) # Update toolbar with live stats
4949
5050 def check_collisions (self ) -> None :
5151 bullets_to_remove = []
@@ -57,7 +57,7 @@ def check_collisions(self) -> None:
5757 enemies_to_remove .append (enemy )
5858 bullets_to_remove .append (bullet )
5959 # Increase score on hitting an enemy
60- self .score += enemy . value
60+ self .score += 1
6161
6262 # Remove bullets and enemies after iteration to avoid modifying the list during iteration
6363 for bullet in bullets_to_remove :
Original file line number Diff line number Diff line change 11import pygame
22
3+
34class Toolbar :
45 def __init__ (self ):
56 self .font = pygame .font .Font (pygame .font .get_default_font (), 20 )
67 self .score_position = pygame .Vector2 (10 , 10 ) # Default position for displaying score
78 self .health_position = pygame .Vector2 (10 , 40 ) # Default position for displaying health
9+ self .current_score = - 1
10+ self .current_health = - 1
811
912 def update (self , score : int , health : int ):
1013 # This would typically update internal state if needed
You can’t perform that action at this time.
0 commit comments