diff options
| author | jussi | 2024-05-22 00:11:40 +0300 |
|---|---|---|
| committer | jussi | 2024-05-22 00:11:40 +0300 |
| commit | cb1bc03681dff958da6ff851cfe32dfdd83f6f8d (patch) | |
| tree | 59ba256ce41cec8ac7e0d91b68baf222a9ff596a /examples/resources/lib/vector2.lua | |
| parent | c95c797da61b4b2829d542f6d7c164a88951cad4 (diff) | |
| download | reilua-enhanced-cb1bc03681dff958da6ff851cfe32dfdd83f6f8d.tar.gz reilua-enhanced-cb1bc03681dff958da6ff851cfe32dfdd83f6f8d.tar.bz2 reilua-enhanced-cb1bc03681dff958da6ff851cfe32dfdd83f6f8d.zip | |
Object lib serialization.
Diffstat (limited to 'examples/resources/lib/vector2.lua')
| -rw-r--r-- | examples/resources/lib/vector2.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/resources/lib/vector2.lua b/examples/resources/lib/vector2.lua index 68adc2b..8616a51 100644 --- a/examples/resources/lib/vector2.lua +++ b/examples/resources/lib/vector2.lua @@ -67,7 +67,6 @@ function Vector2:newV( v ) return object end - function Vector2:set( x, y ) self.x = x or 0 self.y = y or self.x @@ -82,6 +81,10 @@ function Vector2:setV( v ) self.y = v.y end +function Vector2:serialize() + return "Vector2:new("..self.x..","..self.y..")" +end + function Vector2:arr() return { self.x, self.y } end @@ -106,6 +109,10 @@ function Vector2:max( v2 ) return Vector2:new( math.max( self.x, v2.x ), math.max( self.y, v2.y ) ) end +function Vector2:round() + return Vector2:new( RL.Round( self.x ), RL.Round( self.y ) ) +end + function Vector2:floor() return Vector2:new( math.floor( self.x ), math.floor( self.y ) ) end |
