-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.h
154 lines (111 loc) · 3.56 KB
/
player.h
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef PLAYER_H_INCLUDED
#define PLAYER_H_INCLUDED
#include <iostream>
#include <SFML/Graphics.hpp>
#include <list>
#include "tirs/projectile.h"
#include "unit.h"
#include "timer.h"
#include "animation.h"
#include "tirs/missile.h"
#include "image_manager.h"
#include "tirs/projectile_manager.h"
#include "Cheat_manager.h"
class Player : public Unit
{
public:
Player(short id, int life, sf::Vector2f position);
//Destructeur
~Player();
//Accesseur sur le sprite du joueur
sf::Sprite* getSprite();
//Accesseur sur le nombre de vies
short getLives();
//accesseur sur le rectangle du sprite
sf::IntRect GetBoundingBox();
//Fait tirer le joueur
void fire0();
void fire1();
//Déplace les projectiles
void moveProjectile();
//Dessine les projectiles
void drawProjectile();
//Augmente le score du joueur
void addScore(int score);
//accesseur sur le score
int getScore();
//Fait perdre une vie
void loseLive();
//accesseur sur l'état du joueur (vient de perdre une vie ou non)
bool getLostlife();
//Remet le joueur dans l'état dans lequel ile st susceptible de perdre une vie
void resetLostLife();
//Déplacements
void moveUp();
void moveDown();
void moveLeft();
void moveRight();
void dontMove();
//Dessiner le joueur
void draw();
//accesseur sur la position
int getPosition(int axis);
sf::Vector2f getPosition();
void setPosition(int axis, int value);
//accesseur sur le nombre de dommages
short getDamages() const;
//accesseur sur les missiles du joueur
bool getMissile();
//accesseur sur l'arme secondaire
bool getSecondary();
bool getThird();
//Setters
void setMissile(bool mode);
void setSecondary(bool mode);
void setThird(bool mode);
short getArmor();
bool getPlayerKTA();
void setPlayerKTA(bool state);
void checkKTA();
bool isDead();
void explosion();
protected:
//Vitesse du joueur
sf::Vector2f m_speed;
//Dommages infligés et nombre de vies
short const m_damages;
short m_lives;
short m_armor;
bool exploding;
//Nombre max de vie du joueur, taille du sprite et coef de déplacememnt
short const max_lives, m_coefSpeed;
int const m_frameWidth, m_frameHeight;
//Temps entre deux tirs en secondes
float const fireRate;
//Moment du dernier tir
float lastShot;
//Timer sur les tirs
Timer timer;
Timer timerArmor;
Timer timerKillThemAll;
//Score courant du joueur
long double m_score;
//Etat invincible ou non du joueur, activations des différentes armes
bool lostLife, missiles, secondary, third;
//Variables d'animation
Animated *m_animated;
//Contiennent les framesp our les différents déplacements
Anim m_anim, goRight, goLeft;
//Animation réacteur
Animated *m_animatedReactor;
//Contient les frames du réacteur
Anim m_animReactor;
//L'image associée au sprite du vaisseau
sf::Image *image;
//Image du réacteur
sf::Image *imageReactor;
bool killThemAll;
};
//Autorise ou non les tirs
bool canFire(float lastShot, Timer &timer, float const fireRate);
#endif // PLAYER_H_INCLUDED