Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions arcade/pymunk_physics_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,40 @@ def apply_force(self, sprite: Sprite, force: tuple[float, float]):
)
physics_object.body.apply_force_at_local_point(force, (0, 0))

def apply_torque(self, sprite: Sprite, torque: float):
"""
Apply torque to a Sprite.

Args:
sprite:
The sprite to apply the force to.
torque:
The torque to apply to the sprite.
"""
physics_object = self.sprites[sprite]
if physics_object.body is None:
raise PymunkException(
"Tried to apply a torque, but this physics object has no 'body' set."
)
physics_object.body.torque = torque

def set_angular_velocity(self, sprite: Sprite, velocity: float):
"""
Set velocity to a Sprite.

Args:
sprite:
The sprite to set the angular velocity of.
velocity:
The velocity to set.
"""
physics_object = self.sprites[sprite]
if physics_object.body is None:
raise PymunkException(
"Tried to set velocity, but this physics object has no 'body' set."
)
physics_object.body.angular_velocity = velocity

def set_horizontal_velocity(self, sprite: Sprite, velocity: float) -> None:
"""
Set a sprite's velocity.
Expand Down