-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.c
More file actions
74 lines (63 loc) · 2.25 KB
/
input.c
File metadata and controls
74 lines (63 loc) · 2.25 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
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* input.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tborges- <tborges-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/01 22:45:19 by tborges- #+# #+# */
/* Updated: 2024/12/02 19:45:06 by tborges- ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void move_player(t_game *game, t_coordinates current,
t_coordinates destination)
{
t_map *map;
map = &(game->map);
if (map->data[destination.y][destination.x] == 'C')
map->count_c--;
else if (map->data[destination.y][destination.x] == 'E'
&& map->count_c == 0)
exit(0);
map->data[destination.y][destination.x] = 'P';
map->data[current.y][current.x] = '0';
game->count_moves++;
ft_printf("Moves: %d\n", game->count_moves);
}
void move_left(t_game *game)
{
t_coordinates current;
t_coordinates destination;
current = get_player_position(game->map);
destination.x = current.x - 1;
destination.y = current.y;
check_restritions(game, current, destination);
}
void move_up(t_game *game)
{
t_coordinates current;
t_coordinates destination;
current = get_player_position(game->map);
destination.x = current.x;
destination.y = current.y - 1;
check_restritions(game, current, destination);
}
void move_rigth(t_game *game)
{
t_coordinates current;
t_coordinates destination;
current = get_player_position(game->map);
destination.x = current.x + 1;
destination.y = current.y;
check_restritions(game, current, destination);
}
void move_down(t_game *game)
{
t_coordinates current;
t_coordinates destination;
current = get_player_position(game->map);
destination.x = current.x;
destination.y = current.y + 1;
check_restritions(game, current, destination);
}