-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPlayer.h
More file actions
84 lines (70 loc) · 2.44 KB
/
Player.h
File metadata and controls
84 lines (70 loc) · 2.44 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
74
75
76
77
78
79
80
81
82
83
84
#ifndef PLAYER_H
#define PLAYER_H
#include "Level_Load.h"
#include <set>
#include <vector>
// Pacman Timing: Each 0.136 seconds per position in the map. For each move, it's drawn 4 times.
// Updated at 7.35 FPS and drawn at 29.4 FPS
const int INITIAL_PACMAN_LIVES = 2;
enum tDirection { RIGHT, DOWN, LEFT, UP, NON };
const std::set<tGame_Element> ALLOWED_OBJECTS = { INITIAL, EMPTY, RED_GHOST, BLUE_GHOST, PINK_GHOST, ORANGE_GHOST, PLAYER, PELLET, POWER_UP, CHERRY, PINEAPPLE, WATERMELON, BONUS_POINT };
struct pixel_position {
int x, y;
float pixel_x, pixel_y;
};
const int PACMAN_ANIMATION_STAGES = 10;
class Player
{
public:
Player(Level const& level, int mLives);
void Reset(Level &level);
void GameReset(Level &level, int l= INITIAL_PACMAN_LIVES);
void SetDirection(tDirection direction);
void SetNextDirection(tDirection next_direction);
void SetLastDirection(tDirection last_direction);
void SetDead(bool b);
void SetAnimationState(int i);
void ResetProgress();
void IncreaseProgress();
void SetPosition(const int & x, const int & y);
void SetInitialPosition(const int & x, const int & y);
void SetPixelPosition(float pixel_x, float pixel_y);
void SetLives(const short int & l);
void MovePlayer(std::vector<std::vector<tGame>> &map);
void Draw(float swidth, float sheight, int x, int y);
void SetCounter(int i);
void SetDeadCounter(int i);
void SetMaxCounter(int i);
void ResetCounter();
ALLEGRO_BITMAP *GetBitmap() const;
tDirection GetDirection() const;
tDirection GetNextDirection() const;
tDirection GetLastDirection() const;
int GetProgress() const;
int GetLives() const;
int GetPositionX() const;
int GetPositionY() const;
int GetInitialPositionX() const;
int GetInitialPositionY() const;
float GetPixelPositionX() const;
float GetPixelPositionY() const;
int GetAnimationState() const;
int GetCounter() const;
int GetMaxCounter() const;
int GetDeadCounter() const;
bool GetDead() const;
~Player();
private:
bool dead;
int progress, max_lives;
short int lives, animationState, counter;
int max_counter, dead_counter;
pixel_position initial_position, position;
std::vector<ALLEGRO_BITMAP *> sprite;
std::vector<ALLEGRO_BITMAP *> dead_sprite;
tDirection dir, next_dir, last_dir;
};
void CheckJump(std::vector<std::vector<tGame>> & map, int & checkX, int & checkY);
bool movementPossible(std::vector<std::vector<tGame>> &map, int checkX, int checkY, bool ghost = false);
tDirection GetOppositeDirection(tDirection direction);
#endif