Procedurally Generated Maps?

Talk about making games.

Procedurally Generated Maps?

Postby jimmynewguy » Mon Nov 28, 2011 2:39 am

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! :)
Attachments
test.zip
(783.29 KiB) Downloaded 101 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Procedurally Generated Maps?

Postby jimmynewguy » Mon Nov 28, 2011 7:49 pm

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)
Attachments
Example2.PNG
Example.PNG
Generated Maps.zip
(785.88 KiB) Downloaded 96 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Procedurally Generated Maps?

Postby Hblade » Tue Nov 29, 2011 1:03 pm

cool! :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Procedurally Generated Maps?

Postby SuperSonic » Tue Nov 29, 2011 6:21 pm

Looks very cool :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Procedurally Generated Maps?

Postby jimmynewguy » Wed Nov 30, 2011 3:04 am

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:
Attachments
untitled.PNG
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Procedurally Generated Maps?

Postby jimmynewguy » Sun Dec 04, 2011 11:23 pm

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)
Attachments
test.zip
(786.01 KiB) Downloaded 98 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest