-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExplosion.java
35 lines (32 loc) · 868 Bytes
/
Explosion.java
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
import java.awt.Color;
import java.awt.Graphics;
public class Explosion extends MovingObject{
int duration;
long time0;
@Override
void move(int k) {
}
public Explosion(int x, int y,int width, int height,int speed, Color c, long time0){
super(x, y,width,height, speed, c);
this.duration = 100;
this.time0=time0;
}
boolean over() {
long timeNow = System.currentTimeMillis();
long time = timeNow - time0;
if (time < 0 || time > duration) {
return true;
}
return false;
}
void paint(Graphics g){
g.setColor(c);
int w= width/2;
int h= height/2;
g.fillArc(x-w, y-h, width, height, 0, 360);
w = width / 6;
h = height/ 6;
g.setColor(Color.YELLOW);
g.fillArc(x-w, y-h, 2*w, 2*h, 0, 360);
}
}