Changed drawing order and updated line connecting
This commit is contained in:
parent
abce928481
commit
178043bac3
2 changed files with 23 additions and 4 deletions
19
grid.lua
19
grid.lua
|
@ -22,20 +22,26 @@ end
|
|||
|
||||
-- Draw lines and the whole grid
|
||||
function Grid:draw()
|
||||
-- Draw lines
|
||||
-- Draw grid
|
||||
for x = 1, self.size.x do-- Draw lines
|
||||
for _, line in ipairs( self.lines ) do
|
||||
line:draw()
|
||||
end
|
||||
-- Draw grid
|
||||
for x = 1, self.size.x do
|
||||
|
||||
for y = 1, self.size.y do
|
||||
local px, py = x * Config.cellSize, y * Config.cellSize
|
||||
love.graphics.circle( "fill", px - Config.cellSize / 2, py - Config.cellSize / 2, Config.pointRadius)
|
||||
end
|
||||
end
|
||||
-- Draw lines
|
||||
for _, line in ipairs( self.lines ) do
|
||||
line:draw()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check all lines and return one, which contains point (if any)
|
||||
-- TODO: rewrite this function to extract clear/reverse behavior
|
||||
function Grid:matchesLine( point, ignoreEnd )
|
||||
local line = self.lines[tableFind( self.lines, point,
|
||||
function( value, innervalue )
|
||||
|
@ -71,6 +77,13 @@ function Grid:matchesLine( point, ignoreEnd )
|
|||
return line
|
||||
end
|
||||
|
||||
function Grid:isOtherEndpoint( line, point )
|
||||
return tableHas( self.lines, { line=line, point=point }, function( value, innervalue )
|
||||
return innervalue ~= value.line and innervalue.endpoint:equals( value.point )
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function Grid:inBounds( point )
|
||||
return point.x <= self.size.x and point.y <= self.size.y
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue