Skip to content

Instantly share code, notes, and snippets.

@jacobmischka
Created October 18, 2015 02:16
Show Gist options
  • Save jacobmischka/10174847ec2983eca16c to your computer and use it in GitHub Desktop.
Save jacobmischka/10174847ec2983eca16c to your computer and use it in GitHub Desktop.
???
local tile = require("tile")
local board = {}
function board:new()
o = o or {}
setmetatable(o, self)
self.__index = self
o.tiles = {}
return o
end
function board:reset()
self.tiles = {}
for i = 1, 8 do
self.tiles[i] = {}
for j = 1, 8 do
self.tiles[i][j] = tile:new(round(math.random() * 12 + 1), i, j)
print(self.tiles[i][j].id)
print(self.id)
end
end
end
function board:draw()
for i = 1, 8 do
for j = 1, 8 do
if self.tiles and self.tiles[i] and self.tiles[i][j] then
self.tiles[i][j]:draw()
end
end
end
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
return board
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment