-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMyWorld.java
More file actions
210 lines (184 loc) · 8.88 KB
/
Copy pathMyWorld.java
File metadata and controls
210 lines (184 loc) · 8.88 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
import greenfoot.Actor;
import greenfoot.Greenfoot;
import greenfoot.GreenfootImage;
import greenfoot.GreenfootSound;
import greenfoot.World;
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
public class MyWorld extends World {
int rap = 425;
int bap;
int spawntime;
int spr;
public Map<String, Integer> redpowerups;
public Map<String, Integer> bluepowerups;
public Timer timer;
int preg;
int pink;
int rrcan;
boolean rfsound;
boolean bfsound;
boolean isound;
public static GreenfootSound music = new GreenfootSound("cheer.wav");
public MyWorld() {
super(1256, 570, 1);
timer = new Timer();
this.bap = 1256 - this.rap;
this.spawntime = 0;
this.redpowerups = new HashMap();
this.bluepowerups = new HashMap();
this.rrcan = 0;
this.rfsound = false;
this.bfsound = false;
this.isound = false;
this.setPaintOrder(new Class[]{Obscurer.class, Water.class, Actor.class});
this.addObject(new ScoreBoard(), 628, 485);
this.addObject(timer, 628, 468);
this.addObject(new RedFuel(), 334, 538);
this.addObject(new BlueFuel(), 922, 538);
this.addObject(new RedRotors(), 216, 535);
this.addObject(new BlueRotors(), 1040, 535);
this.addObject(new RedClimber(), 108, 535);
this.addObject(new BlueClimber(), 1148, 535);
this.addObject(new RedScore(), 555, 524);
this.addObject(new BlueScore(), 701, 524);
this.addObject(new BottomAirship(0), this.rap, 362);
this.addObject(new BottomAirship(1), this.bap, 362);
this.addObject(new Peg(0), 341, 360);
this.addObject(new Peg(1), 914, 360);
this.addObject(new TopAirship(0), this.rap - 1, 286);
this.addObject(new TopAirship(1), this.bap - 1, 286);
this.addObject(new CenterRotor(1), this.bap + 2, 195);
this.addObject(new CenterRotor(0), this.rap + 2, 195);
this.addObject(new BoilerBottom(0), 38, 299);
this.addObject(new BoilerTop(0), 38, 191);
this.addObject(new BoilerScore(1), 41, 154);
this.addObject(new BoilerBottom(1), 1218, 299);
this.addObject(new BoilerTop(1), 1219, 191);
this.addObject(new BoilerScore(0), 1216, 154);
this.addObject(new BlueFeeder(), 38, 339);
this.addObject(new RedFeeder(), 1218, 339);
this.addObject(new BlueDavit(), 705, 274);
this.addObject(new RedDavit(), 550, 274);
this.addObject(new Feeder(), 628, 350);
this.addObject(new RedRobot(), 155, 370);
this.addObject(new BlueRobot(), 1101, 370);
this.addObject(new BlueRotor(), this.bap + 2, 216);
this.addObject(new BlueRotor(), this.bap + 93, 216);
this.addObject(new BlueRotor(), this.bap - 94, 216);
this.addObject(new RedRotor(), this.rap + 2, 216);
this.addObject(new RedRotor(), this.rap - 93, 216);
this.addObject(new RedRotor(), this.rap + 92, 216);
this.addObject(new Text("Qualification 133 of 140", 24, Color.BLACK, (Color)null, (Color)null), 400, 425);
this.addObject(new Text("Beantown Blitz", 24, Color.BLACK, (Color)null, (Color)null), 880, 425);
for(int i = 0; i < Title.allpowerups.length; ++i) {
this.redpowerups.put(Title.allpowerups[i], Integer.valueOf(0));
this.bluepowerups.put(Title.allpowerups[i], Integer.valueOf(0));
}
this.spr = (3 - Title.spawnrate) * 500;
this.spr = (int)((double)this.spr + (Math.floor(Math.random() * (double)(200 * (3 - Title.spawnrate))) - (double)(100 * (3 - Title.spawnrate))));
if(Title.sounds) {
Greenfoot.playSound("charge-1.wav");
}
if(Title.bgsound) {
music.playLoop();
}
}
public void act() {
if(Title.spawnrate != 0) {
++this.spawntime;
if(this.spawntime >= this.spr) {
this.addObject(new Powerup(Title.powerups[(int)Math.floor(Math.random() * (double)Title.powerups.length)]), (int)Math.floor(Math.random() * 1008.0D) + 124, (int)Math.floor(Math.random() * 400.0D));
this.spr = (3 - Title.spawnrate) * 500;
this.spr = (int)((double)this.spr + (Math.floor(Math.random() * (double)(200 * (3 - Title.spawnrate))) - (double)(100 * (3 - Title.spawnrate))));
this.spawntime = 0;
}
}
for(int i = 0; i < Title.powerups.length; ++i) {
if(((Integer)this.redpowerups.get(Title.powerups[i])).intValue() > 0) {
this.redpowerups.put(Title.powerups[i], Integer.valueOf(((Integer)this.redpowerups.get(Title.powerups[i])).intValue() - 1));
}
if(((Integer)this.bluepowerups.get(Title.powerups[i])).intValue() > 0) {
this.bluepowerups.put(Title.powerups[i], Integer.valueOf(((Integer)this.bluepowerups.get(Title.powerups[i])).intValue() - 1));
}
}
int reg = 0;
int space = 0;
if(((Integer)this.redpowerups.get("regolith")).intValue() > 0 || ((Integer)this.bluepowerups.get("regolith")).intValue() > 0) {
reg = 1;
}
if(((Integer)this.redpowerups.get("space")).intValue() > 0 || ((Integer)this.bluepowerups.get("space")).intValue() > 0) {
space = 1;
}
this.setBackground(new GreenfootImage("Background" + reg + "" + space + ".png"));
if(!this.getObjects(Obscurer.class).isEmpty()) {
this.removeObject((Actor)this.getObjects(Obscurer.class).get(0));
}
if(((Integer)this.redpowerups.get("blindness")).intValue() <= 0 && ((Integer)this.bluepowerups.get("blindness")).intValue() <= 0) {
this.isound = true;
} else {
this.addObject(new Obscurer(), 628, 200);
if(this.isound && Title.sounds) {
Greenfoot.playSound("splat.wav");
this.isound = false;
}
}
if(!this.getObjects(Water.class).isEmpty()) {
this.removeObject((Actor)this.getObjects(Water.class).get(0));
}
if(((Integer)this.redpowerups.get("watergame")).intValue() > 0 || ((Integer)this.bluepowerups.get("watergame")).intValue() > 0) {
this.addObject(new Water(), 628, 350);
}
if(((Integer)this.redpowerups.get("portal")).intValue() > 0) {
RedRobot r = (RedRobot)this.getObjects(RedRobot.class).get(0);
this.addObject(new Teleportal(((Integer)this.redpowerups.get("portal")).intValue()), r.getX(), r.getY());
}
if(((Integer)this.bluepowerups.get("portal")).intValue() > 0) {
BlueRobot b = (BlueRobot)this.getObjects(BlueRobot.class).get(0);
this.addObject(new Teleportal(((Integer)this.bluepowerups.get("portal")).intValue()), b.getX(), b.getY());
}
while(!this.getObjects(Ice.class).isEmpty()) {
this.removeObject((Actor)this.getObjects(Ice.class).get(0));
}
if(((Integer)this.redpowerups.get("nuke")).intValue() > 1) {
this.addObject(new Nukesplosion(), ((TopAirship)this.getObjects(TopAirship.class).get(1)).getX(), 210);
if(Title.sounds) {
Greenfoot.playSound("explosion.wav");
}
}
if(((Integer)this.bluepowerups.get("nuke")).intValue() > 1) {
this.addObject(new Nukesplosion(), ((TopAirship)this.getObjects(TopAirship.class).get(0)).getX(), 210);
if(Title.sounds) {
Greenfoot.playSound("explosion.wav");
}
}
if(((Integer)this.redpowerups.get("freeze")).intValue() > 0) {
this.addObject(new Ice(), ((BlueRobot)this.getObjects(BlueRobot.class).get(0)).getX(), ((BlueRobot)this.getObjects(BlueRobot.class).get(0)).getY());
if(this.rfsound && Title.sounds) {
Greenfoot.playSound("Freeze.wav");
this.rfsound = false;
}
} else {
this.rfsound = true;
}
if(((Integer)this.bluepowerups.get("freeze")).intValue() > 0) {
this.addObject(new Ice(), ((RedRobot)this.getObjects(RedRobot.class).get(0)).getX(), ((RedRobot)this.getObjects(RedRobot.class).get(0)).getY());
if(this.bfsound && Title.sounds) {
Greenfoot.playSound("Freeze.wav");
this.bfsound = false;
}
} else {
this.bfsound = true;
}
if(((Integer)this.redpowerups.get("recyclerush")).intValue() <= 0 && ((Integer)this.bluepowerups.get("recyclerush")).intValue() <= 0) {
this.rrcan = 0;
} else {
this.addObject(new RecycleCrate(((Integer)this.redpowerups.get("recyclerush")).intValue() == 1 || ((Integer)this.bluepowerups.get("recyclerush")).intValue() == 1), 628, 370 - this.rrcan * 60);
++this.rrcan;
}
}
public void stopped() {
((Timer)this.getObjects(Timer.class).get(0)).gamePaused();
}
}