aboutsummaryrefslogtreecommitdiff
path: root/1bitjam.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-09-23 21:11:29 +1000
committerquou <quou@disroot.org>2024-09-23 21:11:29 +1000
commit259237fae792e8f19d9b7920b2354f75bc1789e2 (patch)
treeaf079430f30f7df1b76efc4f96f520b0b6eee0af /1bitjam.c
initial commit, basic platform and rendering code.
Diffstat (limited to '1bitjam.c')
-rw-r--r--1bitjam.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/1bitjam.c b/1bitjam.c
new file mode 100644
index 0000000..d573fe1
--- /dev/null
+++ b/1bitjam.c
@@ -0,0 +1,50 @@
+#include "asset.h"
+#include "config.h"
+#include "memory.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;
+ Rect rect = { 0, 0, 32, 32 };
+ Rect rect2 = { 0, 0, 8, 8 };
+ int x = 0, y = 0;
+ (void)argc;
+ (void)argv;
+ init_heap(
+ &h,
+ arena_alloc(m, app_memory_size),
+ app_memory_size
+ );
+ a = new_app(&h, "1 bit jam");
+ init_fps(&f, default_mpf);
+ while (a->o) {
+ fps_begin(&f);
+ while (f.now >= f.next && a->o) {
+ app_begin(a);
+ ren_begin(&r, a->fb, viewport_w, viewport_h);
+ ren_clear(&r);
+ if (a->btn_states[btn_left] & btn_state_pressed)
+ x--;
+ if (a->btn_states[btn_right] & btn_state_pressed)
+ x++;
+ if (a->btn_states[btn_up] & btn_state_pressed)
+ y--;
+ if (a->btn_states[btn_down] & btn_state_pressed)
+ y++;
+ ren_text(&r, 30, 60, "Hello");
+ ren_map(&r, 10, 5, &rect, get_bitmap(asset_id_hello_img));
+ ren_map(&r, x, y, &rect2, get_bitmap(asset_id_guy_img));
+ ren_end(&r);
+ app_end(a);
+ fps_update(&f);
+ }
+ fps_end(&f);
+ }
+ deinit_app(a);
+ return error_none;
+}