restart button on the game over is now wokring properly well
This commit is contained in:
@@ -1,13 +1,54 @@
|
|||||||
// src/game/game_over.cpp
|
// src/game/game_over.cpp
|
||||||
#include "game_over.h"
|
#include "game_over.h"
|
||||||
|
#include "mbed.h"
|
||||||
|
#include "../render/background.h"
|
||||||
|
#include "../assets/background_frame.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
void show_game_over_screen(int seconds) {
|
void show_game_over_screen(int seconds) {
|
||||||
printf("\033[2J\033[H");
|
printf("\033[2J\033[H");
|
||||||
|
|
||||||
|
// 34 znakov vo vypise
|
||||||
|
const int box_width = 34;
|
||||||
|
const int start_col = (VIEW_WIDTH - box_width) / 2;
|
||||||
|
|
||||||
|
const int box_height = 6;
|
||||||
|
const int top_padding = (VIEW_HEIGHT - box_height) / 2;
|
||||||
|
|
||||||
|
// Empty rows
|
||||||
|
for (int i = 0; i < top_padding; i++) {
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < start_col; i++) printf(" ");
|
||||||
printf("==================================\r\n");
|
printf("==================================\r\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < start_col; i++) printf(" ");
|
||||||
printf(" G A M E O V E R \r\n");
|
printf(" G A M E O V E R \r\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < start_col; i++) printf(" ");
|
||||||
printf("==================================\r\n");
|
printf("==================================\r\n");
|
||||||
printf(" Vydrzal si %d sekund. \r\n", seconds);
|
|
||||||
|
for (int i = 0; i < start_col; i++) printf(" ");
|
||||||
|
printf(" Doba hry %d sekund. \r\n", seconds);
|
||||||
|
|
||||||
|
for (int i = 0; i < start_col; i++) printf(" ");
|
||||||
printf("==================================\r\n");
|
printf("==================================\r\n");
|
||||||
|
printf(" Stlacte tlacidlo pre restart. \r\n");
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
DigitalIn restart_button(BUTTON1);
|
||||||
|
|
||||||
|
int initial_state = restart_button.read();
|
||||||
|
while (restart_button.read() == initial_state) {
|
||||||
|
ThisThread::sleep_for(50ms);
|
||||||
|
}
|
||||||
|
int new_state = restart_button.read();
|
||||||
|
while (restart_button.read() == new_state) {
|
||||||
|
ThisThread::sleep_for(50ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\033[2J\033[H");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,7 @@ int main(void) {
|
|||||||
serial_port.set_format(8, BufferedSerial::None, 1);
|
serial_port.set_format(8, BufferedSerial::None, 1);
|
||||||
printf("Baud: %d, Format: 8-N-1\r\n", BAUD_RATE);
|
printf("Baud: %d, Format: 8-N-1\r\n", BAUD_RATE);
|
||||||
|
|
||||||
render_loop(1);
|
while (true) {
|
||||||
|
render_loop(4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user