Added velocity parameters and associated functions to actors #369
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.vxandactor.vyare the velocity components in either axis, analogous toactor.xandactor.y.actor.velis the combined velocity as a tuple, analogous toactor.pos.actor.move_by_vel()moves the actor by its velocity. If called everyupdate(), this makes for very easy straight-line-movementactor.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,Noneis returned.