|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include "FileIO.h"
|
|
#include "Maze.h"
|
|
#include "Utilities.h"
|
|
#include "Game.h"
|
|
using namespace std;
|
|
|
|
|
|
void FileIO::SaveGame (Maze &m, Utilities &u, Game &g)
|
|
{
|
|
quitAfterSave = false;
|
|
|
|
if (u.checkKey()=='p')
|
|
{
|
|
|
|
int saveChoice = 0;
|
|
|
|
ofstream fout;
|
|
fout.open ("Pacman_Game_Save.txt");
|
|
|
|
|
|
for (int i=0;i<18;i++)
|
|
{
|
|
for (int j=0;j<21;j++)
|
|
{
|
|
fout << m.getMazeArray(j,i);
|
|
}
|
|
fout << endl;
|
|
}
|
|
|
|
fout.close();
|
|
|
|
|
|
do{
|
|
u.gotoXY(0,20);
|
|
cout <<" ";
|
|
u.gotoXY(0,20);
|
|
cout << "Your game has been saved, 1: Contiue 2: Quit: " << endl;
|
|
cout << " ";
|
|
u.gotoXY(45,20);
|
|
cin >> saveChoice;
|
|
}while(saveChoice!=1 && saveChoice!=2);
|
|
|
|
|
|
if (saveChoice == 2)
|
|
{
|
|
g.setLoopGameBool(false);
|
|
quitAfterSave =true;
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
u.gotoXY(0,20);
|
|
cout <<" ";
|
|
}
|
|
}
|
|
}
|
|
|
|
bool FileIO::getQuitAfterSave()
|
|
{
|
|
return quitAfterSave;
|
|
} |