c7ed24483d
- Introduced `test_final_level_flow.py` to validate final level transitions and game end scenarios. - Created `test_game_over_flow.py` to ensure game over conditions trigger correctly based on rat counts. - Implemented `test_keybindings.py` to verify keybinding configurations and their context-specific actions. - Developed `test_level_editor.py` to assess level editor functionalities and layout computations. - Added `test_level_io.py` for testing level data serialization and deserialization. - Established `test_loop_logic_parity.py` to ensure consistent game state across multiple simulation runs. - Created `test_non_regression.py` to simulate game behavior and capture states for future verification. - Implemented `test_verify.py` to compare current game states against a golden master for regression detection.
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
from .unit import Unit, UnitType
|
|
from engine.collision_system import CollisionLayer
|
|
import random
|
|
import uuid
|
|
|
|
# Costanti - Points disappear after ~1.5 seconds (90 frames at 60 FPS)
|
|
AGE_THRESHOLD = 90
|
|
|
|
|
|
class Point(Unit):
|
|
"""
|
|
Represents a collectible point in the game.
|
|
Appears when a rat dies and can be collected by the player.
|
|
"""
|
|
|
|
def __init__(self, game, position=(0,0), id=None, value=10):
|
|
super().__init__(game, position, id, collision_layer=CollisionLayer.POINT, unit_type=UnitType.POINT)
|
|
self.value = value
|
|
self.speed = 1 # Points don't move but need speed for draw timing
|
|
|
|
def move(self):
|
|
self.age += self.speed
|
|
if self.age == AGE_THRESHOLD:
|
|
self.die()
|
|
|
|
def collisions(self):
|
|
pass
|
|
|
|
def die(self, unit=None, score=None):
|
|
"""Handle point cleanup. Points just disappear when they expire."""
|
|
target_unit = unit if unit else self
|
|
# Use base class cleanup
|
|
super().die()
|
|
|
|
|
|
def draw(self):
|
|
image = self.game.graphics.assets[f"BMP_BONUS_{self.value}"]
|
|
image_size = self.game.render_engine.get_image_size(image)
|
|
self.rat_image = image
|
|
partial_x, partial_y = 0, 0
|
|
|
|
x_pos = self.position_before[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2 + partial_x
|
|
y_pos = self.position_before[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2 + partial_y
|
|
|
|
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|