Dungeon/Cave generator
Posted: Fri Apr 11, 2014 3:37 pm
Hi everbody!
I needed a good lua-dungeon-generator for my game. So I tried to make my own one. But it's a simple tunnel-cave generator.
Here is the download: --how you can use it
Do someone know a good dungeon generator, written in lua?
I needed a good lua-dungeon-generator for my game. So I tried to make my own one. But it's a simple tunnel-cave generator.
Here is the download: --how you can use it
Code: Select all
require("cave generator")
love.window.setMode(800,800)
--set the size
worldX = 150
worldY = 150
blockSize = 800/worldX
world = cave_generator.createWorld(worldX,worldY) --create an empty world
function love.keypressed(key)
if key==" " then
ok, dt = cave_generator.create(world,worldX,worldY,11) --create a cave, 11 is the cave-size, chose a size between 10 and ~20
end
end
function love.draw()
for x=1,worldX do
for y=1,worldY do
if world[x][y].type==0 or world[x][y].type==2 then --0==nothing, 1==air, 2==block
love.graphics.setColor(180,180,180)
love.graphics.rectangle("fill", (x-1)*blockSize, (y-1)*blockSize, blockSize, blockSize)
love.graphics.setColor(255,255,255)
elseif world[x][y].type==1 then
love.graphics.setColor(80,80,80)
love.graphics.rectangle("fill", (x-1)*blockSize, (y-1)*blockSize, blockSize, blockSize)
love.graphics.setColor(255,255,255)
end
end
end
end