Jump to content
  • Advertisement
Sign in to follow this  
knedlik

XNA Maze Generating

This topic is 2854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi.
I'd like to ask you for an advice about generating random maze in XNA (C#).

My maze is generated from an array of ints [15,12], it looks like this:
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,0,0,0,0,0,0,0,0,1,0,1,1,0,1
1,0,1,1,1,1,1,0,1,1,0,1,1,0,1
5,0,1,1,0,0,0,0,0,1,0,0,0,0,1
1,1,1,1,0,1,1,1,1,1,0,1,1,0,1
1,1,1,1,0,1,1,0,0,0,0,1,1,0,1
1,1,1,1,0,1,1,0,1,1,0,1,1,0,1
1,0,1,1,0,0,1,0,1,1,0,0,0,0,1
1,0,1,0,1,0,1,0,1,1,1,1,1,0,1
1,0,1,1,1,0,1,0,1,1,0,1,1,0,1
1,0,0,0,0,0,0,0,0,0,0,1,1,2,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

1 is wall, 0 is empty space, 2 is start and 5 is finish.

Now everything works, but I'd like to create some function that will generate random maze. I read some tutorials, but it didn't help - every algorithm works only for mazes where cells are empty spaces and borders between cells are walls.

I don't want you to write whole code for me, just an advice how could I make it.
Thanks for every answer.

Share this post


Link to post
Share on other sites
Advertisement
One way would be to start your grid out something like:

11111
10101
11111
10101
11111

The initial 0's would be your "cells" and the 1's between them would be your "walls".

Share this post


Link to post
Share on other sites
This might be useful to you.

Quote:
every algorithm works only for mazes where cells are empty spaces and borders between cells are walls.


Sorry if this is obvious, but why is that a problem?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!