-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaze_generator_2.c
60 lines (54 loc) · 903 Bytes
/
maze_generator_2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "wolf.h"
void go_up(int **maze, int i, int j, int size)
{
if (maze[i - 2][j] != 0)
{
maze[i - 2][j] = 0;
maze[i - 1][j] = 0;
generation(maze, i - 2, j, size);
}
}
void go_down(int **maze, int i, int j, int size)
{
if (maze[i + 2][j] != 0)
{
maze[i + 2][j] = 0;
maze[i + 1][j] = 0;
generation(maze, i + 2, j, size);
}
}
void go_left(int **maze, int i, int j, int size)
{
if (maze[i][j - 2] != 0)
{
maze[i][j - 2] = 0;
maze[i][j - 1] = 0;
generation(maze, i, j - 2, size);
}
}
void go_right(int **maze, int i, int j, int size)
{
if (maze[i][j + 2] != 0)
{
maze[i][j + 2] = 0;
maze[i][j + 1] = 0;
generation(maze, i, j + 2, size);
}
}
void set_exit(t_env *world)
{
int i;
int j;
j = world->size - 1;
i = world->size - 1;
while (j > 1)
{
if (world->map[i - 1][j] == 0)
{
world->exit_x = i - 1;
world->exit_y = j;
break ;
}
j--;
}
}