-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_error.c
70 lines (64 loc) · 1.65 KB
/
map_error.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dalba-de <dalba-de@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/19 17:51:48 by dalba-de #+# #+# */
/* Updated: 2020/05/19 18:36:16 by dalba-de ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/cub3d.h"
int check_w(int x, int y, t_cub *cub)
{
while (x >= 0)
{
if (cub->map[y][x] == '1')
return (1);
x--;
}
return (0);
}
int check_e(int x, int y, t_cub *cub)
{
while (x < cub->map_x)
{
if (cub->map[y][x] == '1')
return (1);
x++;
}
return (0);
}
int check_s(int x, int y, t_cub *cub)
{
while (y < cub->map_y)
{
if (cub->map[y][x] == '1')
return (1);
y++;
}
return (0);
}
int check_n(int x, int y, t_cub *cub)
{
while (y >= 0)
{
if (cub->map[y][x] == '1')
return (1);
y--;
}
return (0);
}
char f_char(int x, int y, t_cub *cub)
{
if (cub->map[y][x] == '1')
return ('1');
else
{
if (check_n(x, y, cub) && check_s(x, y, cub)
&& check_e(x, y, cub) && check_w(x, y, cub))
return (cub->map[y][x]);
}
return ('9');
}