Pacman Torben Petré
Loading...
Searching...
No Matches
Difficulty.h
Go to the documentation of this file.
1#ifndef PACMAN_DIFFICULTY_H
2#define PACMAN_DIFFICULTY_H
3#include <unordered_map>
4
5
6namespace logic {
7
8
22
23
24 // Relatively accurately based on the table here:
25 // https://pacman.holenet.info/#LvlSpecs
26 class Difficulty {
27 public:
31 Difficulty(Difficulty &other) = delete;
32 void operator=(const Difficulty &) = delete;
33
34
39 [[nodiscard]] static Difficulty& getInstance();
40
41
42 //
43 // Directly exposing the Specifications from the DifficultySpecs Struct
44 // to avoid verbosity.
45 //
46
52 [[nodiscard]] int getFruitSpriteOffset() const;
53
59 [[nodiscard]] int getFruitPoints() const;
60
65 [[nodiscard]] float getPacmanSpeed() const;
66
71 [[nodiscard]] float getGhostSpeed() const;
72
77 [[nodiscard]] float getFrighenedGhostSpeed() const;
78
87 [[nodiscard]] float getFrightenedTime() const;
88
98 [[nodiscard]] int getFlashesh() const;
99
100
105 void increaseDifficulty();
106
110 void reset();
111
112 private:
113 Difficulty();
114
115 std::unordered_map<int, DifficultySpecs> difficultyMap;
116 int difficulty = 0;
117 };
118}
119
120
121
122#endif
float getFrightenedTime() const
This duration differs on every level and goes up and down.
Definition Difficulty.cpp:66
int getFruitSpriteOffset() const
Retrieves the sprite sheet offset for the fruit associated with the current difficulty level.
Definition Difficulty.cpp:46
void reset()
Resets the difficulty back to 0.
Definition Difficulty.cpp:41
static Difficulty & getInstance()
Returns an instance of the Difficulty class.
Definition Difficulty.cpp:30
int getFlashesh() const
Flashes determine how many warnings the player gets before frightened ghosts turn normal again.
Definition Difficulty.cpp:70
void increaseDifficulty()
Increases the difficulty for as long as it doesn't out~index the difficulty map. Reuses the final dif...
Definition Difficulty.cpp:36
Difficulty(Difficulty &other)=delete
void operator=(const Difficulty &)=delete
float getGhostSpeed() const
The speed of the Ghosts is different on some levels.
Definition Difficulty.cpp:58
float getFrighenedGhostSpeed() const
The speed decrease of the ghosts varies on some levels.
Definition Difficulty.cpp:62
float getPacmanSpeed() const
The speed of Pacman is different on some levels.
Definition Difficulty.cpp:54
int getFruitPoints() const
The point value differs per difficulty level. As per the original game. https://pacman....
Definition Difficulty.cpp:50
Definition Difficulty.h:6
Definition Difficulty.h:13
float frighenedGhostSpeed
Definition Difficulty.h:18
float pacmanSpeed
Definition Difficulty.h:16
int fruitSpriteOffset
Definition Difficulty.h:14
float ghostSpeed
Definition Difficulty.h:17
int fruitPoints
Definition Difficulty.h:15
float frightenedTime
Definition Difficulty.h:19
int flashesh
Definition Difficulty.h:20