You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
48 lines
1.6 KiB
from .unit import Unit |
|
import random |
|
import uuid |
|
|
|
# Costanti - Points disappear after ~1.5 seconds (90 frames at 60 FPS) |
|
AGE_THRESHOLD = 90 |
|
|
|
|
|
from .unit import Unit |
|
from engine.collision_system import CollisionLayer |
|
|
|
|
|
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) |
|
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.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")
|
|
|