Last active
August 29, 2015 14:01
-
-
Save codepaladin/04e7c8ed2fa73fcb8a65 to your computer and use it in GitHub Desktop.
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 tile map | |
function drawGrid() | |
for row = 0, 5 do | |
local gridRow = {} | |
for col = 0, 5 do | |
-- draw a diamond shaped tile | |
local vertices = { 0,-16, -64,16, 0,48, 64,16 } | |
local tile = display.newPolygon(group, 0, 0, vertices ) | |
-- outline the tile and make it transparent | |
tile.strokeWidth = 1 | |
tile:setStrokeColor( 0, 1, 1 ) | |
tile.alpha = .25 | |
-- set the tile's x and y coordinates | |
local x = col * tileHeight | |
local y = row * tileHeight | |
tile.x = x - y | |
-- the first part of this equation is to move the y coordinate down 32 pixels (tileHeight/2) | |
tile.y = (tileHeight/2) + ((x + y)/2) | |
-- make a tile walkable | |
gridRow[col] = 0 | |
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