Skip to content

Commit

Permalink
repair spaceships
Browse files Browse the repository at this point in the history
  • Loading branch information
vpoulailleau committed Feb 5, 2024
1 parent 77952fa commit cbe6110
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions space_collector/game/spaceship.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def update(self, delta_time: float) -> None:
self.x = max(0, min(self.x, MAP_DIMENSION))
self.y += delta_time * self.speed * math.sin(math.radians(self.angle))
self.y = max(0, min(self.y, MAP_DIMENSION))
if distance(self, self.base) < 200:
self.broken = False

def move(self, angle: int, speed: int) -> None:
self.angle = angle
Expand Down Expand Up @@ -151,17 +153,13 @@ def fire(self, angle: int) -> None:
self.y + math.sin(angle_radians) * HIGH_ENERGY_LENGTH,
]
)
logging.info("fire %s", str(self))
for team in self.player.all_spaceships()[1:]:
for spaceship in team:
logging.info(" to %s", str(spaceship))
if distance(self, spaceship) > HIGH_ENERGY_LENGTH:
logging.info(" too far")
continue
distance_to_high_energy = distance_point_to_segment(
start, end, Vector([spaceship.x, spaceship.y])
)
logging.info(" distance: %f", distance_to_high_energy)
if distance_to_high_energy < 200:
spaceship.broken = True

Expand Down

0 comments on commit cbe6110

Please sign in to comment.