-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.c
100 lines (97 loc) · 2.07 KB
/
check.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
92
93
94
95
96
97
98
99
100
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* count_coin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: youel-id <youel-id@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/13 18:12:52 by youel-id #+# #+# */
/* Updated: 2023/01/13 18:12:54 by youel-id ### ########.fr */
/* */
/* ************************************************************************** */
#include"so_long.h"
int check_coin_exit(t_data *data)
{
int x = 0;
int y = 0;
int i = -1;
while (data->arr[++i])
{
int j = -1;
while (data->arr[i][++j])
{
if (data->arr[i][j] == 'E')
{
x = j;
y = i;
}
if (data->arr[i][j] == 'C')
{
data->cx= j;
data->cy = i;
}
}
}
if (data->arr[y][x] != 'E')
{
printf("Error: No End point\n");
return 0;
}
if (data->arr[data->cy][data->cx] != 'C')
{
printf("Error: No coin\n");
return 0;
}
return (1);
}
int check_walls_player(t_data *data)
{
int x;
int y;
int j;
int i;
i = -1;
while(data->arr[++i])
{
j = -1;
while(data->arr[i][++j])
{
if(data->arr[i][j] == '1')
{
x = j;
y = i;
break;
}
}
}
if(data->arr[y][x] != '1')
{
printf("Error: NO Walls");
return 0;
}
return(1);
}
int check_player(t_data *data)
{
int i;
int j;
i = -1;
while(data->arr[++i])
{
j = -1;
while (data->arr[i][j++])
{
if(data->arr[i][j] == 'p')
{
data->xp = j;
data->yp = i;
}
}
}
if(data->arr[data->yp][data->xp] != 'P')
{
printf("Error: PLAYER");
return 0;
}
return(1);
}