Add score
This commit is contained in:
9
game.c
9
game.c
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user