Pacman  1.0
Pacman game
Ghosts.h
Aller à la documentation de ce fichier.
1 #ifndef GHOSTS_H
2 #define GHOSTS_H
3 
4 #include "Entity.h"
5 #include "constants.h"
6 #include <iostream>
7 #include <random>
8 
15 class Ghosts : public Entity {
16  public:
17  Ghosts(float x, float y, int direction, Tile target, int dotCounter);
18  ~Ghosts();
30  void move(int pacmanX, int pacmanY, std::shared_ptr<Intersection> dest, int dotEaten);
41  void render(int frame, SDL_Renderer *renderer, SDL_Texture *texture);
42  virtual std::shared_ptr<Intersection> getDestination() = 0;
43  virtual void setDestination(std::shared_ptr<Intersection> dest) = 0;
44  void setMode(int mode);
45  int getMode();
46  virtual Tile getOrig() = 0;
47 
48  protected:
49  std::vector<SDL_Rect> sprites;
50  SDL_Rect getSprite(int frame, int direction);
51  int mode = SCATTER;
64  std::shared_ptr<Intersection> makeTurn(int pacmanX, int pacmanY,
65  std::shared_ptr<Intersection> dest);
66  virtual Tile getGoalTile(int pacmanX, int pacmanY) = 0;
69  std::mt19937 rng;
70  Uint32 modeTimer = 0;
72  bool isFree = false;
73 };
74 
75 #endif /* GHOSTS_H */
Entity class.
Definition: Entity.h:18
int direction
Definition: Entity.h:40
float x
Definition: Entity.h:37
float y
Definition: Entity.h:38
Ghosts class.
Definition: Ghosts.h:15
std::shared_ptr< Intersection > makeTurn(int pacmanX, int pacmanY, std::shared_ptr< Intersection > dest)
return the next intersection
Definition: Ghosts.cpp:108
virtual Tile getOrig()=0
virtual Tile getGoalTile(int pacmanX, int pacmanY)=0
virtual void setDestination(std::shared_ptr< Intersection > dest)=0
int previousMode
Definition: Ghosts.h:52
std::mt19937 rng
Definition: Ghosts.h:69
void setMode(int mode)
Definition: Ghosts.cpp:11
Tile scatterTarget
Definition: Ghosts.h:67
int getMode()
Definition: Ghosts.cpp:23
int mode
Definition: Ghosts.h:51
virtual std::shared_ptr< Intersection > getDestination()=0
bool isFree
Definition: Ghosts.h:72
SDL_Rect getSprite(int frame, int direction)
Definition: Ghosts.cpp:25
std::vector< SDL_Rect > sprites
Definition: Ghosts.h:49
~Ghosts()
Definition: Ghosts.cpp:9
void move(int pacmanX, int pacmanY, std::shared_ptr< Intersection > dest, int dotEaten)
move the ghost
Definition: Ghosts.cpp:45
int oppositeDirection(int direction)
Definition: Ghosts.cpp:93
Uint32 modeTimer
Definition: Ghosts.h:70
void render(int frame, SDL_Renderer *renderer, SDL_Texture *texture)
render the ghost
Definition: Ghosts.cpp:35
int dotCounter
Definition: Ghosts.h:71
Ghosts(float x, float y, int direction, Tile target, int dotCounter)
Definition: Ghosts.cpp:3
#define SCATTER
Definition: constants.h:44
Tile struct.
Definition: Maze.h:17