diff options
| author | jussi | 2024-05-01 15:21:28 +0300 |
|---|---|---|
| committer | jussi | 2024-05-01 15:21:28 +0300 |
| commit | 4452bccfa63cf86c134aa616ee0bebcc66beca03 (patch) | |
| tree | a40befeb0393fd5599240ccb85a4500781d78c17 /examples/resources/lib/rectangle.lua | |
| parent | bdd660be01f3742befe15dff26929a77eeefe61d (diff) | |
| download | reilua-enhanced-4452bccfa63cf86c134aa616ee0bebcc66beca03.tar.gz reilua-enhanced-4452bccfa63cf86c134aa616ee0bebcc66beca03.tar.bz2 reilua-enhanced-4452bccfa63cf86c134aa616ee0bebcc66beca03.zip | |
Bitwise operations for cross Lua compatibility.
Diffstat (limited to 'examples/resources/lib/rectangle.lua')
| -rw-r--r-- | examples/resources/lib/rectangle.lua | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/examples/resources/lib/rectangle.lua b/examples/resources/lib/rectangle.lua index a167939..7413f53 100644 --- a/examples/resources/lib/rectangle.lua +++ b/examples/resources/lib/rectangle.lua @@ -47,9 +47,9 @@ function Rectangle:new( x, y, width, height ) local object = setmetatable( {}, Rectangle.meta ) object.x = x or 0 - object.y = y or 0 + object.y = y or object.x object.width = width or 0 - object.height = height or 0 + object.height = height or object.width return object end @@ -75,9 +75,9 @@ end function Rectangle:set( x, y, width, height ) self.x = x or 0 - self.y = y or 0 + self.y = y or self.x self.width = width or 0 - self.height = height or 0 + self.height = height or self.width end function Rectangle:setT( t ) @@ -183,27 +183,21 @@ end function Rectangle:temp( x, y, width, height ) local object = tempPool[ curTemp ] - curTemp = curTemp + 1 - if TEMP_COUNT < curTemp then - curTemp = 1 - end + curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1 object.x = x or 0 - object.y = y or 0 + object.y = y or object.x object.width = width or 0 - object.height = height or 0 + object.height = height or object.width return object end function Rectangle:tempT( t ) local object = tempPool[ curTemp ] - curTemp = curTemp + 1 - if TEMP_COUNT < curTemp then - curTemp = 1 - end + curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1 object.x, object.y, object.width, object.height = table.unpack( t ) @@ -212,11 +206,8 @@ end function Rectangle:tempR( r ) local object = tempPool[ curTemp ] - curTemp = curTemp + 1 - if TEMP_COUNT < curTemp then - curTemp = 1 - end + curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1 object.x = r.x object.y = r.y |
