-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
75 lines (70 loc) · 2.45 KB
/
main.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, 2020
** myhunter
** File description:
** main hunter
*/
#include "runner.h"
void initguistruct(myrunner_t *myh)
{
myh->backg = spriteinit("images/logobk.png");
myh->playbtn = spriteinit("images/playbtn.png");
myh->settingsbtn = spriteinit("images/settingsbtn.png");
myh->exitbtn = spriteinit("images/exitbtn.png");
myh->playbtn_hover = spriteinit("images/playhover.png");
myh->settingsbtn_hover = spriteinit("images/settingshover.png");
myh->exitbtn_hover = spriteinit("images/exithover.png");
myh->backbgpos = myposinit(0, 0, myh->backg);
myh->backbgscale = mypscaleinit(0.8, 0.8, myh->backg);
myh->pos_playbtn = myposinit(50, 480, myh->playbtn);
myh->pos_settingsbtn = myposinit(310, 480, myh->settingsbtn);
myh->pos_exitbtn = myposinit(570, 480, myh->exitbtn);
myh->scale_playbtn = mypscaleinit(0.5, 0.5, myh->playbtn);
myh->scale_settingsbtn = mypscaleinit(0.5, 0.5, myh->settingsbtn);
myh->scale_exitbtn = mypscaleinit(0.5, 0.5, myh->exitbtn);
}
void initmygame(myrunner_t *myh, sfRenderWindow* window)
{
sfRenderWindow_drawSprite(window, myh->backg, NULL);
sfRenderWindow_drawSprite(window, myh->playbtn, NULL);
sfRenderWindow_drawSprite(window, myh->settingsbtn, NULL);
sfRenderWindow_drawSprite(window, myh->exitbtn, NULL);
}
int guiinit(void)
{
myrunner_t *myh = malloc(sizeof(myrunner_t));
sfVideoMode mode = {800, 600, 32};
sfRenderWindow* window;
sfEvent event;
window = sfRenderWindow_create(mode,
"UBERUNNER | DELIVER PIZZA WITHOUT DROPPING IT", sfResize | sfClose, NULL);
init_my_assets(myh, window, event);
play_music(myh, window, event);
while (sfRenderWindow_isOpen(window)) {
dispatch_my_main_func(myh, window, event);
dispatch_my_second_func(myh, window, event);
dispatch_my_third_func(myh, window, event);
while (sfRenderWindow_pollEvent(window, &event)) {
if (event.type == sfEvtClosed) {
sfRenderWindow_close(window);
sfMusic_stop(myh->music_menu);
}
}
sfRenderWindow_display(window);
}
}
int main(int argc, char **argv)
{
if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'h') {
help_disp();
return (0);
}
else if (argc >= 2 && argv[1] != "-h") {
my_putstr("Wrong argument!Type -h to get help.\n");
return (84);
} else {
guiinit();
return (0);
}
return (0);
}