-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
304 lines (231 loc) · 7.7 KB
/
Copy pathGame.java
File metadata and controls
304 lines (231 loc) · 7.7 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Game extends World
{
private Player1 thePlayer1;
private Leben theAnzeige1;
Enemigo heEnemigo1,theEnemigo2,theEnemigo3;
private SpeedShow theSpeed1;
private BombsShow theBombs1;
private RadiusShow theRadius1;
int x1, y1, counter1 = 0, zeitpunkt, Verletzung1, Anzeigecounter1 = 0;
int bombs1, radius1, speed1;
int p1Leben;
int[][] Objekte = new int[15][15];
int enemigo=3;
public Player1 getPlayer(){
return thePlayer1;
}
public Game(int z, int[][] o, int V1, int V2, int c1, int c2, int pl1, int pl2, int b1, int b2, int r1, int r2, int s1, int s2, int x1z, int y1z, int x2z, int y2z)
{
super(1050, 900, 1);
setPaintOrder(GameOver.class); //
zeitpunkt = z;
Objekte = o;
Anzeigecounter1 = c1;
Verletzung1 = V1;
p1Leben = pl1;
bombs1 = b1;
radius1 = r1;
speed1 = s1;
x1 = x1z;
y1 = y1z;
prepare();
wall();
}
public void act()
{
if (p1Leben > 0)
{
thePlayer1.information1Game();
}
if (counter1 > 0) counter1--;
anzeige();
if(Verletzung1 == 1)
{
reduceLife(1, Anzeigecounter1, 1);
Verletzung1 = 0;
}
else if(Verletzung1 == 2)
{
reduceLife(1, Anzeigecounter1, 2);
Verletzung1 = 0;
}
}
private void prepare()
{
thePlayer1 = new Player1(0, counter1, bombs1, radius1, speed1);
addObject(thePlayer1, 180, 130);
if(zeitpunkt == 0)
{
Division aufteilung = new Division();
addObject(aufteilung, 0, 0);
}
else
{
for(int i = 0; i < 15; i++)
{
for(int j = 0; j < 15; j++)
{
if(Objekte[i][j] == 1)
{
Fragil wood = new Fragil();
addObject(wood, 175+i*50, 125+j*50);
}
else if(Objekte[i][j] == 2)
{
ExtraBombe extrabombe = new ExtraBombe();
addObject(extrabombe,175+i*50, 125+j*50);
}
else if(Objekte[i][j] == 3)
{
//NuevaVida vida = new NuevaVida();
//addObject(vida, 175+i*50, 125+j*50);
}
else if(Objekte[i][j] == 5)
{
Speed speed = new Speed();
addObject(speed, 175+i*50, 125+j*50);
}
else if(Objekte[i][j] == 6)
{
Fuerza f = new Fuerza();
addObject(f, 175+i*50, 125+j*50);
}
else if(Objekte[i][j] > 70)
{
switch(Objekte[i][j]){
case 71:
Enemigo theEnemigo1 = new enemigo1();
addObject(theEnemigo1,175+i*50, 125+j*50);
break;
case 72:
Enemigo theEnemigo2 = new enemigo2();
addObject(theEnemigo2,175+i*50, 125+j*50);
break;
case 73:
Enemigo theEnemigo3 = new enemigo3();
addObject(theEnemigo3,175+i*50, 125+j*50);
break;
}
}
}
}
}
theAnzeige1 = new Leben (p1Leben, 1, 0, Anzeigecounter1, 0);
addObject(theAnzeige1, 858, 30);
theSpeed1 = new SpeedShow (speed1, 1);
addObject(theSpeed1, 990, 120);
theRadius1 = new RadiusShow (radius1, 1);
addObject(theRadius1, 990, 160);
theBombs1 = new BombsShow (bombs1, 1);
addObject(theBombs1, 990, 200);
}
public Player1 getPlayer1()
{
return thePlayer1;
}
public void enemigoMenos(){
enemigo--;
if(enemigo==0){
theAnzeige1 = new Leben (p1Leben, 1, 0, 0, 0);
addObject(theAnzeige1, 858, 30);
thePlayer1.verletzen();
p1Leben=0;
if (p1Leben == 0)
{
GameOver gameOver = new GameOver(2); //
addObject(gameOver, 525, 450);
}}
}
public void saveInformation1(int x, int y, int b, int s, int r)
{
x1 = x;
y1 = y;
bombs1 = b;
speed1 = s;
radius1 = r;
}
public void anzeige()
{
removeObject(theSpeed1);
theSpeed1 = new SpeedShow (speed1, 1);
addObject(theSpeed1, 990, 120);
removeObject(theBombs1);
theBombs1 = new BombsShow (bombs1, 1);
addObject(theBombs1, 990, 160);
removeObject(theRadius1);
theRadius1 = new RadiusShow (radius1, 1);
addObject(theRadius1, 990, 200);
}
/*public void chaos()//
{
Greenfoot.setWorld(new Chaos(this, x1, y1, p1Leben, Objekte, bombs1, radius1, speed1));
}*/
public void addLife(int player)
{
if (player == 1 && p1Leben < 3)
{
p1Leben++;
removeObject(theAnzeige1);
theAnzeige1 = new Leben (p1Leben, player, 1, 0, 0);
addObject(theAnzeige1, 858, 30);
}
}
public void reduceLife(int player, int c, int howmuch)
{
if (player == 1 && counter1 == 0) //
{
p1Leben--;
if(howmuch == 2) p1Leben--;
removeObject(theAnzeige1);
theAnzeige1 = new Leben (p1Leben, player, 0, c, howmuch);
addObject(theAnzeige1, 858, 30);
thePlayer1.verletzen();
if (p1Leben == 0)
{
GameOver gameOver = new GameOver(2); //
addObject(gameOver, 525, 450);
}
counter1 = 20;
}
}
public void saveObjects(int[][] o)
{
Objekte = o;
}
public void changeObjects(int x, int y, int n)
{
Objekte[x][y] = n;
}
private void wall()
{
for (int i = 125; i<926; i = i+50)
{
Solido construido = new Solido();
addObject(construido, i, 75);
}
for (int i = 125; i<926; i = i+50)
{
Solido construido = new Solido();
addObject(construido, i, 875);
}
for (int j = 75; j<826; j=j+50)
{
Solido construido = new Solido();
addObject(construido, 125, j);
}
for (int j = 75; j<826; j=j+50)
{
Solido construido = new Solido();
addObject(construido, 925, j);
}
for (int j = 175; j<776; j=j+100)
{
for (int i = 225; i<826; i=i+100)
{
Solido construido = new Solido();
addObject(construido, i, j);
}
}
}
}