-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFase.cpp
More file actions
109 lines (93 loc) · 2.54 KB
/
Copy pathFase.cpp
File metadata and controls
109 lines (93 loc) · 2.54 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
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
#include "Fase.h"
using namespace fases;
Fase::Fase(RenderWindow* w, Jogador* j) {
colisoes = new GerenciadorColisoes(j);
window = w;
j1 = j;
j2 = nullptr;
listaEntidades = new ListaEntidades;
listaEntidades->push(j1);
listaObstaculos = new Lista<Obstaculo>;
}
Fase::Fase(RenderWindow* w, Jogador* J1, Jogador* J2, float tempo) {
colisoes = new GerenciadorColisoes(J1, J2);
window = w;
j1 = J1;
j2 = J2;
tempoInicial = tempo;
listaEntidades = new ListaEntidades;
listaEntidades->push(j1);
if (j2 != nullptr) {
listaEntidades->push(j2);
}
listaObstaculos = new Lista<Obstaculo>;
}
Fase::~Fase() {
for (int i = 0; i < listaEntidades->getSize(); i++) {
listaEntidades->pop(i);
}
}
void Fase::inicializaElementos() {
for (int i = 0; i < listaObstaculos->getSize(); i++) {
Entidade* temp = listaObstaculos->getItem(i);
listaEntidades->push(temp);
}
}
ListaEntidades* Fase::getListaEntidades() {
return listaEntidades;
}
GerenciadorColisoes* Fase::getGerenciadorColisoes() {
return colisoes;
}
void Fase::executar() {
for (int i = 0; i < listaEntidades->getSize(); i++) {
Entidade* temp = listaEntidades->getItem(i);
if (temp != nullptr && temp->getVivo())
temp->move();
}
colisoes->executar();
if (colisoes->testaListaInimigo()) {
colisoes->limpaListaInimigo();
for (int i = 0; i < 6; i++) {
geraInimigoAleatorio();
}
}
}
void Fase::convertePlatF(int n) {
srand(time(NULL));
while (n > 0) {
for (int i = 0; i < listaObstaculos->getSize(); i++) {
if (rand() % 100 == 1 && listaObstaculos->getItem(i)->getId() == 31) {
Obstaculo* temp = listaObstaculos->getItem(i);
listaObstaculos->pop(temp);
temp = new PlataformaFalsa(Vector2f(temp->getX(), temp->getY()), Vector2f(temp->getLargura(), temp->getAltura()));
listaObstaculos->push(temp);
n--;
}
}
}
}
void Fase::converteEsp(int n) {
srand(time(NULL));
while (n > 0) {
for (int i = 0; i < listaObstaculos->getSize(); i++) {
if (rand() % 100 == 1 && listaObstaculos->getItem(i)->getId() == 31) {
Obstaculo* temp = listaObstaculos->getItem(i);
listaObstaculos->pop(temp);
temp = new Espinhos(Vector2f(temp->getX(), temp->getY()), Vector2f(temp->getLargura(), temp->getAltura()));
listaObstaculos->push(temp);
n--;
}
}
}
}
float Fase::getTempo(float tempo) {
return tempo - tempoInicial;
}
void Fase::setTempoRestante(float tempo) {
tempoRestante = tempo;
}
float Fase::getTempoRestante()
{
return tempoRestante;
}