OK
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user