it works
This commit is contained in:
parent
c6547c1121
commit
d5e8a6945e
6 changed files with 77 additions and 28 deletions
|
|
@ -9,7 +9,7 @@ GridPoint = Point
|
|||
---@return Point
|
||||
function GridPoint:absolute()
|
||||
return Point:new(
|
||||
self.x * Config.cellSize + Config.gridOffset,
|
||||
self.x * Config.cellSize,
|
||||
self.y * Config.cellSize
|
||||
)
|
||||
end
|
||||
|
|
@ -17,15 +17,15 @@ end
|
|||
-- Same as coords, but converted to global coords
|
||||
---@return number, number
|
||||
function GridPoint:globalCoords()
|
||||
return self.x * Config.cellSize - Config.cellSize / 2 + Config.gridOffset,
|
||||
self.y * Config.cellSize - Config.cellSize / 2
|
||||
return self.x * Config.cellSize,
|
||||
self.y * Config.cellSize
|
||||
end
|
||||
|
||||
-- Returns local coords from global
|
||||
---@param point Point
|
||||
---@return GridPoint
|
||||
function GridPoint.snapCoords( point )
|
||||
local x = math.ceil( (point.x - Config.gridOffset) / Config.cellSize )
|
||||
local x = math.ceil( (point.x) / Config.cellSize )
|
||||
local y = math.ceil( point.y / Config.cellSize )
|
||||
return GridPoint:new( x, y )
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue