|
|
@@ -16,7 +16,7 @@ local world = {} |
|
|
|
for y = 1, world.depth do |
|
|
|
world[x][y] = {} |
|
|
|
for z = 1, world.height do |
|
|
|
world[x][y][z] = "nothing" |
|
|
|
world[x][y][z] = "air" |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@@ -24,7 +24,22 @@ local world = {} |
|
|
|
|
|
|
|
-- generates a world, should be called after world.new() |
|
|
|
function world.generate() |
|
|
|
|
|
|
|
-- draw the bottom layer of dirt |
|
|
|
for x = 1, world.width do |
|
|
|
for y = 1, world.depth do |
|
|
|
world[x][y][1] = "dirt" |
|
|
|
end |
|
|
|
end |
|
|
|
-- draw the grass |
|
|
|
for x = 1, world.width do |
|
|
|
for y = 1, world.depth do |
|
|
|
world[x][y][2] = "grass" |
|
|
|
end |
|
|
|
end |
|
|
|
-- draw a stream |
|
|
|
for x = 1, world.width do |
|
|
|
world[x][5][2] = "water" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
-- load the tile files |
|
|
@@ -50,16 +65,20 @@ local world = {} |
|
|
|
image = world.tiles.dirt |
|
|
|
elseif tile == "water" then |
|
|
|
image = world.tiles.water |
|
|
|
elseif tile == "air" then |
|
|
|
image = nil |
|
|
|
else |
|
|
|
image = world.tiles.nothing |
|
|
|
end |
|
|
|
|
|
|
|
love.graphics.draw(image, loc.x * 16 + offset.x, loc.y * 16 + offset.y - z * 16) |
|
|
|
|
|
|
|
if image ~= nil then |
|
|
|
love.graphics.draw(image, loc.x * 16 + offset.x, loc.y * 16 + offset.y - z * 16) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
if not world.hover == nil then |
|
|
|
if world.hover ~= nil then |
|
|
|
love.graphics.draw(world.select, world.hover.x, world.hover.y) |
|
|
|
end |
|
|
|
end |
|
|
|