blob: 851b1792fbf3f8f1b7111a35aa196e682d428f46 (
plain)
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
|
#include "app.h"
#include "physics.h"
#include "res.h"
#include "ent.h"
#include "game.h"
#include "env.h"
#include "cam.h"
#include "editor.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
App app = {0};
static void
app_init(void) {
SetTraceLogLevel(LOG_WARNING);
SetConfigFlags(FLAG_MSAA_4X_HINT |
FLAG_VSYNC_HINT |
FLAG_WINDOW_RESIZABLE);
InitWindow(1280, 720, "Fun Game");
SetExitKey(KEY_NULL);
SetTargetFPS(60);
app.run = true;
FLAG_SET(app.flags, BIT(APP_FLAG_EDIT));
FLAG_SET(app.flags, BIT(APP_FLAG_DEBUG));
physics_init();
res_init();
env_init();
entity_system_init();
game_init();
editor_init();
cam_init();
}
static void
app_exit(void) {
editor_exit();
game_exit();
entity_system_exit();
env_exit();
res_exit();
physics_exit();
}
static void
app_loop(void) {
app.run = !WindowShouldClose();
entity_system_update();
/* this is some hypothetical bullshit, probably will change */
if (app.mode == APP_MODE_EDIT) {
editor_update();
}
physics_update();
res_update();
env_update();
BeginDrawing();
ClearBackground(RAYWHITE);
env_draw_sky(main_cam.cam);
BeginMode3D(main_cam.cam);
entity_system_draw_3d();
EndMode3D();
if (FLAG_CHECK(app.flags, BIT(APP_FLAG_DEBUG)) ||
FLAG_CHECK(app.flags, BIT(APP_FLAG_EDIT))) {
BeginMode3D(main_cam.cam);
rlDisableDepthTest();
editor_draw_3d();
EndMode3D();
}
editor_draw_ui();
EndDrawing();
}
int
main(void) {
app_init();
while (app.run) {
app_loop();
}
app_exit();
return 0;
}
|