24 explicit World(
const std::shared_ptr<AbstractFactory> &factory,
int lives);
32 [[nodiscard]]
float getWidth()
const;
59 [[nodiscard]] std::shared_ptr<PacmanModel>
getPacman()
const;
65 [[nodiscard]]
unsigned int getLives()
const;
82 [[nodiscard]]
float normalizeX(
int value)
const;
90 [[nodiscard]]
float normalizeY(
int value)
const;
101 [[nodiscard]]
bool collidesWithWall(
float normalizedX,
float normalizedY,
bool passDoor)
const;
121 void loadMap(
const std::string& path);
158 void respawnEntities();
163 void startFrightened();
168 void endFrightened();
176 void updateRestartingState(
double dt);
183 void updateFrightenedState(
double dt);
191 void updatePlayingState(
double dt);
198 void updateGhosts(
double dt);
203 void updateCollectibles();
205 float mapHeight = 20;
208 float tileWidth = 16;
209 float tileHeight = 16;
214 float DEATH_DURATION = 2;
220 bool flashing =
false;
222 std::pair<float, float> collissionCoordinates;
224 std::shared_ptr<AbstractFactory> factory;
225 std::vector<std::shared_ptr<CollectibleEntityModel>> collectibles;
226 std::vector<std::shared_ptr<GhostModel>> ghosts;
227 std::vector<std::shared_ptr<WallModel>> walls;
229 std::shared_ptr<PacmanModel> pacman;
float getFrightenedTime() const
This duration differs on every level and goes up and down.
Definition Difficulty.cpp:66
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
Definition EntityModel.h:12
std::pair< float, float > getCollissionCoordinates() const
Pair that holds the X and Y coordinates of the last collission registered by the World.
Definition World.cpp:37
std::shared_ptr< PacmanModel > getPacman() const
Definition World.cpp:28
float normalizeY(int value) const
Normalizes Grid coordinates on a [-1, 1] bounded coordinate system.
Definition World.cpp:46
int getGhostExitX() const
Exit coordinates are the coordinates specified on the map which Ghosts must go to in their exiting st...
Definition World.cpp:19
World(const std::shared_ptr< AbstractFactory > &factory, int lives)
Creates a World instance. Creating an instance does nothing on its own.
Definition World.cpp:7
unsigned int getLives() const
The current amount of lives that Pacman has remaining.
Definition World.cpp:32
void loadMap(const std::string &path)
Loads any map that is in a rectangular format and follows the specific ASCII formatting....
Definition World.cpp:70
void killPacman()
Kills Pacman, subtracts a live and puts the World in RESTARTING state.
Definition World.cpp:276
int getGhostExitY() const
Exit coordinates are the coordinates specified on the map which Ghosts must go to in their exiting st...
Definition World.cpp:23
void update(double dt)
World Update function. Calls specific helper methods based on the current World state (RESTARTING,...
Definition World.cpp:249
float normalizeX(int value) const
Normalizes Grid coordinates on a [-1, 1] bounded coordinate system.
Definition World.cpp:42
float getHeight() const
Returns the height of the currently loaded map (width is in tiles).
Definition World.cpp:15
void handleMove(const Moves &move) const
Passes a move down to Pacman.
Definition World.cpp:269
float getWidth() const
Returns the width of the currently loaded map (width is in tiles).
Definition World.cpp:11
bool collidesWithWall(float normalizedX, float normalizedY, bool passDoor) const
Checks whether the provided coordinates collide with a wall. Takes door Wall types into consideration...
Definition World.cpp:56
Definition Difficulty.h:6
Moves
Definition EntityModel.h:8
WorldState
Definition World.h:12
@ RESTARTING
Definition World.h:12
@ FRIGHTENED
Definition World.h:12
@ PLAYING
Definition World.h:12
@ AWAITING_MAP
Definition World.h:12
constexpr float COLLISSION_EPSILON
Definition World.h:14