Initial commit
This commit is contained in:
commit
f765ec74ef
6 changed files with 181 additions and 0 deletions
24
point.lua
Normal file
24
point.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
-- 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
|
Loading…
Add table
Add a link
Reference in a new issue