-- bring in the util module local util = require("util") -- world stuffs local world = {} -- create a new world with given height and width 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] = {} for y = 1, world.height do world[x][y] = "nothing" end end end -- load the tile files function world.loadTiles() 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 function world.render(offset) for x = 1, world.width do for y = 1, world.height do local tile = world[x][y] local loc = util.cartToIso({x = x, y = y}) if tile == "grass" then image = world.tiles.grass elseif tile == "dirt" then image = world.tiles.dirt elseif tile == "water" then image = world.tiles.water else image = world.tiles.nothing end love.graphics.draw(image, loc.x * 16 + offset.x, loc.y * 16 + offset.y) end end if not world.hover == nil then love.graphics.draw(world.select, world.hover.x, world.hover.y) end end return world