36 lines
744 B
Lua
36 lines
744 B
Lua
require "config"
|
|
|
|
-- Game grid table, acts as "global level" of some sort
|
|
Grid = {}
|
|
|
|
-- Factory function
|
|
function Grid:new( size )
|
|
local grid = {
|
|
lines = {},
|
|
size = size
|
|
}
|
|
|
|
setmetatable( grid, { __index = self } )
|
|
|
|
return grid
|
|
end
|
|
|
|
-- Add new line to grid
|
|
function Grid:push( line )
|
|
table.insert( self.lines, line )
|
|
end
|
|
|
|
-- Draw lines and the whole grid
|
|
function Grid:draw()
|
|
-- 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, py, Config.pointRadius )
|
|
end
|
|
end
|
|
end
|