|
|
@@ -7,6 +7,8 @@ local world = {} |
|
|
|
function world.new(width, height) |
|
|
|
world.width = width |
|
|
|
world.height = height |
|
|
|
world.hover = nil |
|
|
|
world.select = love.graphics.newImage("img/tiles/select.png") |
|
|
|
|
|
|
|
for x = 1, world.width do |
|
|
|
world[x] = {} |
|
|
@@ -18,11 +20,11 @@ local world = {} |
|
|
|
|
|
|
|
-- load the tile files |
|
|
|
function world.loadTiles() |
|
|
|
world.grass = love.graphics.newImage("img/tiles/grass.png") |
|
|
|
world.dirt = love.graphics.newImage("img/tiles/dirt.png") |
|
|
|
world.water = love.graphics.newImage("img/tiles/water.png") |
|
|
|
world.nothing = love.graphics.newImage("img/tiles/nothing.png") |
|
|
|
world.select = love.graphics.newImage("img/tiles/select.png") |
|
|
|
world.tiles = {} |
|
|
|
world.tiles.grass = love.graphics.newImage("img/tiles/grass.png") |
|
|
|
world.tiles.dirt = love.graphics.newImage("img/tiles/dirt.png") |
|
|
|
world.tiles.water = love.graphics.newImage("img/tiles/water.png") |
|
|
|
world.tiles.nothing = love.graphics.newImage("img/tiles/nothing.png") |
|
|
|
end |
|
|
|
|
|
|
|
-- render the world |
|
|
@@ -33,18 +35,22 @@ local world = {} |
|
|
|
local loc = util.cartToIso({x = x, y = y}) |
|
|
|
|
|
|
|
if tile == "grass" then |
|
|
|
image = world.grass |
|
|
|
image = world.tiles.grass |
|
|
|
elseif tile == "dirt" then |
|
|
|
image = world.dirt |
|
|
|
image = world.tiles.dirt |
|
|
|
elseif tile == "water" then |
|
|
|
image = world.water |
|
|
|
image = world.tiles.water |
|
|
|
else |
|
|
|
image = world.nothing |
|
|
|
image = world.tiles.nothing |
|
|
|
end |
|
|
|
|
|
|
|
love.graphics.draw(image, loc.x * 16 + offset.x, loc.y * 16 + offset.y) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
if not world.hover == nil then |
|
|
|
love.graphics.draw(world.select, world.hover.x, world.hover.y) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
return world |