#include "afx.h"
#include "input.h"
#include "sprite.h"
+#include <stdio.h>
// Exported for sprite.c
union gfx_sampler g_sampler;
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
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;
} 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);
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)
{
// 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();
}