游戏可以运行

This commit is contained in:
2026-05-20 21:23:46 +08:00
parent e5aa78e8be
commit 804f9d87aa
7 changed files with 256 additions and 49 deletions

View File

@@ -5,7 +5,7 @@ from game.utils import distance
class Enemy:
def __init__(self, enemy_type):
def __init__(self, enemy_type, waypoints=None):
data = ENEMY_DATA[enemy_type]
self.type = enemy_type
self.max_hp = data["hp"]
@@ -32,7 +32,8 @@ class Enemy:
self.heal_interval = data.get("heal_interval", 2.0)
self.heal_timer = self.heal_interval
self.x, self.y = PATH_WAYPOINTS[0]
self.waypoints = waypoints or PATH_WAYPOINTS
self.x, self.y = self.waypoints[0]
self.waypoint_index = 1
self.slow_timer = 0
@@ -84,12 +85,12 @@ class Enemy:
e.hp = min(e.hp + self.heal_amount, e.max_hp)
# Movement
if self.waypoint_index >= len(PATH_WAYPOINTS):
if self.waypoint_index >= len(self.waypoints):
self.reached_end = True
self.alive = False
return
tx, ty = PATH_WAYPOINTS[self.waypoint_index]
tx, ty = self.waypoints[self.waypoint_index]
dx = tx - self.x
dy = ty - self.y
dist = math.hypot(dx, dy)