summaryrefslogtreecommitdiff
path: root/src/Controllers/ConsoleController/ConsoleController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Controllers/ConsoleController/ConsoleController.cpp')
-rw-r--r--src/Controllers/ConsoleController/ConsoleController.cpp53
1 files changed, 18 insertions, 35 deletions
diff --git a/src/Controllers/ConsoleController/ConsoleController.cpp b/src/Controllers/ConsoleController/ConsoleController.cpp
index bca3ad8..d91e807 100644
--- a/src/Controllers/ConsoleController/ConsoleController.cpp
+++ b/src/Controllers/ConsoleController/ConsoleController.cpp
@@ -4,62 +4,45 @@
ConsoleController::ConsoleController()
{
- m_game = new Game();
}
ConsoleController::~ConsoleController()
{
- delete m_game;
}
-void ConsoleController::play()
+void ConsoleController::run()
{
- //Intruction msg
- std::cout << "Use arrows to play !" << std::endl;
//Init keyPress
kbdh::Direction keyPress;
- //Display the first grid
- m_game->showGrid();
+ //Intruction msg
+ std::cout << "Use arrows to play !" << std::endl;
+
+ //Pop a random number on the grid
+ m_game.popRandomNumber();
+
+ //First cout grid
+ m_game.coutGrid();
+
//Start game
- while (1)
+ while (!m_game.isOver())
{
- std::cout << "Game over : " << m_game->isOver() << "fin";
//Get key press
keyPress=this->waitArrowKeyPress();
- //New line for the console print arrow press
- std::cout << std::endl;
-
-
- //Print keyPress
- switch(keyPress){
- case kbdh::Up:
- std::cout << "Keypress : Up" << std::endl;
- break;
- case kbdh::Down:
- std::cout << "Keypress : Down" << std::endl;
- break;
- case kbdh::Left:
- std::cout << "Keypress : Left" << std::endl;
- break;
- case kbdh::Right:
- std::cout << "Keypress : Right" << std::endl;
- m_game->swipeRight();
- break;
- }
-
- //Show the Grid
- m_game->showGrid();
- std::cout << std::endl;
+ //Apply move
+ m_game.swipe(keyPress);
+ //Pop a random number on the grid
+ m_game.popRandomNumber();
- //Pop new number
- m_game->pop();
+ //Cout grid
+ m_game.coutGrid();
}
+ m_game.coutGrid();
}