|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
using namespace std;
|
|
#include <fstream>
|
|
#include <string>
|
|
#include "Utilities.h"
|
|
#include "Game.h"
|
|
#include "Ghost.h"
|
|
#include "Maze.h"
|
|
#include "Pacman.h"
|
|
#include "Fruit.h"
|
|
|
|
|
|
Fruit::Fruit(){
|
|
fx = 1;
|
|
fy = 1;
|
|
charF = '!';
|
|
number = 1;
|
|
levelFruit = 1;
|
|
|
|
}
|
|
Fruit::Fruit(char fruit){
|
|
charF = fruit;
|
|
fx = 1;
|
|
fy = 1;
|
|
number = 1;
|
|
levelFruit = 1;
|
|
}
|
|
|
|
void Fruit::showFruit(Game &game, int &dot, Maze &m, Utilities &f){
|
|
|
|
levelFruit = game.getGameLevel();
|
|
if(dot == 70)
|
|
{
|
|
do{
|
|
fx = rand() % 21 ;
|
|
fy = rand() % 18 ;
|
|
dot = 0;
|
|
}while(m.getMazeArray(fx, fy)=='-' || m.getMazeArray(fx, fy)=='|' || m.getMazeArray(fx, fy)=='.' || m.getMazeArray(fx, fy)=='X');
|
|
f.gotoXY(fx,fy);
|
|
f.changeColour(FOREGROUND_GREEN | FOREGROUND_BLUE);
|
|
switch(levelFruit){
|
|
case 1:
|
|
charF = '!';
|
|
|
|
break;
|
|
case 2:
|
|
charF = '*';
|
|
|
|
break;
|
|
case 3:
|
|
charF = '#';
|
|
|
|
break;
|
|
}
|
|
cout << charF;
|
|
m.setMazeArray(fx,fy,charF);
|
|
|
|
}
|
|
}
|
|
|
|
Fruit::~Fruit(){
|
|
} |