Added Vector#lerp

This commit is contained in:
2019-10-01 11:48:22 -05:00
parent bb482f4463
commit 8f9e671340
2 changed files with 5 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
begin begin
require "../ffi-gosu/lib/gosu" require File.expand_path("../../ffi-gosu/lib/gosu", File.dirname(__FILE__))
rescue LoadError => e rescue LoadError => e
pp e pp e
require "gosu" require "gosu"

View File

@@ -162,6 +162,10 @@ module CyberarmEngine
@x + @y + @z @x + @y + @z
end end
def lerp(other, factor)
(self - other) * factor.clamp(0.0, 1.0)
end
# 2D distance using X and Y # 2D distance using X and Y
def distance(other) def distance(other)
Math.sqrt((@x-other.x)**2 + (@y-other.y)**2) Math.sqrt((@x-other.x)**2 + (@y-other.y)**2)