lib/traits/moveable.rb in gosu_extensions-0.2.6 vs lib/traits/moveable.rb in gosu_extensions-0.2.7
- old
+ new
@@ -1,18 +1,15 @@
# A moveable has a shape, speed etc.
#
-# TODO moveable should only have active components, like accelerate etc. Positioning etc. should go to Thing.
-#
module Moveable extend Trait
Accelerate = :accelerate; def self.accelerate strength = 1.0; [Accelerate, strength] end
Left = :move_left; def self.left strength = 1.0; [Left, strength] end
Right = :move_right; def self.right strength = 1.0; [Right, strength] end
Up = :move_up; def self.up strength = 1.0; [Up, strength] end
Down = :move_down; def self.down strength = 1.0; [Down, strength] end
Backwards = :backwards; def self.backwards strength = 1.0; [Backwards, strength] end
- # TODO Jump = :jump
# Default methods for controls.
#
def accelerate strength = 1.0
self.speed += self.rotation_vector * strength/SUBSTEPS
@@ -32,9 +29,11 @@
def backwards strength = 1.0
accelerate -0.5*strength
end
# Movement rules
+ #
+ # TODO Move to Sprite?
#
# Note: Call in method move.
#
def bounce_off_border_x elasticity = 1.0
if position.x > window.screen_width || position.x < 0
\ No newline at end of file