Class: RGame::Engine::Components::Velocity
- Inherits:
-
RGame::Engine::Component
- Object
- RGame::Engine::Component
- RGame::Engine::Components::Velocity
- Defined in:
- lib/rgame/engine/components/velocity.rb
Overview
Integrates linear and angular velocity into the node's transform each step. Free-moving entities (rocks, bullets) use it alone; a controller component (or the node's own control hook) writes vx/vy/spin as intent. From Body#integrate.
Instance Attribute Summary collapse
-
#spin ⇒ Object
Returns the value of attribute spin.
-
#vx ⇒ Object
Returns the value of attribute vx.
-
#vy ⇒ Object
Returns the value of attribute vy.
Attributes inherited from RGame::Engine::Component
Instance Method Summary collapse
-
#initialize(vx: 0.0, vy: 0.0, spin: 0.0) ⇒ Velocity
constructor
A new instance of Velocity.
- #update(dt) ⇒ Object
Methods inherited from RGame::Engine::Component
#context, #control, #draw, #on_attach, #on_detach, #sweep_freed
Methods included from Signal::DSL
Constructor Details
#initialize(vx: 0.0, vy: 0.0, spin: 0.0) ⇒ Velocity
Returns a new instance of Velocity.
12 13 14 15 16 17 |
# File 'lib/rgame/engine/components/velocity.rb', line 12 def initialize(vx: 0.0, vy: 0.0, spin: 0.0) super() @vx = vx @vy = vy @spin = spin end |
Instance Attribute Details
#spin ⇒ Object
Returns the value of attribute spin.
10 11 12 |
# File 'lib/rgame/engine/components/velocity.rb', line 10 def spin @spin end |
#vx ⇒ Object
Returns the value of attribute vx.
10 11 12 |
# File 'lib/rgame/engine/components/velocity.rb', line 10 def vx @vx end |
#vy ⇒ Object
Returns the value of attribute vy.
10 11 12 |
# File 'lib/rgame/engine/components/velocity.rb', line 10 def vy @vy end |
Instance Method Details
#update(dt) ⇒ Object
19 20 21 22 23 |
# File 'lib/rgame/engine/components/velocity.rb', line 19 def update(dt) node.x += @vx * dt node.y += @vy * dt node.angle += @spin * dt end |