-
Notifications
You must be signed in to change notification settings - Fork 0
/
end_screens.c
65 lines (60 loc) · 2.43 KB
/
end_screens.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* game_lost.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apereira <apereira@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/18 10:57:01 by apereira #+# #+# */
/* Updated: 2023/01/19 18:23:38 by apereira ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void enemy_check(t_game *game)
{
if (game->matriz[game->pp_y / 64][(game->pp_x + 19) / 64] == 'G')
game->p += 2;
if (game->matriz[(game->pp_y + 19) / 64][(game->pp_x + 39) / 64] == 'G')
game->p += 2;
if (game->matriz[(game->pp_y + 39) / 64][(game->pp_x + 19) / 64] == 'G')
game->p += 2;
if (game->matriz[(game->pp_y + 19) / 64][game->pp_x / 64] == 'G')
game->p += 2;
}
void exit_check(t_game *game)
{
if (game->matriz[game->pp_y / 64][(game->pp_x + 19) / 64] == 'E')
game->p++;
if (game->matriz[(game->pp_y + 19) / 64][(game->pp_x + 39) / 64] == 'E')
game->p++;
if (game->matriz[(game->pp_y + 39) / 64][(game->pp_x + 19) / 64] == 'E')
game->p++;
if (game->matriz[(game->pp_y + 19) / 64][game->pp_x / 64] == 'E')
game->p++;
}
void display_victory(t_game game)
{
mlx_clear_window(game.mlx, game.wdw);
mlx_destroy_window(game.mlx, game.wdw);
game.wdw = NULL;
game.wdw2 = mlx_new_window(game.mlx, 1000, 560,
"Congratulations !");
mlx_put_image_to_window(game.mlx, game.wdw2, game.t_img.won,
0, 0);
mlx_hook(game.wdw2, 2, 1L << 0, keydown, &game);
mlx_hook(game.wdw2, 17, 1L << 17, destroy_wdw, &game);
mlx_loop(game.mlx);
}
void display_loss(t_game game)
{
mlx_clear_window(game.mlx, game.wdw);
mlx_destroy_window(game.mlx, game.wdw);
game.wdw = NULL;
game.wdw2 = mlx_new_window(game.mlx, 1000, 560,
"Better luck next time !");
mlx_put_image_to_window(game.mlx, game.wdw2, game.t_img.lost,
0, 0);
mlx_hook(game.wdw2, 2, 1L << 0, keydown, &game);
mlx_hook(game.wdw2, 17, 1L << 17, destroy_wdw, &game);
mlx_loop(game.mlx);
}