-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen_game_over3.c
75 lines (70 loc) · 2.1 KB
/
screen_game_over3.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
/*
** EPITECH PROJECT, 2022
** screen_game_over3.c
** File description:
** screen_game_over3
*/
#include "my_runner.h"
int check_pos_mouse_g_o
(sfRenderWindow* window, sfEvent event,
screen_game_over_t *g_o, all_game_obj_t *all)
{
int ret = 0;
if (event.mouseButton.x > g_o->button2->pos.x &&
event.mouseButton.x < g_o->button2->pos.x + g_o->button2->rect.width &&
event.mouseButton.y > g_o->button2->pos.y &&
event.mouseButton.y < g_o->button2->pos.y + g_o->button2->rect.height) {
destroy_all_obj(all->player, all->bg, all->obj, all->clock);
sfMusic_destroy(all->music);
free(all);
destroy_g_o(g_o);
sfRenderWindow_close(window);
return 1;
}
ret = check_pos_mouse_g_o2(window, event, g_o, all);
return ret;
}
int check_pos_mouse_g_o2
(sfRenderWindow *window, sfEvent event,
screen_game_over_t *g_o, all_game_obj_t *all)
{
if (event.mouseButton.x > g_o->button1->pos.x &&
event.mouseButton.x < g_o->button1->pos.x + g_o->button1->rect.width &&
event.mouseButton.y > g_o->button1->pos.y &&
event.mouseButton.y < g_o->button1->pos.y + g_o->button1->rect.height) {
char *file = all->file;
destroy_all_obj(all->player, all->bg, all->obj, all->clock);
sfMusic_destroy(all->music);
free(all);
destroy_g_o(g_o);
runner(window, event, file);
return 1;
}
return 0;
}
int close_window_g_o
(sfRenderWindow *window, sfEvent event,
screen_game_over_t *g_o, all_game_obj_t *all)
{
if (event.type == sfEvtClosed) {
destroy_all_obj(all->player, all->bg, all->obj, all->clock);
sfMusic_destroy(all->music);
free(all);
destroy_g_o(g_o);
sfRenderWindow_close(window);
return 1;
}
return 0;
}
void destroy_g_o(screen_game_over_t *g_o)
{
destroy_title_obj(g_o->bg);
destroy_title_obj(g_o->button1);
destroy_title_obj(g_o->button2);
destroy_title_obj(g_o->outline);
sfSoundBuffer_destroy(g_o->sound->buffer);
sfSound_destroy(g_o->sound->sound);
sfMusic_stop(g_o->music);
sfMusic_destroy(g_o->music);
free(g_o);
}