-
Notifications
You must be signed in to change notification settings - Fork 0
/
collisions.c
52 lines (48 loc) · 1.92 KB
/
collisions.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* collisions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hgrissen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/04 17:56:18 by hgrissen #+# #+# */
/* Updated: 2021/11/04 20:09:39 by hgrissen ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int exit_collision(char **map, t_pos *pos, t_input input)
{
if (input.down && map[pos->y + 1][pos->x] == 'E')
return (1);
else if (input.up && map[pos->y - 1][pos->x] == 'E')
return (1);
else if (input.left && map[pos->y][pos->x - 1] == 'E')
return (1);
else if (input.right && map[pos->y][pos->x + 1] == 'E')
return (1);
return (0);
}
int col_collision(char **map, t_pos *pos, t_input input)
{
if (input.down && map[pos->y + 1][pos->x] == 'C')
return (1);
else if (input.up && map[pos->y - 1][pos->x] == 'C')
return (1);
else if (input.left && map[pos->y][pos->x - 1] == 'C')
return (1);
else if (input.right && map[pos->y][pos->x + 1] == 'C')
return (1);
return (0);
}
int wall_collision(char **map, t_pos *pos, t_input input)
{
if (input.down && map[pos->y + 1][pos->x] == '1')
return (1);
else if (input.up && map[pos->y - 1][pos->x] == '1')
return (1);
else if (input.left && map[pos->y][pos->x - 1] == '1')
return (1);
else if (input.right && map[pos->y][pos->x + 1] == '1')
return (1);
return (0);
}