diff options
| author | jussi | 2023-11-23 18:36:05 +0200 |
|---|---|---|
| committer | jussi | 2023-11-23 18:36:05 +0200 |
| commit | 925afdf101d6993e35d6c32c52766c7c3f89ae5e (patch) | |
| tree | 96de525752eb02d8772d18ca1b4c31a98680aca3 /examples/resources/lib | |
| parent | 1ab9722875c543e8fd1b6600fd16e51412181641 (diff) | |
| download | reilua-enhanced-925afdf101d6993e35d6c32c52766c7c3f89ae5e.tar.gz reilua-enhanced-925afdf101d6993e35d6c32c52766c7c3f89ae5e.tar.bz2 reilua-enhanced-925afdf101d6993e35d6c32c52766c7c3f89ae5e.zip | |
Fixed snake example after Vector2Angle change.
Diffstat (limited to 'examples/resources/lib')
| -rw-r--r-- | examples/resources/lib/rectangle.lua | 7 | ||||
| -rw-r--r-- | examples/resources/lib/vector2.lua | 4 | ||||
| -rw-r--r-- | examples/resources/lib/vector3.lua | 14 |
3 files changed, 23 insertions, 2 deletions
diff --git a/examples/resources/lib/rectangle.lua b/examples/resources/lib/rectangle.lua index 93f2bb3..dfdbef0 100644 --- a/examples/resources/lib/rectangle.lua +++ b/examples/resources/lib/rectangle.lua @@ -110,6 +110,7 @@ function Rectangle:area() return self.width * self.height end +--- Returns rectangle that fits both rectangles inside it function Rectangle:fit( rec ) local pos = Vector2:new( math.min( self.x, rec.x ), math.min( self.y, rec.y ) ) @@ -121,6 +122,12 @@ function Rectangle:fit( rec ) ) end +--- If rectangle is fully inside another rectangle +function Rectangle:isInside( rect ) + return rect.x <= self.x and self.x + self.width <= rect.x + rect.width + and rect.y <= self.y and self.y + self.height <= rect.y + rect.height +end + function Rectangle:checkCollisionRec( rec ) return RL.CheckCollisionRecs( self, rec ) end diff --git a/examples/resources/lib/vector2.lua b/examples/resources/lib/vector2.lua index e3df887..afb5fda 100644 --- a/examples/resources/lib/vector2.lua +++ b/examples/resources/lib/vector2.lua @@ -130,8 +130,8 @@ function Vector2:lineAngle( v2 ) return RL.Vector2LineAngle( self, v2 ) end -function Vector2:atan() - return math.atan( self.x, self.y ) +function Vector2:atan2() + return math.atan( self.y, self.x ) end function Vector2:scale( scale ) diff --git a/examples/resources/lib/vector3.lua b/examples/resources/lib/vector3.lua index 7059690..1b5cdd3 100644 --- a/examples/resources/lib/vector3.lua +++ b/examples/resources/lib/vector3.lua @@ -3,6 +3,8 @@ if table.unpack == nil then table.unpack = unpack end +local Vector2 = require( "vector2" ) + Vector3 = {} Vector3.meta = { __index = Vector3, @@ -78,6 +80,18 @@ function Vector3:clone() return Vector3:new( self.x, self.y, self.z ) end +function Vector3:getVectorXY() + return Vector2:new( self.x, self.y ) +end + +function Vector3:getVectorXZ() + return Vector2:new( self.x, self.z ) +end + +function Vector3:getVectorZY() + return Vector2:new( self.z, self.y ) +end + function Vector3:abs() return Vector3:new( math.abs( self.x ), math.abs( self.y ), math.abs( self.z ) ) end |
