Update asset loading to include transparent color and adjust white flash timing; enhance nuclear bomb scoring and gas unit die method
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ class Graphics():
|
||||
self.assets = {}
|
||||
for file in os.listdir("assets/Rat"):
|
||||
if file.endswith(".png"):
|
||||
self.assets[file[:-4]] = self.render_engine.load_image(f"Rat/{file}")
|
||||
self.assets[file[:-4]] = self.render_engine.load_image(f"Rat/{file}", transparent_color=(128, 128, 128))
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -455,12 +455,12 @@ class GameWindow:
|
||||
current_time = sdl2.SDL_GetTicks()
|
||||
elapsed_time = current_time - self.white_flash_start_time
|
||||
|
||||
if elapsed_time < 1000: # First 1 second : full white
|
||||
if elapsed_time < 500: # First 500ms : full white
|
||||
self.white_flash_opacity = 255
|
||||
return True
|
||||
elif elapsed_time < 3000: # Next 2 seconds: fade out
|
||||
# Calculate fade based on remaining time (2000ms fade duration)
|
||||
fade_progress = (elapsed_time - 1000) / 2000.0 # 0.0 to 1.0
|
||||
elif elapsed_time < 2000: # Next 2 seconds: fade out
|
||||
# Calculate fade based on remaining time (1000ms fade duration)
|
||||
fade_progress = (elapsed_time - 500) / 1000.0 # 0.0 to 1.0
|
||||
self.white_flash_opacity = int(255 * (1.0 - fade_progress))
|
||||
return True
|
||||
else: # Effect is complete
|
||||
|
||||
@@ -184,6 +184,7 @@ class MiceMaze(
|
||||
entry.get('user_id', 'Unknown'),
|
||||
|
||||
])
|
||||
|
||||
if not self.game_end[1]:
|
||||
self.render_engine.dialog(
|
||||
"Game Over: Mice are too many!",
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -151,7 +151,7 @@ class NuclearBomb(Unit):
|
||||
if random.random() < 0.7: # 70% chance to kill each rat
|
||||
rats_to_kill.append(unit)
|
||||
for unit in rats_to_kill:
|
||||
unit.die(score=None)
|
||||
unit.die(score=5)
|
||||
|
||||
print(f"Nuclear explosion killed {len(rats_to_kill)} rats!")
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class Gas(Unit):
|
||||
def collisions(self):
|
||||
pass
|
||||
|
||||
def die(self, unit=None):
|
||||
def die(self, unit=None, score=None):
|
||||
if not unit:
|
||||
unit = self
|
||||
self.game.units.pop(unit.id)
|
||||
|
||||
+3
-3
@@ -78,10 +78,10 @@
|
||||
"B0B": {
|
||||
"name": "B0B",
|
||||
"created_date": "2025-08-21T18:03:12.189612",
|
||||
"last_played": "2025-08-21T18:04:57.426796",
|
||||
"last_played": "2025-08-21T18:59:35.393040",
|
||||
"games_played": 0,
|
||||
"total_score": 0,
|
||||
"best_score": 0,
|
||||
"total_score": 590,
|
||||
"best_score": 590,
|
||||
"settings": {
|
||||
"difficulty": "normal",
|
||||
"sound_volume": 50,
|
||||
|
||||
Reference in New Issue
Block a user