Last active
August 29, 2015 14:00
-
-
Save codepaladin/11145629 to your computer and use it in GitHub Desktop.
Jumper Draw Grid
This file contains 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
-- draw a tile map to the screen | |
-- populate the map table | |
function drawGrid() | |
for row = 1, 10 do | |
local gridRow = {} | |
for col = 1, 10 do | |
-- draw a tile | |
local tile = display.newRect((col * 50) - 25, (row * 50) - 25, 48, 48) | |
-- make some tiles un-walkable | |
if ((row == 4 or row == 6) and (col >2 and col < 9)) then | |
tile.alpha = 1 | |
gridRow[col] = 1 | |
else | |
tile.alpha = .5 | |
gridRow[col] = 0 | |
end | |
-- set the tile's pixel coordinates | |
tile.xyPixelCoordinate = {x=tile.x, y=tile.y} | |
-- set the tile's grid coordinates | |
tile.xyGridCoordinate = {x=col, y=row} | |
-- draw the start position | |
if(row == 3 and col == 4) then d | |
rawStart(tile.xyPixelCoordinate, tile.xyGridCoordinate) | |
end | |
-- draw the end position | |
if(row == 5 and col == 6) then d | |
rawEnd(tile.xyPixelCoordinate, tile.xyGridCoordinate) | |
end | |
end | |
-- add gridRow table to the map table | |
map[row] = gridRow | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment