Ok, and thanks for the suggestions. I made a change in the above snippets that should work around that...
And oh ya, console would be a good idea...
And I'm going to post all that I have so far, it's a bit... Well it looks like someone just starting out. Haha.
Code: Select all
function love.load()
love.graphics.setBackgroundColor(0, 0, 0)
mapWidth = 20
mapHeight = 12
terrainSetImage = love.graphics.newImage("terrain_atlas.png")
terrainSize = 16
terrainQuads = {}
-- sky
terrainQuads[0] = love.graphics.newQuad(2*terrainSize, 2*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- blank dirt
terrainQuads[1] = love.graphics.newQuad(0*terrainSize, 0*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- top grass
terrainQuads[2] = love.graphics.newQuad(1*terrainSize, 0*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- left grass
terrainQuads[3] = love.graphics.newQuad(2*terrainSize, 0*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- right grass
terrainQuads[4] = love.graphics.newQuad(0*terrainSize, 1*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- bottom grass
terrainQuads[5] = love.graphics.newQuad(1*terrainSize, 1*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- top left grass
terrainQuads[6] = love.graphics.newQuad(2*terrainSize, 1*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- top right grass
terrainQuads[7] = love.graphics.newQuad(0*terrainSize, 2*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- top right left grass
terrainQuads[8] = love.graphics.newQuad(1*terrainSize, 2*terrainSize,
terrainSize, terrainSize, terrainSetImage:getWidth(),
terrainSetImage:getHeight())
-- map table
map = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 1, 7, 0, 0, 0},
{2, 2, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 1, 1, 1, 2, 2, 2},
{1, 1, 1, 7, 0, 0, 0, 0, 0, 0, 0, 6, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 7, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
}
end
function draw_map()
for y=1, mapHeight do
for x=1, mapWidth do
love.graphics.drawq(terrainSetImage,
terrainQuads[map[y][x]],
(x-1)*terrainSize, (y-1)*terrainSize, 0, 1, 1, 0, 0)
end
end
end
function love.keypressed(key)
if key == "escape" then -- if user wants to exit
love.event.push("q") -- then exit!
end
end
function love.draw()
draw_map()
end
It's a basic just drawing a map, I'm just trying to get used to drawing out "stationary" items before moving on.