-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovement_utils.c
50 lines (45 loc) · 1.68 KB
/
movement_utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* movement_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mkorpela <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 16:59:38 by mkorpela #+# #+# */
/* Updated: 2024/03/13 06:46:28 by mkorpela ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void increment_and_print_steps(t_game *game)
{
game->steps += 1;
ft_printf("Steps: %d\n", game->steps);
}
void disable_carrot_instance(t_game *game)
{
int i;
i = 0;
while (i < game->carrots)
{
if (game->bunny_x == (game->img->carrot->instances[i].x) / 64
&& game->bunny_y == (game->img->carrot->instances[i].y) / 64)
{
game->img->carrot->instances[i].enabled = false;
game->collected_carrots++;
}
i++;
}
}
void is_game_over(t_game *game)
{
if (game->exit_x == game->bunny_x && game->exit_y == game->bunny_y)
{
if (game->carrots == game->collected_carrots)
{
ft_printf("\n-------------CONGRATULATIONS!------------\n");
ft_printf("Bunny got to eat all those yummy carrots!\n");
ft_printf("Bunny made it safely home. :)\n\n");
mlx_close_window(game->mlx);
}
}
}