Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / 3D Dungeon Style Level Generator

Author
Message
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 4th Jun 2011 01:16
For ages I was coming up with various types of algorithms that will automatically generate a random level or dungeon style level. After much though and hardly any programming lately I decided to use an amoeba style digger algorithm to generate a dungeon.

The main routine is called with the size of the play area in width and height and also with the amount of diggers to be used. The random seed is set to a specific number to generate the same dungeon each time it's run.

The code then calls the 3d level generator which very simply converts each point in the array to a 3d object.

Have fun with it!





Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 4th Jun 2011 01:34 Edited at: 4th Jun 2011 01:35
I do plan on making some upgrades to the generator once I have some more ideas such as adding doors, items, stairs, etc... Won't be long before each ameoba digger will create it own textures per grid point it digs out.

I also want to area check the map so I can add stairs going to other parts of the dungeon.

They're next on my list of things to do with this.

Warning! May contain Nuts!
tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 4th Jun 2011 02:16
Pretty cool. Is it better suited to a "cave" type map? Usually dungeons have some sort of planning to them. You could also incorporate a flood fill algorithm after generation, and adjust as needed, to make sure that up/down stairs are reachable.


A 3D marble platformer using Newton physics.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 4th Jun 2011 02:42
I've left shown on the created maps where the diggers die. I could use these to check which diggers are connected and which aren't. That way the other zones can be connected.

The flood fill is similar to the path finding algorithm I'm currently playing with to do just this.

Another type of level generator I've got an idea for is similar to creating a tree, taking a little bit more work though.

Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 7th Jun 2011 20:33 Edited at: 7th Jun 2011 20:34
I've now implemented the flood fill routine so things are coming along. This separates the dead ameobas into their zones/areas/caves. I've updated the generate 3d function so that it doesn't create un-necessary walls.



After running this program as it stands the text file returned shows something like this:


The code itself is now this:


Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 7th Jun 2011 22:21
I do have a question though... How do I make this into just one object?

I want to make each surface as a plain object, texture and position it and put each element into just one object. Is it something to do with limbs?

Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 8th Jun 2011 01:46
I've removed creating boxes for each object and replaced everything with just plane objects and included 12 different textures if anyone finds this useful.

Just use the mouse and cursor keys to free fly around for now to get the feel of what this creates. Alter the randomize seed value, and the other values in the two lines here


I've attached the complete source code, with the media.

Anyone got any pointers how to make this into one complete object???

Warning! May contain Nuts!
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Jun 2011 05:00
Quote: "Anyone got any pointers how to make this into one complete object???"


You could try making a mesh out of each plane, then adding it as a limb to your first object. That would affect the plane's position, and I'm not sure how that would affect the textures, you might need to texture each limb as well.

PS - instead of triple posting, you could just edit your last post to include the updated stuff. Just sayin'

Login to post a reply

Server time is: 2026-07-11 02:13:56
Your offset time is: 2026-07-11 02:13:56