-
Notifications
You must be signed in to change notification settings - Fork 0
/
Explosion.java
56 lines (45 loc) · 1.27 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
/**
* 爆発クラス
* @author mori
*
*/
public class Explosion extends Thread {
// 爆発イメージのサイズ
private static final int SIZE = 20;
// 爆発イメージ
private Image explosionImage;
// アニメーション用のカウンタ
private int count;
// 爆発の位置
private int x;
private int y;
public Explosion(int x, int y) {
this.x = x;
this.y = y;
count = 0;
// 爆発エフェクトのイメージを読み込む
ImageIcon icon = new ImageIcon(getClass()
.getResource("image/explosion.gif"));
explosionImage = icon.getImage();
start();
}
public void draw(Graphics g) {
g.drawImage(explosionImage, x, y, x + SIZE, y + SIZE, count * SIZE, 0, count * SIZE + SIZE, SIZE, null);
}
public void run() {
while (true) {
count++;
if (count == 15) {
return;
}
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}