diff --git a/config.lua b/config.lua index 08189f4..c2c79e7 100644 --- a/config.lua +++ b/config.lua @@ -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, diff --git a/grid.lua b/grid.lua index 3af32da..fd1e57c 100644 --- a/grid.lua +++ b/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 diff --git a/gridpoint.lua b/gridpoint.lua index e8d57e0..eff5a8f 100644 --- a/gridpoint.lua +++ b/gridpoint.lua @@ -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