Module: Tween

Defined in:
lib/fantasy/tween.rb

Class Method Summary collapse

Class Method Details

.move_towards(from:, to:, speed:) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/fantasy/tween.rb', line 4

def self.move_towards(from:, to:, speed:)
  direction = to - from
  step = [direction.length, speed * Global.frame_time].min

  return to if step.zero?

  direction = direction.normalize
  from + (direction * step)
end