Created
October 18, 2015 02:16
-
-
Save jacobmischka/10174847ec2983eca16c to your computer and use it in GitHub Desktop.
???
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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