From: tf2spi Date: Mon, 13 Oct 2025 19:39:32 +0000 (-0400) Subject: Final update to Miss(le) Hell before v0.1.1 X-Git-Url: http://git.misomosispi.com/?a=commitdiff_plain;h=78a81c0f988b7705b0772423545f54b39ed7e0ae;p=miss-le-hell.git Final update to Miss(le) Hell before v0.1.1 We introduce handle tables, arenas, and fonts into the engine and use/test them for the game. Bleh... What a mess. --- diff --git a/game/game_callbacks.c b/game/game_callbacks.c index a78d0ea..7a20a79 100644 --- a/game/game_callbacks.c +++ b/game/game_callbacks.c @@ -4,6 +4,7 @@ #include "afx.h" #include "input.h" #include "sprite.h" +#include // Exported for sprite.c union gfx_sampler g_sampler; @@ -23,7 +24,9 @@ static union gfx_font g_font; static float timeprev; static float timedelta; +static int bullets_exploded = 0; static float reset_tick = 0.0f; +static float death_tick = 0.0f; #define FLAG_LEFT 1 #define FLAG_RIGHT 2 @@ -209,8 +212,10 @@ static void update_projectiles(struct projectiles *projectiles) continue; struct vector2f32 delta = v2f32sub(enemy->pos, p->pos); // TODO: Yes, I also know this isn't exact. I'll fix that... Maybe. - if (v2f32mag2(delta) < (EXPLOSION_RADIUS * EXPLOSION_RADIUS)) + if (v2f32mag2(delta) < (EXPLOSION_RADIUS * EXPLOSION_RADIUS)) { + bullets_exploded++; remove_projectile(&g_enemy, i); + } } } break; @@ -223,6 +228,7 @@ static void update_projectiles(struct projectiles *projectiles) } else if (g_ship.destroyed <= EPSILON) { struct vector2f32 delta = v2f32sub(p->pellet.pos, g_ship.pos); if (v2f32mag2(delta) < SHIP_RADIUS * SHIP_RADIUS) { + death_tick = timeprev; g_ship.destroyed = EPSILON * 2.0f; add_explosion(&g_friendly, p->pellet.pos); remove_projectile(projectiles, i); @@ -348,6 +354,8 @@ static void reset_game() g_flags = 0; g_pellet_spawn_time = PELLET_SPAWN_BASE; reset_tick = os_timef(OS_TIME_TICK); + death_tick = 0.0f; + bullets_exploded = 0; } static void on_key(uint32_t keyboard, uint32_t key, bool down) { @@ -537,6 +545,9 @@ void game_callback_render(void) // Now bind the pipeline for fonts and render gfx_pipeline_bind(g_font_pipeline); - text_draw(g_font, STRLIT("Hello World!\nHow are you?"), (struct vector2f32){64.0f,64.0f}); + char prompt[128]; + float time_alive = (death_tick ? death_tick : timeprev) - reset_tick; + snprintf(prompt, sizeof(prompt), "Seconds Alive: %d\nBullets Exploded: %d\n", (int)time_alive, bullets_exploded); + text_draw(g_font, CSTR2STRC(prompt), (struct vector2f32){4.0f-CAM_DIM_X/2,-4.0f+CAM_DIM_Y/2}); sprite_flush(); } diff --git a/game/sprite.c b/game/sprite.c index 0721b49..6e7b512 100644 --- a/game/sprite.c +++ b/game/sprite.c @@ -96,6 +96,7 @@ void text_draw(union gfx_font f, struct stringc text, struct vector2f32 loc) float pxscale = info.fontsize / (info.ascent - info.descent); float line_height = pxscale * (info.ascent - info.descent + info.linegap); float xbase = loc.x; + loc.y -= line_height; for (size_t i = 0; i < text.len; i++) { if (text.data[i] == '\n') { loc.y -= line_height;