mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 21:22:33 +00:00
Added Vector#lerp
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user