-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.h
More file actions
73 lines (56 loc) · 1.84 KB
/
Game.h
File metadata and controls
73 lines (56 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*----------------------------------------------------------------------------------------------*/
/* Game is the Main Object that controls the game of Pacman.
*/
#pragma once
#include "Player.h"
#include "GameObject.h"
#include "utils.h"
#include "Ghost_Expert.h"
#include "Ghost_Intermediate.h"
#include "Ghost_Novice.h"
#include "Const.h"
#include "Fruit.h"
#include "Board.h"
#include "Error.h"
#include <fstream>
#include <iostream>
#include <string>
#include <filesystem>
namespace fs = std::filesystem;
class Game {
protected:
Board* board2;
vector<string> levelNames;
char board[terminal_Size_Y][terminal_Size_X] = {};
char difficultyLevel = BEST; // if difficultyLevel not chosen, the default is BEST
bool saveMode;
std::fstream steps;
std::fstream result;
public:
Game(bool _saveMode = NORMAL) {
saveMode = _saveMode;
difficultyLevel = BEST;
}
bool withColor = false; // Is used to determine whether or not the game would be presented with or without colors.
enum State { WON, LOST, PAUSE };
void init();
void getLevels();
void printMenu(char& choice);
void instructions();
bool startGame(Player& player);
void printBoard2();
void printStats(int lives, int points, int food);
bool printMessage(State state);
void movePlayer(Player& player, char ch, char& temp);
void moveGhosts(vector<Ghost*>& ghosts, bool& moveTurn, GameObject pacmanPos);
void moveFruit(Fruit& fruit, int& moveTurn);
bool checkCollision(Player player, vector<Ghost*> ghosts);
void respawn(Player& player, vector<Ghost*>& ghosts);
void findFruitSpawnPoint(Fruit& fruit, Player player, vector<Ghost*> ghosts);
void checkFruitCollision(Player& player, vector<Ghost*> ghosts, Fruit& fruit);
char getDifficulty() const;
void setDifficulty(char diff);
// Save
string fileNameSteps(string fileName);
string fileNameResult(string fileName);
};