Module: Nimo::Behavior::WithVelocity

Included in:
Projectile
Defined in:
lib/nimo/behavior/with_velocity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#velocityObject (readonly)

Returns the value of attribute velocity.



13
14
15
# File 'lib/nimo/behavior/with_velocity.rb', line 13

def velocity
  @velocity
end

Instance Method Details

#initialize(*params) ⇒ Object



15
16
17
18
19
# File 'lib/nimo/behavior/with_velocity.rb', line 15

def initialize(*params)
  @speed = 0
  @velocity = Velocity.new(0.0, 0.0)
  super(*params)
end

#moveObject



21
22
23
24
# File 'lib/nimo/behavior/with_velocity.rb', line 21

def move
  @x += @speed * @velocity.x
  @y += @speed * @velocity.y
end