added result screens
fixed bug about picking up two boosts crashing the game
This commit is contained in:
105
src/result.cc
105
src/result.cc
@ -1,5 +1,6 @@
|
||||
#include "result.h"
|
||||
|
||||
#include "constants.h"
|
||||
|
||||
const char *WIN_SCREEN =
|
||||
"+-----------------------------------------------------------------------------+\
|
||||
@ -23,23 +24,113 @@ const char *WIN_SCREEN =
|
||||
| |\
|
||||
| |\
|
||||
| |\
|
||||
| Winner! |\
|
||||
| |\
|
||||
| |\
|
||||
| |\
|
||||
| > |\
|
||||
| |\
|
||||
| > |\
|
||||
| |\
|
||||
| |\
|
||||
| Press 'r' to restart and any other key to quit. |\
|
||||
| |\
|
||||
+-----------------------------------------------------------------------------+";
|
||||
|
||||
const position &MSG_START = {11, 24};
|
||||
const char *ESC_SCREEN =
|
||||
"+-----------------------------------------------------------------------------+\
|
||||
| |\
|
||||
| |\
|
||||
| |\
|
||||
| __ |\
|
||||
| _/o \\ |\
|
||||
| /_ | | / |\
|
||||
| W\\ / |//// |\
|
||||
| \\ \\ __________||//|/ |\
|
||||
| \\ \\/ /|/-//- |\
|
||||
| | ----- // -- |\
|
||||
| | ----- /- |\
|
||||
| | ----- / |\
|
||||
| \\ / |\
|
||||
| \\_/ \\___/ |\
|
||||
| \\ // |\
|
||||
| ||| |\
|
||||
| ||| |\
|
||||
| Z_>> |\
|
||||
| |\
|
||||
| |\
|
||||
| |\
|
||||
| Chicken! |\
|
||||
| |\
|
||||
| > |\
|
||||
| |\
|
||||
| |\
|
||||
| Press 'r' to restart and any other key to quit. |\
|
||||
| |\
|
||||
+-----------------------------------------------------------------------------+";
|
||||
|
||||
|
||||
const char *LOSE_SCREEN =
|
||||
"+-----------------------------------------------------------------------------+\
|
||||
| |\
|
||||
| _ /) |\
|
||||
| / )/ ) |\
|
||||
| |/)\\) |\
|
||||
| /\\_ |\
|
||||
| \\__|= |\
|
||||
| ( ) |\
|
||||
| __)(__ |\
|
||||
| _____/ \\\\_____ |\
|
||||
| | || |\
|
||||
| | _ ___ _ || |\
|
||||
| | | \\ | | \\ || |\
|
||||
| | | | | | | || |\
|
||||
| | |_/ | |_/ || |\
|
||||
| | | \\ | | || |\
|
||||
| | | \\ | | || |\
|
||||
| | | \\. _|_. | . || |\
|
||||
| | || |\
|
||||
| * | * ** * ** |** ** |\
|
||||
| \\))...../.,(//,,..,,\\||(,,.,\\\\,.((// |\
|
||||
| |\
|
||||
| Loser! |\
|
||||
| |\
|
||||
| > |\
|
||||
| |\
|
||||
| |\
|
||||
| Press 'r' to restart and any other key to quit. |\
|
||||
| |\
|
||||
+-----------------------------------------------------------------------------+";
|
||||
|
||||
const position &MSG_START = {4, 24};
|
||||
const int MAX_MSG_LEN = 71;
|
||||
const std::string DOTS = "...";
|
||||
|
||||
void game_result::run(input *in) {
|
||||
in->get_command();
|
||||
if (in->get_command() == game_restart)
|
||||
status = restart;
|
||||
}
|
||||
|
||||
void game_result::print(output *out) {
|
||||
out->print_str({0, 0}, WIN_SCREEN);
|
||||
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_YELLOW));
|
||||
if (msg.length() > MAX_MSG_LEN) {
|
||||
msg.resize(MAX_MSG_LEN - DOTS.length());
|
||||
msg += DOTS;
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case won:
|
||||
out->print_str({0, 0}, WIN_SCREEN);
|
||||
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_YELLOW));
|
||||
break;
|
||||
|
||||
case escaped:
|
||||
out->print_str({0, 0}, ESC_SCREEN);
|
||||
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_GREEN));
|
||||
break;
|
||||
|
||||
case dead:
|
||||
out->print_str({0, 0}, LOSE_SCREEN);
|
||||
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_RED));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user