-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrenade_Thrown.pde
37 lines (33 loc) · 981 Bytes
/
Grenade_Thrown.pde
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
// thrown grenade projectile - refer to Gas_Thrown for documentation.
class Grenade_Thrown extends Projectile {
boolean moving = true;
int fuse = 0;
Timer myTimer = new Timer(5);
Grenade_Thrown(PVector position, float velocity, float theta, float xEnd, float yEnd) {
super(position, velocity, theta, xEnd, yEnd);
}
void update() {
myTimer.update();
if (myPosition.x > myXEnd - 30 && myPosition.x < myXEnd + 30 && myPosition.y > myYEnd - 30 && myPosition.y < myYEnd + 30) {
moving = false;
}
if (moving) {
myPosition.x += myVelocity.x;
myPosition.y += myVelocity.y;
}
if (myTimer.isDone()) {
explosions.add(new Explosion(myPosition.x, myPosition.y, 100));
toRemove = true;
}
if (visible) {
pushMatrix();
imageMode(CENTER);
translate(myPosition.x, myPosition.y);
if (moving) {
rotate(frameCount/5);
}
image(grenade, 0, 0);
popMatrix();
}
}
}