Skip to content

Commit 535d349

Browse files
authored
fix: angle negation for Pymunk physics engine to ensure correct sprite rotation (#2840)
1 parent 027d160 commit 535d349

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arcade/pymunk_physics_engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def add_sprite(
266266

267267
# Set the body's position
268268
body.position = pymunk.Vec2d(sprite.center_x, sprite.center_y)
269-
body.angle = math.radians(sprite.angle)
269+
body.angle = math.radians(-sprite.angle)
270270

271271
# Callback used if we need custom gravity, damping, velocity, etc.
272272
def velocity_callback(
@@ -514,7 +514,7 @@ def set_rotation(self, sprite: Sprite, rotation: float) -> None:
514514
raise PymunkException(
515515
"Tried to set a rotation, but this physics object has no 'body' set."
516516
)
517-
physics_object.body.angle = math.radians(rotation)
517+
physics_object.body.angle = math.radians(-rotation)
518518

519519
def set_velocity(self, sprite: Sprite, velocity: tuple[float, float]) -> None:
520520
"""Directly set the velocity of a sprite known to the engine.

0 commit comments

Comments
 (0)