diff --git a/src/CTController/CTConsole.cpp b/src/CTController/CTConsole.cpp new file mode 100644 index 0000000..44b598e --- /dev/null +++ b/src/CTController/CTConsole.cpp @@ -0,0 +1,48 @@ +#include "CTConsole.hpp" + +CTConsole::CTConsole() +{ + m_game = new Game(); +} + +CTConsole::~CTConsole() +{ + delete m_game; +} + +void CTConsole::play() +{ + while (!m_game->isOver()) + { + m_game->showGrid(); + char moveChoice = ' '; + + std::cin >> moveChoice; + + switch (moveChoice) + { + case 'z': + std::cout << "up" << std::endl; + break; + + case 's': + std::cout << "down" << std::endl; + break; + + case 'q': + std::cout << "left" << std::endl; + break; + + case 'd': + std::cout << "right" << std::endl; + break; + + default: + break; + } + + std::cout << std::endl; + + m_game->pop(); + } +} \ No newline at end of file diff --git a/src/CTController/CTConsole.hpp b/src/CTController/CTConsole.hpp new file mode 100644 index 0000000..9534877 --- /dev/null +++ b/src/CTController/CTConsole.hpp @@ -0,0 +1,26 @@ +#ifndef DEF_CTCONSOLE +#define DEF_CTCONSOLE + +/* CTConsole.hpp + * Defines the class CTConsole + * CTConsole is a controller which displays a game in a terminal + * Creators : krilius, manzerbredes + * Date : 29/04/2915 */ + +#include + +#include "../Model/Game.hpp" + +class CTConsole +{ +private: + Game * m_game; + +public: + CTConsole(); + ~CTConsole(); + + void play(); +}; + +#endif \ No newline at end of file diff --git a/src/Model/ModelConstants.hpp b/src/Model/ModelConstants.hpp new file mode 100644 index 0000000..5cbc21b --- /dev/null +++ b/src/Model/ModelConstants.hpp @@ -0,0 +1,12 @@ +#ifndef DEF_MODELCONSTANTS +#define DEF_MODELCONSTANTS + +/* ModelConstants.hpp + * Constains constants and enums used in the whole model + * Creators : krilius, manzerbredes + * Date : 29/04/2015 */ + +enum Direction { UP, DOWN, LEFT, RIGHT }; +typedef enum Direction Direction; + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 12f6c6d..9006fcd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,18 @@ #include #include +#include -#include "Model/Grid.hpp" +#include "CTController/CTConsole.hpp" int main() { - Grid * grid = new Grid(4); - - grid->afficher(); - - return 0; + srand(time(NULL)); + + CTConsole * controller = new CTConsole(); + + controller->play(); + + delete controller; + + return 0; }