Initial commit
This commit is contained in:
commit
f765ec74ef
6 changed files with 181 additions and 0 deletions
36
grid.lua
Normal file
36
grid.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue