Add score

This commit is contained in:
2025-10-18 17:43:22 +01:00
parent 4da5437715
commit 07616120d3
3 changed files with 151 additions and 23 deletions

9
game.c
View File

@@ -125,6 +125,7 @@ static unsigned level;
static bool dead;
static unsigned asteroid_count;
static uint8_t counter;
static unsigned score;
static unsigned ship_entity_id;
static unsigned ship_shape_id;
@@ -355,6 +356,7 @@ static void destroy_asteroid(entity_t *a, vec2_t shot_vel)
{
a->dead = true;
--asteroid_count;
++score;
float r;
if (a->radius == ASTEROID_HUGE) {
@@ -491,6 +493,7 @@ static void win()
static void reset()
{
level = INIT_LEVEL;
score = 0;
create_field();
}
@@ -555,12 +558,14 @@ void game_draw()
shapes[i].connect);
}
text_draw_score(aspect, score);
if (dead && !(counter & COUNTER_MASK))
text_draw("GAME OVER");
text_draw_centre("GAME OVER");
if (!dead && asteroid_count == 0) {
draw_arrow();
if (!(counter & COUNTER_MASK))
text_draw("CLEAR");
text_draw_centre("CLEAR");
}
}