游戏可以运行

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

@@ -39,16 +39,19 @@ class Tower:
continue
d = distance(self.x, self.y, e.x, e.y)
if d <= self.range:
progress = e.waypoint_index + (1 - distance(e.x, e.y, *self._wp(e.waypoint_index)) / 100)
wp_idx = min(e.waypoint_index, len(e.waypoints) - 1)
progress = e.waypoint_index + (1 - distance(e.x, e.y, *e.waypoints[wp_idx]) / 100)
if progress > best_progress:
best_progress = progress
best = e
self.target = best
def _wp(self, idx):
if self.target and idx < len(self.target.waypoints):
return self.target.waypoints[idx]
if self.target:
return self.target.waypoints[-1]
from game.config import PATH_WAYPOINTS
if idx < len(PATH_WAYPOINTS):
return PATH_WAYPOINTS[idx]
return PATH_WAYPOINTS[-1]
def update(self, dt, enemies, projectiles):