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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#include "rodeo.h"
#include <inttypes.h>
#include "input.h"
#include "player.h"
#include "bullet.h"
#include "enemies.h"
#include "wall.h"
#include "debug.h"
#include "init.h"
#include "menu.h"
const uint16_t window_width = 1600;
const uint16_t window_height = 900;
// variables for storing debug info that can be displayed
cstr renderer_name;
float fps_display;
void
main_loop(void)
{
if(rodeo_gfx_frame_count_get() % 10 == 0)
{
fps_display = rodeo_gfx_frame_perSecond_get();
}
mrodeo_gfx_frame_do()
{
rodeo_input_poll();
if (get_player_hp() > 0 && get_menu_state() == menu_state_inactive)
{
// retrieve and apply player input
parse_player_input();
player_shoot(get_player_bullet_world());
enemies_attempt_weapon_fire();
// spawn enemies
attempt_random_enemy_spawn((rodeo_rectangle_t){ 0, 0, window_width, window_height });
}
else
{
parse_menu_input();
if (get_player_hp() <= 0)
{
set_menu_state(menu_state_gameover);
}
}
// run enemy movement ai
group_follow_target(
(rodeo_collision_2d_item_t){
.data_handle = get_player_position()->id.self_handle
}
);
detect_bullet_enemy_collisions();
detect_bullet_wall_collisions();
detect_player_enemy_collisions();
detect_player_wall_collisions();
detect_enemy_wall_collisions();
// apply movements
move_bullets();
move_enemies();
move_player();
draw_level();
if (get_menu_state() == menu_state_inactive || get_menu_state() == menu_state_gameover)
{
draw_bullets();
if (get_menu_state() != menu_state_gameover)
{
draw_player();
}
draw_enemies();
draw_hp_bar();
}
draw_menu();
}
//draw_debug_text(renderer_name, fps_display);
}
int
main(void)
{
inputs_register_do()
{
mrodeo_window_do(window_height, window_width, cstr_lit("Bubbles, Behind"))
{
mrodeo_gfx_do(1600, 900)
{
mrodeo_audio_do(8)
{
renderer_name = rodeo_gfx_renderer_name_get();
//rodeo_gfx_frame_limit_set(60);
game_systems_init_do()
{
// use to test manually spawning enemies
//spawn_enemy(400.0f,700.0f);
//spawn_enemy(900.0f,700.0f);
//spawn_enemy(400.0f,100.0f);
//spawn_enemy(900.0f,100.0f);
//for(int i = 0; i < 1500; ++i)
//{
// float rng1 = ((float)rodeo_random_double_get() * 100) + 150;
// float rng2 = ((float)rodeo_random_double_get() * 100) + 150;
// spawn_ghost(rng1,rng2);
//}
rodeo_mainLoop_run(
main_loop
);
}
}
}
}
}
return 0;
}
|