|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Game.h"
|
|
#include "Maze.h"
|
|
#include "Utilities.h"
|
|
#include<iostream>
|
|
using namespace std;
|
|
|
|
Game::Game()
|
|
{
|
|
level = 1;
|
|
life = 3;
|
|
point = 0;
|
|
loopGame = true;
|
|
addLife = 0;
|
|
}
|
|
|
|
void Game::setPoint(int x)
|
|
{
|
|
point += x;
|
|
}
|
|
void Game::print1()
|
|
{
|
|
|
|
|
|
cout << "Level: " << level << "\tGP:" << point << endl;
|
|
bool check = false;
|
|
if(point > 8888 && addLife==0 )
|
|
{
|
|
check = true;
|
|
while(check)
|
|
{
|
|
extraLife();
|
|
check = false;
|
|
addLife++;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void Game::print2()
|
|
{
|
|
cout << "Life left: " << life << " ";
|
|
|
|
switch(level){
|
|
case 1:
|
|
cout << "Fruit:Cherry " << endl;
|
|
break;
|
|
case 2:
|
|
cout << "Fruit:Strayberry " << endl;
|
|
break;
|
|
case 3:
|
|
cout << "Fruit:Orange " << endl;
|
|
break;
|
|
}
|
|
}
|
|
|
|
int Game::getPoint()
|
|
{
|
|
return point;
|
|
}
|
|
|
|
void Game::Move(Maze m,Utilities u)
|
|
{
|
|
u.gotoXY(0,18);
|
|
u.changeColour(FOREGROUND_WHITE);
|
|
Game::print1();
|
|
Game::print2();
|
|
u.gotoXY(0,20);
|
|
cout << " ";
|
|
u.gotoXY(0,20);
|
|
cout << "Remain Dot: "<< m.getTotalDot() << endl;
|
|
cout << "Press p to pause";
|
|
u.changeColour(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
|
}
|
|
|
|
int Game::GetLife(){
|
|
return life;
|
|
}
|
|
|
|
void Game::setLife()
|
|
{
|
|
life = 3;
|
|
}
|
|
|
|
void Game::extraLife()
|
|
{
|
|
life++;
|
|
}
|
|
|
|
bool Game::getLoopGameBool()
|
|
{
|
|
return loopGame;
|
|
}
|
|
|
|
void Game::setLoopGameBool(bool temp)
|
|
{
|
|
loopGame = temp;
|
|
}
|
|
|
|
void Game::checkForUpLevel(Maze &m)
|
|
{
|
|
if (m.getTotalDot()==0)
|
|
{
|
|
setGameLevel();
|
|
setLoopGameBool(false);
|
|
}
|
|
}
|
|
|
|
|
|
void Game::setGameLevel()
|
|
{
|
|
level++;
|
|
}
|
|
|
|
int Game::getGameLevel()
|
|
{
|
|
return level;
|
|
}
|
|
|
|
void Game:: setReplayBool(bool temp)
|
|
{
|
|
replay = temp;
|
|
}
|
|
|
|
bool Game::getReplayBool()
|
|
{
|
|
return replay;
|
|
}
|
|
|
|
void Game::gameReset()
|
|
{
|
|
level = 1;
|
|
life = 3;
|
|
point = 0;
|
|
loopGame = true;
|
|
}
|
|
|