-
Notifications
You must be signed in to change notification settings - Fork 0
/
maze.c
91 lines (75 loc) · 1.53 KB
/
maze.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* file: maze.c
* Author: Sweilam
*/
#include "headers.h"
/* global vars */
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *texture;
uint32_t buffer[SCREEN_HEIGHT][SCREEN_WIDTH];
uint32_t tiles[TEX_COUNT][TEX_HEIGHT][TEX_WIDTH];
point_t pos;
point_t direction;
point_t plane;
double time;
/**
* main - render maze
* @argc: number of arguments
* @argv: the array containing arguments
* Return: 0 on success, 1 on failure
*/
int main(int argc, char* argv[])
{
int *maze; /*pointer to 2d array containing maze map*/
char *NameofMap;
bool textured;
pos.x = 1;
pos.y = 2;
direction.x = 1;
direction.y = -0.55;
plane.x = 0;
plane.y = 0.55;
time = 0;
NameofMap = "\0";
textured = false;
if (argc == 3 )
{
if (strcmp(argv[2], "tex") == 0)
textured = true;
NameofMap = argv[1];
}
else if (argc == 2)
{
if (strcmp(argv[1], "no_tex") == 0)
NameofMap = "maps/first_map";
else
{
NameofMap = argv[1];
}
}
else if (argc == 1)
{
NameofMap = "maps/first_map";
}
if (!init_SDL())
return (1);
maze = NULL;
maze = mapParser(NameofMap, maze);
if (maze == NULL)
{
printf("Cannot load map");
return (1);
}
while(true)
{
if(!textured)
renderBGFlat();
raycaster(maze, textured);
user_input(maze);
}
/*clean up */
closeSDL();
free(maze);
return (0);
}