-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapa.pde
More file actions
260 lines (214 loc) · 8.69 KB
/
Copy pathMapa.pde
File metadata and controls
260 lines (214 loc) · 8.69 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
class Mapa {
Nivel1 nivel1;
Nivel2 nivel2;
Nivel3 nivel3;
Nivel4 nivel4;
ResetArea resetArea;
int indexCheckPoint;
ArrayList <CheckPoint> checkPoints = new ArrayList<CheckPoint>();
Mapa() {
nivel1 = new Nivel1();
nivel2 = new Nivel2();
nivel3 = new Nivel3();
nivel4 = new Nivel4();
resetArea = new ResetArea();
nivel1.Start();
nivel2.Start();
nivel3.Start();
nivel4.Start();
}
void DibujarNiveles() {
nivel1.Update();
nivel2.Update();
nivel3.Update();
nivel4.Update();
}
}
//-----------------------------------------------------------------------------------------------------------
class Nivel1 {
Plataforma[] suelo = new Plataforma[8];
float nivelPosX = unidad*3;
float nivelPosY = 0;
Nivel1() {
float size = 6 * unidad;
suelo[0] = new Plataforma (nivelPosX + (0 * unidad), nivelPosY + (20 * unidad), size, size);
suelo[1] = new Plataforma (nivelPosX + (6 * unidad), nivelPosY + (20 * unidad), size, size);
suelo[2] = new Plataforma (nivelPosX + (12 * unidad), nivelPosY + (20 * unidad), size, size);
suelo[3] = new Plataforma (nivelPosX + (18 * unidad), nivelPosY + (20 * unidad), size, size);
suelo[4] = new Plataforma (nivelPosX + (24 * unidad), nivelPosY + (18.5 * unidad), size, size);
suelo[5] = new Plataforma (nivelPosX + (30 * unidad), nivelPosY + (17 * unidad), size, size);
suelo[6] = new Plataforma (nivelPosX + (38 * unidad), nivelPosY + (15 * unidad), size, size);
suelo[7] = new Plataforma (nivelPosX + (49 * unidad), nivelPosY + (12 * unidad), size, size);
println("nivel 1 inicializo");
}
void Start() {
for (int i=0; i < suelo.length; i++) {
suelo[i].GetIndex(i);
suelo[i].GetNivel(1);
suelo[i].DarColor();
suelo[i].Enumerar();
suelo[i].StartAreaDeVuelo();
}
AddEventosDeCambioDeDireccionDeSprites();
AddAreaDeCaidaEnLaterales();
}
void Update() {
for (int i=0; i < suelo.length; i++) {
suelo[i].Update();
}
}
void AddEventosDeCambioDeDireccionDeSprites() {
for (int i=0; i < suelo.length-1; i++) {
mundo.add(new AreaCambiarDireccion(suelo[i], "UP", 1));
}
mundo.add(new AreaCambiarDireccion(suelo[7], "UP", -1));
mundo.add(new AreaCambiarDireccion(suelo[7], "LEFT", -1));
}
void AddAreaDeCaidaEnLaterales() {
suelo[0].StartAreaDeCaida("AMBOS");
suelo[1].StartAreaDeCaida("AMBOS");
suelo[2].StartAreaDeCaida("AMBOS");
suelo[3].StartAreaDeCaida("AMBOS");
suelo[4].StartAreaDeCaida("RIGHT");
}
}
//-----------------------------------------------------------------------------------------------------------
class Nivel2 {
Plataforma[] suelo = new Plataforma[11];
float nivelPosX = 0;
float nivelPosY = 0;
Nivel2() {
suelo[0] = new Plataforma (nivelPosX + (49 * unidad), nivelPosY + (4 * unidad), 5 * unidad, 5 * unidad);
suelo[1] = new Plataforma (nivelPosX + (39 * unidad), nivelPosY + (2 * unidad), 5 * unidad, 5 * unidad);
suelo[2] = new Plataforma (nivelPosX + (36 * unidad), nivelPosY + (1 * unidad), 3 * unidad, 3 * unidad);
suelo[3] = new Plataforma (nivelPosX + (32 * unidad), nivelPosY + (2 * unidad), 3 * unidad, 3 * unidad);
suelo[4] = new Plataforma (nivelPosX + (28 * unidad), nivelPosY + (-0.5 * unidad), 4 * unidad, 4 * unidad);
suelo[5] = new Plataforma (nivelPosX + (22 * unidad), nivelPosY + (-4.5 * unidad), 6 * unidad, 6 * unidad);
suelo[6] = new Plataforma (nivelPosX + (29.5 * unidad), nivelPosY + (-9 * unidad), 3 * unidad, 3 * unidad);
suelo[7] = new Plataforma (nivelPosX + (34 * unidad), nivelPosY + (-10.5 * unidad), 5 * unidad, 5 * unidad);
suelo[8] = new Plataforma (nivelPosX + (39 * unidad), nivelPosY + (-10.5 * unidad), 5 * unidad, 5 * unidad);
suelo[9] = new Plataforma (nivelPosX + (44 * unidad), nivelPosY + (-10.5 * unidad), 5 * unidad, 5 * unidad);
suelo[10]= new Plataforma (nivelPosX + (34 * unidad), nivelPosY + (-5.5 * unidad), 15 * unidad, 5 * unidad);
println("nivel 2 inicializo");
}
void Start() {
for (int i=0; i < suelo.length; i++) {
suelo[i].GetIndex(i);
suelo[i].GetNivel(2);
suelo[i].Enumerar();
suelo[i].DarColor();
suelo[i].StartAreaDeVuelo();
}
suelo[10].areaInteractiva.removeFromWorld();
suelo[10].checkPoint.removeFromWorld();
AddEventosDeCambioDeDireccionDeSprites();
AddAreaDeCaidaEnLaterales();
}
void Update() {
for (int i=0; i < suelo.length; i++) {
suelo[i].Update();
}
}
void AddEventosDeCambioDeDireccionDeSprites() {
mundo.add(new AreaCambiarDireccion(suelo[0], "UP", -1));
mundo.add(new AreaCambiarDireccion(suelo[0], "RIGHT", -1));
mundo.add(new AreaCambiarDireccion(suelo[1], "UP", -1));
mundo.add(new AreaCambiarDireccion(suelo[2], "UP", -1));
mundo.add(new AreaCambiarDireccion(suelo[3], "UP", -1));
mundo.add(new AreaCambiarDireccion(suelo[4], "UP", -1));
mundo.add(new AreaCambiarDireccion(suelo[5], "UP", 1));
mundo.add(new AreaCambiarDireccion(suelo[5], "RIGHT", 1));
for (int i=6; i < suelo.length-1; i++) {
mundo.add(new AreaCambiarDireccion(suelo[i], "UP", 1));
}
}
void AddAreaDeCaidaEnLaterales() {
suelo[1].StartAreaDeCaida("LEFT");
suelo[3].StartAreaDeCaida("LEFT");
suelo[4].StartAreaDeCaida("LEFT");
suelo[8].StartAreaDeCaida("AMBOS");
}
}
//-----------------------------------------------------------------------------------------------------------
class Nivel3 {
Plataforma[] suelo = new Plataforma[4];
float nivelPosX = 0;
float nivelPosY = 0;
Nivel3() {
suelo[0] = new Plataforma (nivelPosX + (55 * unidad), nivelPosY + (-12.5 * unidad), 3.5 * unidad, 3.5 * unidad);
suelo[1] = new Plataforma (nivelPosX + (58 * unidad), nivelPosY + (-16 * unidad), 3 * unidad, 2.5 * unidad);
suelo[2] = new Plataforma (nivelPosX + (60 * unidad), nivelPosY + (-19 * unidad), 2.5 * unidad, 2 * unidad);
suelo[3] = new Plataforma (nivelPosX + (63 * unidad), nivelPosY + (-21.5 * unidad), 4 * unidad, 1.5 * unidad);
println("nivel 3 inicializo");
}
void Start() {
for (int i=0; i < suelo.length; i++) {
suelo[i].GetIndex(i);
suelo[i].GetNivel(3);
suelo[i].Enumerar();
suelo[i].DarColor();
suelo[i].StartAreaDeVuelo();
}
AddEventosDeCambioDeDireccionDeSprites();
}
void Update() {
for (int i=0; i < suelo.length; i++) {
suelo[i].Update();
}
}
void AddEventosDeCambioDeDireccionDeSprites() {
mundo.add(new AreaCambiarDireccion(suelo[3], "UP", -1));
mundo.add(new AreaCambiarDireccion(suelo[3], "LEFT", -1));
}
}
//-----------------------------------------------------------------------------------------------------------
class Nivel4 {
Plataforma[] suelo = new Plataforma[6];
float nivelPosX = 2*unidad;
float nivelPosY = 2*unidad;
Nivel4() {
CrearFamilyBird();
suelo[0] = new Plataforma (nivelPosX + (50 * unidad), nivelPosY + (-28 * unidad), 5 * unidad, 5 * unidad);
suelo[1] = new Plataforma (nivelPosX + (38 * unidad), nivelPosY + (-31 * unidad), 5 * unidad, 5 * unidad);
suelo[2] = new Plataforma (nivelPosX + (27 * unidad), nivelPosY + (-32 * unidad), 4 * unidad, 4 * unidad);
suelo[3] = new Plataforma (nivelPosX + (17 * unidad), nivelPosY + (-27 * unidad), 2 * unidad, 2 * unidad);
suelo[4] = new Plataforma (nivelPosX + (13 * unidad), nivelPosY + (-22 * unidad), 4 * unidad, 4 * unidad);
suelo[5] = new Plataforma (nivelPosX + (-8 * unidad), nivelPosY + (-23.5 * unidad), 12 * unidad, 12 * unidad);
println("nivel 4 inicializo");
}
void Start() {
for (int i=0; i < suelo.length; i++) {
suelo[i].GetIndex(i);
suelo[i].GetNivel(4);
suelo[i].Enumerar();
suelo[i].DarColor();
suelo[i].StartAreaDeVuelo();
}
AddEventosDeCambioDeDireccionDeSprites();
}
void Update() {
for (int i=0; i < suelo.length; i++) {
suelo[i].Update();
}
if (suelo[5].areaInteractiva.isTouchingBody(bird))
escena = "ganaste";
}
void AddEventosDeCambioDeDireccionDeSprites() {
for (int i=0; i < suelo.length-1; i++) {
mundo.add(new AreaCambiarDireccion(suelo[i], "UP", -1));
}
AreaCambiarDireccion areaExcepcional = new AreaCambiarDireccion(suelo[0], "UP", 1);
areaExcepcional.adjustPosition(200, 350);
areaExcepcional.addToWorld(mundo);
}
void CrearFamilyBird() {
FBox familyBird = new FBox(50, 175);
PImage motherAndBirds = loadImage("motherAndBirds.png");
float posX = nivelPosX + (-8 * unidad) + (6 * unidad);
float posY = nivelPosY + (-23.5 * unidad)-(familyBird.getHeight()/2)+10;
familyBird.setPosition(posX, posY);
familyBird.attachImage(motherAndBirds);
familyBird.setSensor(true);
mundo.add(familyBird);
}
}//end method