mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 13:12:34 +00:00
Added Vector#lerp
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
begin
|
||||
require "../ffi-gosu/lib/gosu"
|
||||
require File.expand_path("../../ffi-gosu/lib/gosu", File.dirname(__FILE__))
|
||||
rescue LoadError => e
|
||||
pp e
|
||||
require "gosu"
|
||||
|
||||
@@ -162,6 +162,10 @@ module CyberarmEngine
|
||||
@x + @y + @z
|
||||
end
|
||||
|
||||
def lerp(other, factor)
|
||||
(self - other) * factor.clamp(0.0, 1.0)
|
||||
end
|
||||
|
||||
# 2D distance using X and Y
|
||||
def distance(other)
|
||||
Math.sqrt((@x-other.x)**2 + (@y-other.y)**2)
|
||||
|
||||
Reference in New Issue
Block a user