jf8441's picture
Upload 25 files
0ef7a64 verified
raw
history blame
1.37 kB
/*
Name:Wong Pui Shan
Sdutent ID:52611804
program: AScISD
Name: HAR Chiu Kwong Samson
Sdutent ID:52629360
program: AScISD
Name: LAM Cheuk Man
Sdutent ID:52621140
program: AScISD
Name:KO Jeffrey KO
Sdutent ID:525 695 30
program: AScISD
*/
#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){
//Set the fruit randomly on the map when pacman eat 70 dots
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(){
}