-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_bolaAtaque.pde
More file actions
93 lines (79 loc) · 2 KB
/
class_bolaAtaque.pde
File metadata and controls
93 lines (79 loc) · 2 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
int totalBolas = 250;
ArrayList<BolaAtaque> bolasAtaque = new ArrayList<BolaAtaque>();
int bolasSalidas = 0;
void reiniciarVariables() {
if (vidaRed > vidaRedMax/2) {
totalBolas = 250;
} else if (vidaRed <= vidaRedMax/2) {
totalBolas = 400;
}
bolasAtaque.clear();
bolasSalidas = 0;
}
void reiniciarAtaqueBolas() {
totalBolas = 250;
}
void manejarBolasAtaque() {
for (int i = bolasAtaque.size() - 1; i >= 0; i--) {
BolaAtaque bolaAtaque = bolasAtaque.get(i);
bolaAtaque.mover();
bolaAtaque.mostrar();
if (almaPlayer.colisionConBola(bolaAtaque.x, bolaAtaque.y)) {
vida -= 4;
golpe.play();
bolasAtaque.remove(i);
bolasSalidas++;
}
if (bolaAtaque.fueraDePantalla()) {
bolasAtaque.remove(i);
bolasSalidas++;
if (bolasSalidas >= totalBolas && turnoAtaque != 9) {
boton = ultimoBoton;
turnoJugador = true;
menuPelea = true;
}
}
}
if (bolasAtaque.size() < totalBolas && bolasSalidas < totalBolas) {
bolasAtaque.add(new BolaAtaque());
}
}
class BolaAtaque {
float x, y;
float radio;
float velocidad;
float direccion;
float velocidadRadio;
float alternador = random(5);
BolaAtaque() {
radio = 0;
direccion = random(TWO_PI);
velocidad = random(0.0005, 0.02);
velocidadRadio = 2;
}
void mover() {
direccion += velocidad;
if (turnoCombate%2 != 0 && vidaRed > vidaRedMax/2) {
x = 177 + cos(direccion) * radio;
} else if (vidaRed <= vidaRedMax/2 && alternador > 2) {
x = 177 + cos(direccion) * radio;
} else if (vidaRed <= vidaRedMax/2 && alternador < 2) {
x = 630 + cos(direccion) * radio;
} else {
x = 630 + cos(direccion) * radio;
}
y = 166 + sin(direccion) * radio;
radio += velocidadRadio;
}
void mostrar() {
fill(255, 0, 0);
noStroke();
circle(x, y, 10);
}
boolean fueraDePantalla() {
return x < 0 || x > width || y < 0 || y > height;
}
float calcularArea() {
return PI * radio * radio;
}
}