Skip to content

Commit 7d7619c

Browse files
author
Paul V Craven
committed
Fix example 2
1 parent 5c4d983 commit 7d7619c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

arcade/examples/easing_example_2.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# Mode descriptions shown in the HUD.
2828
MODE_DESCRIPTIONS = {
29-
1: "Instant angle",
29+
1: "Instant (teleport + face mouse)",
3030
2: "Angle ease: LINEAR",
3131
3: "Angle ease: QUAD_IN",
3232
4: "Angle ease: QUAD_OUT",
@@ -126,10 +126,14 @@ def on_draw(self):
126126
)
127127

128128
def _target_angle(self) -> float:
129-
"""Compute the angle from the ship to the target in degrees."""
129+
"""Compute the angle from the ship to the target in degrees.
130+
131+
Arcade uses clockwise-positive angles and the ship sprite
132+
points up at angle 0, so we negate atan2 and add 90.
133+
"""
130134
diff_x = self.target_x - self.ship_sprite.center_x
131135
diff_y = self.target_y - self.ship_sprite.center_y
132-
return math.degrees(math.atan2(diff_y, diff_x)) - 90
136+
return -math.degrees(math.atan2(diff_y, diff_x)) + 90
133137

134138
def _start_angle_ease(self):
135139
"""Record the current angle as the start and set up the ease."""
@@ -193,7 +197,10 @@ def on_mouse_press(self, x: int, y: int, button: int, modifiers: int):
193197
self.target_x = x
194198
self.target_y = y
195199

196-
if 2 <= self.mode <= 5:
200+
if self.mode == 1:
201+
self.ship_sprite.center_x = x
202+
self.ship_sprite.center_y = y
203+
elif 2 <= self.mode <= 5:
197204
self._start_angle_ease()
198205
elif 6 <= self.mode <= 9:
199206
self._start_position_ease()

0 commit comments

Comments
 (0)