-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
70 lines (64 loc) · 1.84 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mhedeon <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/10 16:15:24 by mhedeon #+# #+# */
/* Updated: 2019/01/31 20:02:40 by mhedeon ### ########.fr */
/* */
/* ************************************************************************** */
#include "wolf3d.h"
int pause_frame(Uint32 pause)
{
SDL_Event event;
Uint32 time;
time = SDL_GetTicks();
while ((SDL_GetTicks() - time) < pause)
{
if (SDL_PollEvent(&event))
;
SDL_Delay(1);
}
return (0);
}
static int select_lvl(t_wolf *wolf, int lvl)
{
wolf->hero->health = 60;
wolf->hero->bullet = 8;
wolf->hero->score = 0;
if (lvl == LVL1)
start_lvl_1(wolf);
else if (lvl == LVL2)
start_lvl_2(wolf);
else if (lvl == LVL3)
start_lvl_3(wolf);
else if (lvl == LVL4)
start_lvl_4(wolf);
return (1);
}
int main(void)
{
t_wolf *wolf;
int lvl;
wolf = malloc(sizeof(t_wolf));
if (wolf == NULL)
return (get_error(WOLF_ERR));
if (pre_init(wolf))
{
Mix_Volume(-1, SDL_MIX_MAXVOLUME / 2);
Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 2);
wolf->volume = (SDL_MIX_MAXVOLUME / 2) - 4;
intro(wolf);
while (1)
{
lvl = start_menu(wolf, &wolf->menu);
select_lvl(wolf, lvl);
if (lvl < 1)
break ;
}
}
free_garbage_1(wolf);
return (0);
}