From ad9790f94590554456348da9bae471b144316030 Mon Sep 17 00:00:00 2001 From: Dorian Date: Tue, 3 Jan 2017 23:50:42 +0100 Subject: [PATCH] Reset Key Added --- src/game.cpp | 7 +++++-- src/gameplay.h | 2 +- src/input.cpp | 1 + src/main.cpp | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index ce88165..718b7a5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6,7 +6,6 @@ using namespace std; void Game (const string & FileName) { - set_input_mode (); CMatrix map (LoadMap (FileName)); if (!CheckMapLoaded (map)) { @@ -35,10 +34,14 @@ void Game (const string & FileName) ClearScreen (); ShowMatrix (map); read (STDIN_FILENO, &key, 1); + if (KKeyReset == key) + { + Game (FileName); + return; + } Action (map, obj, key); ++nbmoves; } - reset_input_mode (); ClearScreen (); cout << "Victory ! You won in " << nbmoves << " moves !" << endl; getchar (); diff --git a/src/gameplay.h b/src/gameplay.h index c6778b1..7e53670 100644 --- a/src/gameplay.h +++ b/src/gameplay.h @@ -14,7 +14,7 @@ const char KP2MoveUp = 'o'; const char KP2MoveDown = 'l'; const char KP2MoveLeft = 'k'; const char KP2MoveRight = 'm'; -const char KMenu = 'y'; +const char KKeyReset = 'v'; //Gamemodes const int KGMNone (0); diff --git a/src/input.cpp b/src/input.cpp index 34e5e31..cf76fc2 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -3,6 +3,7 @@ #include #include + /* Use this variable to remember original terminal attributes. */ struct termios saved_attributes; diff --git a/src/main.cpp b/src/main.cpp index 715f1c9..d860083 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,11 +2,13 @@ #include #include #include +#include "input.h" using namespace std; int main (int argc, char *argv[]) { + set_input_mode (); if (argc < 2) { cout << "Argument(s) missing : At least one map file name required" << endl;