game over
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "mbed.h"
|
||||
#include "player.h"
|
||||
#include "background.h"
|
||||
#include "../game/game_over.h"
|
||||
#include "../game/game_state.h"
|
||||
#include "../game/state.h"
|
||||
#include "../game/animation.h"
|
||||
@@ -46,6 +47,8 @@ void logic_loop(void *arg) {
|
||||
int anim_tick_counter = 0;
|
||||
int tick_counter = 0;
|
||||
bool game_over = false;
|
||||
Timer game_timer;
|
||||
game_timer.start();
|
||||
|
||||
// Spawn first obstacle
|
||||
if (speed >= 5)
|
||||
@@ -138,8 +141,11 @@ void logic_loop(void *arg) {
|
||||
ThisThread::sleep_for(25ms);
|
||||
}
|
||||
|
||||
// final update
|
||||
game_timer.stop();
|
||||
int seconds = static_cast<int>(game_timer.elapsed_time().count() / 1000000);
|
||||
|
||||
g_state_mutex.lock();
|
||||
g_state.elapsed_seconds = seconds;
|
||||
g_state.game_over = true;
|
||||
g_state_mutex.unlock();
|
||||
}
|
||||
@@ -154,8 +160,7 @@ void render_loop_thread() {
|
||||
g_state_mutex.unlock();
|
||||
|
||||
if (over) {
|
||||
printf("\033[2J\033[H");
|
||||
printf("GAME OVER\r\n");
|
||||
show_game_over_screen(local.elapsed_seconds);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user