I am writing a game program kind of like pac man.
As of now I am just trying to get my maze to display, but run into errors.
Could someone take a look at my code and see what i am doing wrong.
Thanks,
GJ
Code:
#include <ctime>
#include <conio.h>
#include <windows.h>
#include "Maze.h"
int main()
{
Status s = CONTINUE;
short kb;
char c;
bool b = false;
system("cls");
srand(time(0));
Maze mObj("Maze.dat");
mObj.displayMaze();
while(s == CONTINUE)
{
if(kbhit())
{
kb = getche();
kb = getche();
cout << "\b \b";
mObj.movePlayer(kb);
}
mObj.moveGhosts();
s = mObj.determineStatus();
mObj.displayMaze();
Sleep(250);
}
if(s == WIN)
cout << "Player found the treasure - you win! ";
else
cout << "Player was killed by ghost - you lose ";
system("pause");
return 0;
}
header file
my class and constructor
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
enum Status
{CONTINUE, WIN, LOSE};
const int mazeSize = 24;
const int numberOfGhosts = 10;
class Maze
{
private:
// data members
char maze[mazeSize][mazeSize];
char fileName[21];
struct location
{
int row;
int column;
};
location player;
location treasure;
location ghosts[numberOfGhosts];
public:
// constructor
Maze(char fn[])
{
strcpy(fileName,fn);
ifstream mazeFile;
mazeFile.open("Maze.dat");
for(int r = 0; r < mazeSize; ++r)
{
for(int c = 0; c < mazeSize; ++c)
{
mazeFile >> Maze[r][c];
if(Maze[r][c] == "#")
Maze[r][c] = '\xba';
else
Maze[r][c] = ' ';
}
}
mazeFile.close();
}
//member functions
void displayMaze()
{
}
void movePlayer()
{
}
void setPlayer()
{
}
void setTreasure()
{
}
void moveGhosts()
{
}
void setGhosts()
{
}
void setMazeSize()
{
}
Status determineStatus()
{
return CONTINUE;
}
};