summaryrefslogtreecommitdiff
path: root/examples/resources/lib/rectangle.lua
diff options
context:
space:
mode:
authorjussi2024-11-20 17:10:42 +0200
committerjussi2024-11-20 17:10:42 +0200
commitcf2c2eb05bd5d30169771b0087df84a53124f766 (patch)
tree8549266d3acdaed60e89ad1b49f67a437e9fb26c /examples/resources/lib/rectangle.lua
parentcddfc09ccc286726736fa436a10919021a177b69 (diff)
downloadreilua-enhanced-cf2c2eb05bd5d30169771b0087df84a53124f766.tar.gz
reilua-enhanced-cf2c2eb05bd5d30169771b0087df84a53124f766.tar.bz2
reilua-enhanced-cf2c2eb05bd5d30169771b0087df84a53124f766.zip
Type class updates.
Diffstat (limited to 'examples/resources/lib/rectangle.lua')
-rw-r--r--examples/resources/lib/rectangle.lua33
1 files changed, 32 insertions, 1 deletions
diff --git a/examples/resources/lib/rectangle.lua b/examples/resources/lib/rectangle.lua
index 3de80e4..6e08f52 100644
--- a/examples/resources/lib/rectangle.lua
+++ b/examples/resources/lib/rectangle.lua
@@ -2,7 +2,6 @@
if table.unpack == nil then
table.unpack = unpack
end
-
local Vector2 = Vector2 or require( "vector2" )
local Rectangle = {}
@@ -73,6 +72,17 @@ function Rectangle:newR( r )
return object
end
+function Rectangle:newV( position, size )
+ local object = setmetatable( {}, metatable )
+
+ object.x = position.x
+ object.y = position.y
+ object.width = size.x
+ object.height = size.y
+
+ return object
+end
+
function Rectangle:set( x, y, width, height )
self.x = x or 0
self.y = y or self.x
@@ -91,6 +101,13 @@ function Rectangle:setR( r )
self.height = r.height
end
+function Rectangle:setV( position, size )
+ self.x = position.x
+ self.y = position.y
+ self.width = size.x
+ self.height = size.y
+end
+
function Rectangle:serialize()
return "Rectangle:new("..self.x..","..self.y..","..self.width..","..self.height..")"
end
@@ -221,6 +238,20 @@ function Rectangle:tempR( r )
return object
end
+function Rectangle:tempV( position, size )
+ local object = tempPool[ curTemp ]
+
+ curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1
+
+ object.x = position.x
+ object.y = position.y
+ object.width = size.x
+ object.height = size.y
+
+ return object
+end
+
+
function Rectangle:getTempId()
return curTemp
end