This commit is contained in:
2025-08-17 18:49:07 +02:00
parent a910c8f74a
commit 8a32aad877
13 changed files with 259 additions and 30 deletions
+27 -4
View File
@@ -1,13 +1,11 @@
#!/usr/bin/python3
import random
import uuid
from engine import maze, sdl2 as engine, controls, graphics, unit_manager, scoring
import os
import datetime
import json
from engine import maze, sdl2 as engine, controls, graphics, unit_manager, scoring
class MiceMaze(
controls.KeyBindings,
unit_manager.UnitManager,
@@ -40,6 +38,20 @@ class MiceMaze(
self.start_game()
self.background_texture = None
self.configs = self.get_config()
self.ammo = {
"bomb": {
"count": 2,
"max": 5
},
"nuclear": {
"count": 1,
"max": 1
},
"mine": {
"count": 5,
"max": 5
}
}
def get_config(self):
configs = {}
@@ -57,6 +69,15 @@ class MiceMaze(
# ==================== GAME LOGIC ====================
def refill_ammo(self):
for ammo_type, data in self.ammo.items():
if ammo_type == "bomb":
if random.random() < 0.01:
data["count"] = min(data["count"] + 1, data["max"])
elif ammo_type == "mine":
if random.random() < 0.05:
data["count"] = min(data["count"] + 1, data["max"])
def update_maze(self):
if self.game_over():
return
@@ -79,6 +100,8 @@ class MiceMaze(
unit.collisions()
unit.draw()
self.render_engine.update_status(f"Mice: {self.count_rats()} - Points: {self.points}")
self.refill_ammo()
self.render_engine.update_ammo(self.ammo, self.assets)
self.scroll()
self.render_engine.new_cycle(50, self.update_maze)