-
Notifications
You must be signed in to change notification settings - Fork 0
/
hunter.c
executable file
·76 lines (69 loc) · 1.52 KB
/
hunter.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
76
/*
** EPITECH PROJECT, 2023
** bsfml.c
** File description:
** boostrap
*/
#include "lib/my/include/my.h"
#include <stdbool.h>
#include "lib/my/include/struct.h"
#include <stdlib.h>
#include <stdio.h>
void cleanup(GLOBAL_T *ALL)
{
for (int i = 0; i < NB; i++) {
sfSprite_destroy(ALL->pics[i].sprite);
sfTexture_destroy(ALL->pics[i].texture);
}
free(ALL->pics);
if (ALL->stgs.win != NULL) {
sfRenderWindow_destroy(ALL->stgs.win);
}
sfSound_destroy(ALL->son.ost);
sfSoundBuffer_destroy(ALL->son.buffergame);
}
int help_display(void)
{
FILE *file = fopen("./content/help.txt", "r");
char ch;
if (file == NULL) {
my_printf("Erreur en ouvrant le fichier d'aide\n");
return 84;
}
while (fread(&ch, 1, 1, file) == 1) {
my_printf("%c", ch);
}
fclose(file);
return 0;
}
int initialize(GLOBAL_T *ALL, int argc, char *argv[], char *envp[])
{
char *arg;
int result_env;
for (int i = 1; i < argc; i++) {
arg = argv[i];
if (arg[0] == '-' && arg[1] == 'h' && arg[2] == '\0') {
help_display();
return 84;
}
}
result_env = checking(envp);
if (result_env == 84) {
return 84;
}
if (starting(ALL) == 84) {
return 84;
}
return 0;
}
int main(int argc, char *argv[], char *envp[])
{
GLOBAL_T ALL;
if (initialize(&ALL, argc, argv, envp) == 84) {
return 84;
}
sound_init(&ALL);
window_menu(&ALL);
cleanup(&ALL);
return 0;
}