chingu_vectors
Enables you to place and move your game objects via vectors. Also speed and hastening are not declared as pixels per frame but in pixels per second.
Get it
You know how you get it:
gem install chingu_vectors
Use it
After
require "chingu_vectors"
The trait :vectors is available:
class Player < Chingu::GameObject
trait :vectors
#This method will make the player move 20 pixes left per second
def move_left
self.speed = [0,-20]
end
end
Another example
This would be a method that lets a ball follow another ball (“follow”) nice and smoothly
def update
radiuses = size + follow.size
link = (follow.position - position)
if link.length < radiuses
self.speed = Vector::ZERO
else
link = link - link.normalize * radiuses # Connection between edges
self.speed = link * Game.speed
end
end
Future planning
I have not been updating this gem all to terribly well. I will make sure to make it compatible with chingu 0.9 once it comes out. I also may add some changes to the vector class.