diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-04-30 08:43:05 +0200 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-04-30 08:43:05 +0200 |
| commit | 8e94318a960259c3ef2dad472705e6de0b3229df (patch) | |
| tree | c5964bf1087f310c0d62a9df747502b675b64772 /src/Model/Game.cpp | |
| parent | ad216d86f6573e3575e85f3a2941f6f34b5b1c0e (diff) | |
| parent | a3b805ee7b96d1d693c4108f0104650cfd60b565 (diff) | |
Merge branch 'MakeClass' of github.com:manzerbredes/2P11 into MakeClass
Diffstat (limited to 'src/Model/Game.cpp')
| -rw-r--r-- | src/Model/Game.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Model/Game.cpp b/src/Model/Game.cpp index e69de29..1e24b11 100644 --- a/src/Model/Game.cpp +++ b/src/Model/Game.cpp @@ -0,0 +1,54 @@ +#include "Game.hpp" + +Game::Game() +{ + m_grid = new Grid(4); +} + +Game::~Game() +{ + delete m_grid; +} + +void Game::play() +{ + while(!m_grid->gridIsFull()) + { + m_grid->show(); + + pop(); + std::cout << std::endl; + } + + m_grid->show(); +} + +void Game::showGrid() +{ + m_grid->show(); + std::cout << std::endl; +} + +void Game::pop() +{ + bool cellChosen = false; + + int i; + int j; + + while(!cellChosen) + { + i = rand() % 4; + j = rand() % 4; + + if (m_grid->isEmpty(i,j)) + cellChosen = true; + } + + m_grid->setCell(i, j, new Cell("2")); +} + +bool Game::isOver() +{ + return m_grid->gridIsFull(); +}
\ No newline at end of file |
