Base-Defense
Projeto de um jogo desenvolvido em C++/SFML da disciplina de Linguagem de Programação
heroi.hpp
Ir para a documentação deste ficheiro.
1 #ifndef HEROI_HPP
2 #define HEROI_HPP
3 
4 #include <SFML/Graphics.hpp>
5 #include <SFML/Audio.hpp>
6 #include "../include/projeteis.hpp"
7 #include <vector>
8 using namespace sf;
9 using namespace std;
10 class Projetil;
11 
12 class Heroi {
13  public:
14  Heroi(int vida, const string& heroiFile, const Font& fonte);
15  virtual Sprite getSprite() const;
16  void definirPosicao(const Vector2f& posicao);
17  virtual void mover();
18  void atirar(const Vector2f& direcao);
19  void atualizarProjeteis(float deltaTime);
20  int getVida();
21  void setVida(int novaVida);
22  void setMunicao();
23  virtual void RecuperarVida();
24  void RecuperarMunicao();
25  void TomarDano();
26  void darMunicao();
27  Vector2f getPosicao();
28  virtual bool verificarColisao(const Sprite& sprite);
29  virtual bool verificarColisaoDrop(const Sprite& sprite);
30  virtual void renderizar(RenderWindow& window);
31  vector<Projetil>& getProjeteis();
32 
33  int getRandomQuantidadeProjetil();
34 
35  private:
36 
37 
38  string bulletSongFile = "assets/music/bulletsong.ogg";
39  Sound bulletSong;
40  SoundBuffer bufferBulletSong;
41  Texture texturaProjetil;
42  string projetilFile;
43  vector<Projetil> projeteis;
44  Texture background_heroi;
45  Sprite backgroundSprite_heroi;
46  Vector2f posicao;
47 
48  Clock relogio;
49  Time dps;
50 
51 
52  Sprite backgroundSprite_projetil;
53  Texture background_projetil;
54 
55  int quantidadeProjetil = 30;
56  Text textoMunicao;
57  protected:
58  int vida;
59  float velocidade = 300.0f;
60  Text textoVida;
61  int barraIndex = 0;
62  IntRect barra1 = IntRect(0, 0, 236, 20); // Primeira barra (verde)
63  IntRect barra2 = IntRect(23.6, 0, 236, 20); // Segunda barra (verde)
64  IntRect barra3 = IntRect(47.2, 0, 236, 20); // Terceira barra (verde)
65  IntRect barra4 = IntRect(70.8, 0, 236, 20); // Quarta barra (verde)
66  IntRect barra5 = IntRect(94.4, 0, 236, 20); // Quinta barra (amarela)
67  IntRect barra6 = IntRect(118, 0, 236, 20); // Sexta barra (amarela)
68  IntRect barra7 = IntRect(141.6, 0, 236, 20); // Sétima barra (vermelha)
69  IntRect barra8 = IntRect(165.2, 0, 236, 20);
70  IntRect barra9 = IntRect(188.8, 0, 236, 20);
71  IntRect barra10 = IntRect(212.4, 0, 236, 20);
72  vector<IntRect> barrasVida = {barra1, barra2, barra3, barra4, barra5, barra6, barra7, barra8, barra9, barra10};
73  Texture barraVida;
74  Sprite barraSprite;
75 };
76 
77 
78 #endif // HEROI_HPP
Definition: heroi.hpp:12
Text textoVida
Definition: heroi.hpp:60
int vida
Definition: heroi.hpp:58
Texture barraVida
Definition: heroi.hpp:73
Sprite barraSprite
Definition: heroi.hpp:74
Definition: projeteis.hpp:10