Method: Mover#apply_forces
- Defined in:
- lib/fantasy/includes/mover.rb
#apply_forces(max_speed: Float::INFINITY) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fantasy/includes/mover.rb', line 13 def apply_forces(max_speed: Float::INFINITY) @acceleration ||= Coordinates.zero @velocity ||= Coordinates.zero @velocity += @acceleration @velocity.resize(max_speed) if @velocity.length > max_speed unless @velocity.length.zero? @position += @velocity * Global.frame_time end @acceleration = Coordinates.zero end |