21 lines
526 B
Lua
21 lines
526 B
Lua
require "point"
|
|
require "config"
|
|
|
|
-- Point table with grid-based coordinates
|
|
---@class GridPoint: Point
|
|
GridPoint = Point
|
|
|
|
-- Convert grid x, y to global x, y
|
|
---@return Point
|
|
function GridPoint:absolute()
|
|
return Point:new(
|
|
self.x * Config.cellSize,
|
|
self.y * Config.cellSize
|
|
)
|
|
end
|
|
|
|
-- Same as coords, but converted to global coords
|
|
---@return number, number
|
|
function GridPoint:globalCoords()
|
|
return self.x * Config.cellSize - Config.cellSize / 2, self.y * Config.cellSize - Config.cellSize / 2
|
|
end
|