Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local META = {}
- META =
- {
- __index = function(tbl, key) return META[key] end,
- x = 0,
- y = 0,
- setX = function(lhs, v) x = v end,
- setY = function(lhs, v) y = v end,
- getX = function(lhs) return x end,
- getY = function(lhs) return y end,
- getDistance = function(lhs, rhs)
- return math.sqrt(math.pow(lhs.x-rhs.x,2) + math.pow(lhs.y-rhs.y,2))
- end
- }
- function Vector2(x, y)
- local TBL = setmetatable({}, META)
- TBL:setX(x)
- TBL:setY(y)
- return TBL;
- end
- print("VAL:",Vector2(12,2):getX())
- print("VAL:",Vector2(12,2).x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement