/* 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 #include #include "FileIO.h" #include "Maze.h" #include "Utilities.h" #include "Game.h" using namespace std; // fuction for out the Current Game State to txt file void FileIO::SaveGame (Maze &m, Utilities &u, Game &g) { quitAfterSave = false; //Eneter the funtion When User press 'p' key if (u.checkKey()=='p') { // for later user's input checking int saveChoice = 0; ofstream fout; fout.open ("Pacman_Game_Save.txt"); //store the current maze state in the txt folder for (int i=0;i<18;i++) { for (int j=0;j<21;j++) { fout << m.getMazeArray(j,i); } fout << endl; } fout.close(); // Print Chooses for Continue Game or not 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); // Loop while user not input 1 or 2 // Setting for end game if (saveChoice == 2) { g.setLoopGameBool(false); quitAfterSave =true; } else // Cover the printed word { u.gotoXY(0,20); cout <<" "; } } } bool FileIO::getQuitAfterSave() { return quitAfterSave; }