blob: b52fcd6e9e306bca52de024df306b7bfe02ce1ca (
plain) (
blame)
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
|
#include "asset.h"
#include "config.h"
#include "game.h"
#include "maths.h"
#include "memory.h"
#include "plat.h"
#include "render.h"
static Heap h;
static App* a;
static FPS f;
static Renderer r;
static Game* game;
int prog_init(Arena* m) {
init_maths();
init_heap(
&h,
arena_alloc(m, app_memory_size),
app_memory_size
);
a = new_app(&h, game_name);
init_audio();
init_fps(&f, default_mpf);
game = arena_alloc(m, sizeof *game);
init_game(game, game_state_menu);
return 0;
}
int prog_update(void) {
fps_begin(&f);
while (f.now >= f.next && a->o) {
app_begin(a);
update_game(game, a);
ren_begin(&r, a->fb, viewport_w, viewport_h);
ren_clear(&r);
ren_game(game, &r);
ren_end(&r);
app_end(a);
fps_update(&f);
}
fps_end(&f);
return a->o;
}
void prog_deinit(void) {
deinit_audio();
deinit_app(a);
}
|