From cb1bc03681dff958da6ff851cfe32dfdd83f6f8d Mon Sep 17 00:00:00 2001 From: jussi Date: Wed, 22 May 2024 00:11:40 +0300 Subject: Object lib serialization. --- examples/resources/lib/vector2.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'examples/resources/lib/vector2.lua') 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 -- cgit v1.2.3