Browse Source

Update asset loading to include transparent color and adjust white flash timing; enhance nuclear bomb scoring and gas unit die method

master
Matteo Benedetto 4 months ago
parent
commit
c004edef8f
  1. 2
      engine/graphics.py
  2. 8
      engine/sdl2.py
  3. 1
      rats.py
  4. BIN
      server/mice_game.db
  5. 2
      units/bomb.py
  6. 2
      units/gas.py
  7. 6
      user_profiles.json

2
engine/graphics.py

@ -21,7 +21,7 @@ class Graphics():
self.assets = {} self.assets = {}
for file in os.listdir("assets/Rat"): for file in os.listdir("assets/Rat"):
if file.endswith(".png"): 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))

8
engine/sdl2.py

@ -455,12 +455,12 @@ class GameWindow:
current_time = sdl2.SDL_GetTicks() current_time = sdl2.SDL_GetTicks()
elapsed_time = current_time - self.white_flash_start_time 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 self.white_flash_opacity = 255
return True return True
elif elapsed_time < 3000: # Next 2 seconds: fade out elif elapsed_time < 2000: # Next 2 seconds: fade out
# Calculate fade based on remaining time (2000ms fade duration) # Calculate fade based on remaining time (1000ms fade duration)
fade_progress = (elapsed_time - 1000) / 2000.0 # 0.0 to 1.0 fade_progress = (elapsed_time - 500) / 1000.0 # 0.0 to 1.0
self.white_flash_opacity = int(255 * (1.0 - fade_progress)) self.white_flash_opacity = int(255 * (1.0 - fade_progress))
return True return True
else: # Effect is complete else: # Effect is complete

1
rats.py

@ -184,6 +184,7 @@ class MiceMaze(
entry.get('user_id', 'Unknown'), entry.get('user_id', 'Unknown'),
]) ])
if not self.game_end[1]: if not self.game_end[1]:
self.render_engine.dialog( self.render_engine.dialog(
"Game Over: Mice are too many!", "Game Over: Mice are too many!",

BIN
server/mice_game.db

Binary file not shown.

2
units/bomb.py

@ -151,7 +151,7 @@ class NuclearBomb(Unit):
if random.random() < 0.7: # 70% chance to kill each rat if random.random() < 0.7: # 70% chance to kill each rat
rats_to_kill.append(unit) rats_to_kill.append(unit)
for unit in rats_to_kill: for unit in rats_to_kill:
unit.die(score=None) unit.die(score=5)
print(f"Nuclear explosion killed {len(rats_to_kill)} rats!") print(f"Nuclear explosion killed {len(rats_to_kill)} rats!")

2
units/gas.py

@ -48,7 +48,7 @@ class Gas(Unit):
def collisions(self): def collisions(self):
pass pass
def die(self, unit=None): def die(self, unit=None, score=None):
if not unit: if not unit:
unit = self unit = self
self.game.units.pop(unit.id) self.game.units.pop(unit.id)

6
user_profiles.json

@ -78,10 +78,10 @@
"B0B": { "B0B": {
"name": "B0B", "name": "B0B",
"created_date": "2025-08-21T18:03:12.189612", "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, "games_played": 0,
"total_score": 0, "total_score": 590,
"best_score": 0, "best_score": 590,
"settings": { "settings": {
"difficulty": "normal", "difficulty": "normal",
"sound_volume": 50, "sound_volume": 50,

Loading…
Cancel
Save