From be5c7263406aef867501c7965bcced6a7e2898a6 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 29 Sep 2024 16:39:31 +1000 Subject: animation, player movement, physics etc. --- 1bitjam.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to '1bitjam.c') diff --git a/1bitjam.c b/1bitjam.c index c2a84e1..619876e 100644 --- a/1bitjam.c +++ b/1bitjam.c @@ -1,7 +1,9 @@ #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" @@ -11,9 +13,8 @@ int entrypoint(int argc, const char** argv, Arena* m) { App* a; FPS f; Renderer r; - Rect rect = { 0, 0, 32, 32 }; - Rect rect2 = { 0, 0, 8, 8 }; - int x = 0, y = 0; + Player player; + Map map; (void)argc; (void)argv; init_maths(); @@ -25,25 +26,19 @@ int entrypoint(int argc, const char** argv, Arena* m) { 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); - 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++; - if (a->btn_states[btn_shoot] & btn_state_just_pressed) - play_sound(30); - 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)); + render_map(&map, &r); + ren_player(&player, &r); ren_end(&r); app_end(a); fps_update(&f); -- cgit v1.2.3-54-g00ecf