24 lines
396 B
Lua
24 lines
396 B
Lua
-- Point table
|
|
Point = {}
|
|
|
|
-- Factory function
|
|
function Point:new( x, y )
|
|
local point = {
|
|
x = x or 1,
|
|
y = y or 1
|
|
}
|
|
|
|
setmetatable( point, { __index = self } )
|
|
|
|
return point
|
|
end
|
|
|
|
-- Comparing function
|
|
function Point:equals( point )
|
|
return self.x == point.x and self.y == point.y
|
|
end
|
|
|
|
-- Get self coordinates
|
|
function Point:coords()
|
|
return self.x, self.y
|
|
end
|