Skip to content

Commit

Permalink
Reset Key Added
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianosaure committed Jan 3, 2017
1 parent 14d62a4 commit ad9790f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ using namespace std;

void Game (const string & FileName)
{
set_input_mode ();
CMatrix map (LoadMap (FileName));
if (!CheckMapLoaded (map))
{
Expand Down Expand Up @@ -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 ();
Expand Down
2 changes: 1 addition & 1 deletion src/gameplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdlib.h>
#include <termios.h>


/* Use this variable to remember original terminal attributes. */

struct termios saved_attributes;
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#include <string>
#include <vector>
#include <game.h>
#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;
Expand Down

0 comments on commit ad9790f

Please sign in to comment.