aboutsummaryrefslogtreecommitdiff
path: root/1bitjam.c
blob: 619876ed9dbf881e4624e9ec2326b126e6439fd6 (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
51
#include "asset.h"
#include "config.h"
#include "map.h"
#include "maths.h"
#include "memory.h"
#include "obj.h"
#include "plat.h"
#include "rect.h"
#include "render.h"

int entrypoint(int argc, const char** argv, Arena* m) {
	Heap h;
	App* a;
	FPS f;
	Renderer r;
	Player player;
	Map map;
	(void)argc;
	(void)argv;
	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);
	generate_floor(&map, 0);
	init_player(&player);
	while (a->o) {
		fps_begin(&f);
		while (f.now >= f.next && a->o) {
			app_begin(a);

			update_player(&player, a, &map);

			ren_begin(&r, a->fb, viewport_w, viewport_h);
			ren_clear(&r);
			render_map(&map, &r);
			ren_player(&player, &r);
			ren_end(&r);
			app_end(a);
			fps_update(&f);
		}
		fps_end(&f);
	}
	deinit_audio();
	deinit_app(a);
	return error_none;
}