Page 1 of 1

Procedurally Generated Maps?

PostPosted: Mon Nov 28, 2011 2:39 am
by jimmynewguy
I was seeing if I could do this for a game, just so I wouldn't have to design a bunch of levels and there still could be a lot of content. However, it doesn't seem to work so well since it's rather hard to make a random map and then connect all the rooms. Say I have an array "map" that is 25x25. In it, 0 is ground and 1 is a wall, if the floor is randomly generated and then checked. If the floor has 6 or more adjacent walls, then it will become a wall. If it has 3 or fewer than it will become floor. If it has 4 or 5 than it and all its neighbors will be floor. How would I go about making all the "rooms" that were generated connected?

Here's a small .exe that shows what I've got. It has a lot of holes and problems though...

EDIT: Nevermind, I read an article about this that was made for rouge based games. It helped a ton.

http://roguebasin.roguelikedevelopment. ... ike_Levels

Mine doesn't work as good as the examples he shows, but it works! :)

Re: Procedurally Generated Maps?

PostPosted: Mon Nov 28, 2011 7:49 pm
by jimmynewguy
Works pretty well for anyone who wants to see it. It makes a random map that is from the size of the view (64 X 48 tiles) all the way up to 99 X 99 rooms. Space bar to generate a random one. Wasd to move around the world :)

(you will be able to move diagonally fyi)

Re: Procedurally Generated Maps?

PostPosted: Tue Nov 29, 2011 1:03 pm
by Hblade
cool! :D

Re: Procedurally Generated Maps?

PostPosted: Tue Nov 29, 2011 6:21 pm
by SuperSonic
Looks very cool :P

Re: Procedurally Generated Maps?

PostPosted: Wed Nov 30, 2011 3:04 am
by jimmynewguy
Thanks! Looks like this now, player can move and stuff, there's treasure, and you have to explore to see the world now. Takes a little longer to generate maps now though :roll:

Re: Procedurally Generated Maps?

PostPosted: Sun Dec 04, 2011 11:23 pm
by jimmynewguy
Sloppiest looking code I have ever seen generates these maps now :oops: this will probably be it on this project... the code is too awful. Too much being created at once, too many for loops, too many ifs. I can post the .ged if anyone wants to make fun of it :lol: I just wanted it to work and wasn't too keen on making it clean.

EDIT: Oh, and when you use your turn you have to hit z to move again (since I never added an enemy to move and make it your turn.... sketchy)