Skip to content

Commit

Permalink
Iss 22 (#29)
Browse files Browse the repository at this point in the history
* Added Start and End Screen to RoadRun

The user is presented with a start and end screen for a short time
before and after the game starts, displaying the difficulty level and
end of game score.

* Added Titles to Menu Screen

Now we can see what menu we are on. Main menu or choosing a difficulty
for options.

* Added Instruction to Quit Game

The user now sees a message that instructs them to press q if they wish
to quit. This is on the info_win window part of the game screen.

* Update play intructions
  • Loading branch information
evanugarte authored and drofp committed May 14, 2019
1 parent 332e9be commit 9ad2fa4
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 11 deletions.
5 changes: 5 additions & 0 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define GAME_H_

#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <unordered_map>
Expand Down Expand Up @@ -30,6 +31,7 @@ class Game
private:
WINDOW *game_win;
WINDOW *info_win;
WINDOW *art_win;
char game_map[(kMenuHeight * (kMenuWidth + 1)) + 1];
SettingsItem curr_difficulty;
MapGenerator *map_generator;
Expand All @@ -48,6 +50,9 @@ class Game
void PrintGameFrame(WINDOW *game_win);
void PrintInfoFrame(WINDOW *info_win);

void PrintPrepScreen();
void PrintEndScreen();

void UpdatePlayerLoc();
void UpdatePlayerDeltas();
void CheckCollision();
Expand Down
69 changes: 68 additions & 1 deletion src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Game::Game(int width, int height, char player_icon, SettingsItem difficulty,

game_win = newwin(kMenuHeight, kMenuWidth, starty, startx);
info_win = newwin(kInfoHeight, kInfoWidth, starty, kMenuWidth);
art_win = newwin(300, 300, starty, startx);

nodelay(game_win, true);
keypad(game_win, true);
Expand All @@ -42,7 +43,7 @@ Game::Game(int width, int height, char player_icon, SettingsItem difficulty,
void Game::PlayGame()
{
this->map_generator = MapGeneratorFactory::create(curr_difficulty);

PrintPrepScreen();
while (playing)
{
key = wgetch(game_win);
Expand All @@ -59,6 +60,11 @@ void Game::PlayGame()

wrefresh(game_win);
wrefresh(info_win);
wclear(game_win);
wclear(info_win);
wrefresh(game_win);
wrefresh(info_win);
PrintEndScreen();
endwin();
}

Expand All @@ -82,10 +88,71 @@ void Game::PrintInfoFrame(WINDOW *info_win)
mvwprintw(info_win, 0, 0, "player loc x is %d", player_locx);
mvwprintw(info_win, 1, 0, "High score: %d", curr_high_score);
mvwprintw(info_win, 2, 0, "Score: %d", curr_score);
mvwprintw(info_win, 3, 0, "Press 'q' at any time to quit");

wrefresh(info_win);
}

void Game::PrintPrepScreen()
{
char* mode;
const char* kStartArt = R"ronmak(
/ __ \___ ____ _____/ __ __ / /_____ / __ \____ ____ _____/ _______ ______ / /
/ /_/ / _ \/ __ `/ __ / / / / / __/ __ \ / /_/ / __ \/ __ `/ __ / ___/ / / / __ \/ /
/ _, _/ __/ /_/ / /_/ / /_/ / / /_/ /_/ / / _, _/ /_/ / /_/ / /_/ / / / /_/ / / / /_/
/_/ |_|\___/\__,_/\__,_/\__, / \__/\____/ /_/ |_|\____/\__,_/\__,_/_/ \__,_/_/ /_(_)
/____/
)ronmak";
if(curr_difficulty == SettingsItem::kRegular)
{

mode = R"ronmak(
______ __ ___ __
/ ________ ________ __ / |/ ____ ____/ ___
/ __/ / __ `/ ___/ / / / / /|_/ / __ \/ __ / _ \
/ /___/ /_/ (__ / /_/ / / / / / /_/ / /_/ / __/
/_____/\__,_/____/\__, / /_/ /_/\____/\__,_/\___/
/____/
)ronmak";
}
else
{
mode = R"ronmak(
__ __ __ __ ___ __
/ / / ____ __________/ / / |/ ____ ____/ ___
/ /_/ / __ `/ ___/ __ / / /|_/ / __ \/ __ / _ \
/ __ / /_/ / / / /_/ / / / / / /_/ / /_/ / __/
/_/ /_/\__,_/_/ \__,_/ /_/ /_/\____/\__,_/\___/
)ronmak";
}

mvwprintw(art_win, 0, 0, "%s", kStartArt);
mvwprintw(art_win, 10, 0, "%s", mode);
wrefresh(art_win);
napms(2000);
wmove(art_win, 0, 0);
wclrtobot(art_win);
wrefresh(art_win);
}

void Game::PrintEndScreen()
{

const char* kEndArt = R"ronmak(
______ ____ __
/ ________ _____ ___ ___ / __ \_ _____ _____/ /
/ / __/ __ `/ __ `__ \/ _ \ / / / | | / / _ \/ ___/ /
/ /_/ / /_/ / / / / / / __/ / /_/ /| |/ / __/ / /_/
\____/\__,_/_/ /_/ /_/\___/ \____/ |___/\___/_/ (_)
)ronmak";
mvwprintw(art_win, 0, 0, "%s", kEndArt);
mvwprintw(art_win, 10, 0, "Your score was %d", curr_score);
wrefresh(art_win);
napms(2000);
wclrtobot(art_win);
wrefresh(art_win);
}

void Game::UpdatePlayerLoc()
{
UpdatePlayerDeltas();
Expand Down
27 changes: 19 additions & 8 deletions src/main_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace roadrun
{
void MainMenu::RenderOptions(WINDOW *menu_win, int highlight)
{

mvwprintw(menu_win, 2, 4, "Main Menu");
char *choices[] = {
"Play Game",
"Options",
"Exit",
};
int x, y, i;
x = y = 2;
x = y = 4;
box(menu_win, 0,0);
for(i = 0; i < num_menu_items; i++) {
if(highlight == i + 1)
Expand All @@ -28,7 +28,7 @@ namespace roadrun
}
++y;
}
wrefresh(menu_win);
wrefresh(menu_win);
}

void MainMenu::PrintMenu()
Expand All @@ -53,18 +53,29 @@ namespace roadrun
int starty = 5; //(80 - kHeight) / 2;

menu_win = newwin(kMenuHeight, kMenuWidth, starty, startx);
info_win = newwin(kInfoHeight, kInfoWidth, starty, kMenuWidth+7);
info_win = newwin(kInfoHeight, kMenuWidth, starty, kMenuWidth+7);

keypad(menu_win, TRUE);
mvprintw(0, 0, "Use ^ and v.");
mvprintw(0, 0, "Use up and down arrows to choose, enter to select.");
mvprintw(1, 0, "==================================================");
mvprintw(2, 0, "To play: Press left and right arrow keys to move.");
mvprintw(3, 0, " Dodge the obstacles as long as you can!");
mvprintw(4, 0, "Your Character: ^");
mvwprintw(info_win, 0, 0, R"ronmak(
____ ______
/ __ \____ ____ _____/ / __ \__ ______
/ /_/ / __ \/ __ `/ __ / /_/ / / / / __ \
/ _, _/ /_/ / /_/ / /_/ / _, _/ /_/ / / / /
/_/ |_|\____/\__,_/\__,_/_/ |_|\__,_/_/ /_/
)ronmak");
refresh();
RenderOptions(menu_win, highlight);

mvwprintw(info_win, 0, 0, "Easy High Score: %d",
mvwprintw(info_win, 7, 0, "Easy High Score: %d",
difficulty_map->operator[](SettingsItem::kRegular));
mvwprintw(info_win, 1, 0, "Hard High Score: %d",
mvwprintw(info_win, 8, 0, "Hard High Score: %d",
difficulty_map->operator[](SettingsItem::kLudicrous));
mvwprintw(info_win, 2, 0, "Previous Score: %d", *prev_score);
mvwprintw(info_win, 9, 0, "Previous Score: %d", *prev_score);
wrefresh(info_win);

int enter_pressed = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/settings_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ namespace roadrun
void SettingsMenu::RenderOptions(WINDOW *menu_win, int highlight)
{

mvwprintw(menu_win, 2, 4, "Choose a Difficulty");
char *choices[] = {
"Regular Mode",
"Ludicrous Mode",
"Ron Mak",
};
int x, y, i;
x = y = 2;
x = y = 4;
box(menu_win, 0,0);
for(i = 0; i < num_settings_items; i++) {
if(highlight == i + 1)
Expand Down Expand Up @@ -48,7 +49,7 @@ namespace roadrun
int starty = 5;//(80 - kHeight) / 2;
menu_win = newwin(kHeight, kWidth, starty, startx);
keypad(menu_win, TRUE);
mvprintw(0, 0, "Use ^ and v.");
mvprintw(0, 0, "Use up and down arrows to choose, enter to select.");
refresh();
RenderOptions(menu_win, highlight);
int enter_pressed = 0;
Expand Down

0 comments on commit 9ad2fa4

Please sign in to comment.