-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grenade.pde
32 lines (26 loc) · 860 Bytes
/
Grenade.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
class Grenade extends PhysicsEntity {
color colorTint;
color colorTintGlow;
PImage image;
float imageSize;
Grenade(PVector origin, PVector velocity, color colorTint) {
super(origin, velocity, 6.0, 12.0, 0.33, 0.0);
this.zIndex = 1100;
this.colorTint = color(hue(colorTint), 1.0, 0.4);
this.colorTintGlow = color(hue(colorTint), 0.5, 1.0);
this.image = loadImage("textures/grenade.png");
this.imageSize = 16;
}
void OnCollision(Collision collision) {
new Explosion(collision.position, 96.0, 28.0, SOUND_GRENADE_EXPLODE).spawn();
this.delete();
}
void OnDraw() {
long ticksAlive = this.getTicksAlive();
tint((ticksAlive / 8) % 3 == 0 ? colorTint : colorTintGlow);
imageMode(CENTER);
translate(this.origin.x, this.origin.y);
rotate(radians(ticksAlive * 6));
image(this.image, 0, 0, this.imageSize, this.imageSize);
}
}