-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
73 lines (65 loc) · 1.77 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
/*
** EPITECH PROJECT, 2019
** rpg
** File description:
** rpg
*/
#include "my_rpg.h"
void put_the_one_in_merch(data_t *data, int one)
{
int place = -1;
for (int i = 0; i < MAX_MERCHANT; i++)
if (data->merch.t.inventory.bag[i][0] == 26) {
place = i;
break;
}
if (place != -1) {
data->merch.t.inventory.bag[place][0] = one;
data->merch.t.inventory.bag[place][1] = 0;
}
}
void get_the_one_ring(data_t *data)
{
int place = -1;
data->boss.boss = 5;
for (int i = 0; i < MAX_MERCHANT; i++)
if (data->hero.inventory.bag[i][0] == 26) {
place = i;
break;
}
if (place != -1) {
data->hero.inventory.bag[place][0] = 25;
data->hero.inventory.bag[place][1] = 0;
data->hero.inventory.bag[place][2] = data->item_ref[25].stat.type;
if (sfSound_getStatus(data->sfx.sfx[6].sound) != sfPlaying)
sfSound_play(data->sfx.sfx[6].sound);
add_item_to_historical(&data->scenes[HUD], data->item_ref, 25);
} else
put_the_one_in_merch(data, 25);
}
void setup_game(data_t *data)
{
data->cur = MENU;
sfMusic_play(data->sfx.sfx[0].music);
}
int main(void)
{
data_t data;
sfEvent event = {0};
init_all_data(&data);
setup_game(&data);
data.hero.stat.life = 100;
while (sfRenderWindow_isOpen(data.window.w)) {
if (data.trans >= 10)
poll_event(&data, &event);
draw(&data);
data.delta_time.time = sfClock_restart(data.delta_time.clock);
data.delta_time.s = sfTime_asSeconds(data.delta_time.time);
if (data.trans > 100000)
data.trans = 15;
if (data.boss.boss == 4)
get_the_one_ring(&data);
}
cleanup(&data);
return (0);
}