Compare commits
No commits in common. "master" and "v0.2" have entirely different histories.
3 changed files with 5 additions and 8 deletions
|
|
@ -7,7 +7,6 @@ VERSION = 'v0.2'
|
|||
---@field pointRadius number Radius of each grid point, relative to cellSize
|
||||
---@field linePointRadius number Radius of line start/end points, relative to cellSize
|
||||
---@field cellSize number Size of each grid cell
|
||||
---@field gridOffset number X offset of grid processing
|
||||
---@field lineStyle string love2d line style setting
|
||||
---@field lineWidth number love2d line width setting
|
||||
---@field menuLineWidth number love2d line width for buttons
|
||||
|
|
@ -18,7 +17,6 @@ Config = {
|
|||
linePointRadius = 0.4,
|
||||
|
||||
cellSize = 30,
|
||||
gridOffset = 160,
|
||||
|
||||
lineStyle = "smooth",
|
||||
lineWidth = 0.1,
|
||||
|
|
|
|||
5
grid.lua
5
grid.lua
|
|
@ -39,9 +39,8 @@ function Grid:draw()
|
|||
end
|
||||
|
||||
for y = 1, self.size.y do
|
||||
local gp = GridPoint:new(x, y)
|
||||
local px, py = gp:globalCoords()
|
||||
love.graphics.circle( "fill", px, py, Config.cellSize * Config.pointRadius)
|
||||
local px, py = x * Config.cellSize, y * Config.cellSize
|
||||
love.graphics.circle( "fill", px - Config.cellSize / 2, py - Config.cellSize / 2, Config.cellSize * Config.pointRadius)
|
||||
end
|
||||
end
|
||||
-- Draw lines
|
||||
|
|
|
|||
|
|
@ -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,7 +17,7 @@ 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,
|
||||
return self.x * Config.cellSize - Config.cellSize / 2,
|
||||
self.y * Config.cellSize - Config.cellSize / 2
|
||||
end
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ end
|
|||
---@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