Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Maze Generate(int w, int h)
- {
- var m = new Maze() { Map = new bool[w * 2 + 1, h * 2 + 1] };
- m.Map[m.W / 2, m.H - 1] = true;
- m.Open(new intVector2(m.W / 2, m.H - 2));
- return m;
- }
- void Open(intVector2 p)
- {
- Map[p.X, p.Y] = true;
- foreach (var d in Directions.Shuffle(rng))
- {
- var wall = p + d;
- var next = wall + d;
- if (Bounds.Contains(next.X, next.Y) && !Map[wall.X, wall.Y] && !Map[next.X, next.Y])
- {
- Map[wall.X, wall.Y] = true;
- Open(next);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement