-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
48 lines (41 loc) · 1.03 KB
/
main.c
File metadata and controls
48 lines (41 loc) · 1.03 KB
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
#include "includes.h"
int main(int argc, char **argv)
{
srand(time(NULL));
Node *start = NULL, *last = NULL, *nodes = NULL;
int width = 0, height = 0, choice = 0;
enum choice { generateLabirynth = 1, endProgram = 2};
bool areSizesValid = false;
while (choice != endProgram)
{
if (argc == 1)
choice = viewMenu();
else
{
getValuesFromCommandLineArguments(&height, &width, argv);
choice = generateLabirynth;
}
switch (choice)
{
case generateLabirynth:
do {
if(argc == 1)
setDimensionsManually(&width, &height);
areSizesValid = validateSizes(height, width);
argc = 1;
} while (!areSizesValid);
initializeMaze(width, height, &nodes);
setupStartNodeForGenerator(&start, &last, &nodes, width);
while ((last = linkNodes(last, width, height, &nodes)) != start);
setExitAndEntrance(width, height, &nodes);
break;
case endProgram:
_CrtDumpMemoryLeaks();
return 0;
}
showTheWay(&width, &height, &nodes);
resetLabirynth(&width, &height, &nodes);
system("pause");
}
return 0;
}