summaryrefslogtreecommitdiff
path: root/examples/resources/lib/vector2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'examples/resources/lib/vector2.lua')
-rw-r--r--examples/resources/lib/vector2.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/examples/resources/lib/vector2.lua b/examples/resources/lib/vector2.lua
index 65452cf..8f9ad1d 100644
--- a/examples/resources/lib/vector2.lua
+++ b/examples/resources/lib/vector2.lua
@@ -1,3 +1,8 @@
+-- For luaJit compatibility.
+if table.unpack == nil then
+ table.unpack = unpack
+end
+
Vector2 = {}
Vector2.meta = {
__index = Vector2,
@@ -25,9 +30,6 @@ Vector2.meta = {
__unm = function( v )
return Vector2:new( -v.x, -v.y )
end,
- __idiv = function( v, value )
- return Vector2:new( v.x // value, v.y // value )
- end,
__len = function( v )
local len = 0
@@ -90,6 +92,14 @@ function Vector2:max( v2 )
return Vector2:new( math.max( self.x, v2.x ), math.max( self.y, v2.y ) )
end
+function Vector2:floor()
+ return Vector2:new( math.floor( self.x ), math.floor( self.y ) )
+end
+
+function Vector2:ceil()
+ return Vector2:new( math.ceil( self.x ), math.ceil( self.y ) )
+end
+
function Vector2:addValue( value )
return Vector2:new( RL.Vector2AddValue( self, value ) )
end