Module: Rubygame::Sprites::ForceGroup
- Defined in:
- lib/xgame.rb
Overview
This is a mixin module for groups of sprites with a constant force acting on them
Instance Method Summary collapse
-
#force=(value) ⇒ Object
Force vector [vx, vy, max_applied (optional)].
- #update(*args) ⇒ Object
Instance Method Details
#force=(value) ⇒ Object
Force vector [vx, vy, max_applied (optional)]
201 202 203 204 |
# File 'lib/xgame.rb', line 201 def force=(value) value[2] = {} unless value @force = value end |
#update(*args) ⇒ Object
206 207 208 209 210 211 212 |
# File 'lib/xgame.rb', line 206 def update(*args) super(*args) force = [@force[0] * args[0]/1000.0, @force[1] * args[0]/1000.0, @force[2]] # Make sure force is applied the same no matter how fast we're rendering self.each { |sprite| sprite.apply_force(force) if sprite.respond_to?(:apply_force) } end |