Skip to content

Conversation

@Mambouna
Copy link

@Mambouna Mambouna commented Sep 13, 2025

Since many game objects move along straight paths with a constant speed, this PR adds velocity parameters to actors as well as a function that simply moves the actor by its velocity and one to intersect straight-line-movement.

  • actor.vx and actor.vy are the velocity components in either axis, analogous to actor.x and actor.y.
  • actor.vel is the combined velocity as a tuple, analogous to actor.pos.
  • All can be read and set independently with no issues.
  • actor.move_by_vel() moves the actor by its velocity. If called every update(), this makes for very easy straight-line-movement
  • actor.move_by_vel(2.0) will double the speed. The optional scale parameter allows for things like slowmotion with straight-line-movement.
  • actor.intersection_velocity(target, speed) will calculate a velocity tuple of the given magnitude to intercept the target actor as long as its velocity remains constant. If no valid interception exists, None is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant