first version of the controller

This commit is contained in:
krilius 2015-04-30 08:48:29 +04:00
parent a3b805ee7b
commit 71ebf1235e
4 changed files with 97 additions and 6 deletions

View file

@ -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();
}
}

View file

@ -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 <iostream>
#include "../Model/Game.hpp"
class CTConsole
{
private:
Game * m_game;
public:
CTConsole();
~CTConsole();
void play();
};
#endif

View file

@ -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

View file

@ -1,13 +1,18 @@
#include <iostream>
#include <string>
#include <time.h>
#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;
}