1 package code
.kalter
.longflight
.game
.explosion
;
3 import code
.kalter
.longflight
.Animation
;
4 import code
.kalter
.longflight
.Loader
;
5 import java
.io
.IOException
;
6 import javax
.microedition
.lcdui
.Graphics
;
7 import javax
.microedition
.lcdui
.Image
;
10 * Не приблежаться, рванёт!
14 public class Explosion
implements Detonator
{
16 public static Explosion
createExplosion(String path
) throws IOException
{
17 final Loader loader
= Loader
.getInstance();
18 final Image image
= loader
.getImage(path
);
19 return createExplosion(image
);
22 public static Explosion
createExplosion(Image image
) {
23 return new Explosion(image
);
26 private static final int MAX
= 5;
27 private final Animation
[] boom
;
28 private final int[] positionX
;
29 private final int[] positionY
;
31 // каждый кадр должен быть квадратным
32 private Explosion(Image explosion
) {
33 boom
= new Animation
[MAX
];
34 positionX
= new int[MAX
];
35 positionY
= new int[MAX
];
36 for (int i
= 0; i
< MAX
; i
++) {
37 boom
[i
] = Animation
.createAnimation(explosion
,
38 explosion
.getHeight(), 80);
42 public void deactivateAll() {
43 for (int i
= 0; i
< boom
.length
; i
++) {
48 public void activate(int x
, int y
) {
49 for (int i
= 0; i
< boom
.length
; i
++) {
50 if (!boom
[i
].getState()) {
52 this.positionX
[i
] = x
;
53 this.positionY
[i
] = y
;
59 public void paint(Graphics graphics
) {
60 for (int i
= 0; i
< boom
.length
; i
++) {
61 boom
[i
].paint(graphics
, positionX
[i
], positionY
[i
]);
65 public void update() {
66 for (int i
= 0; i
< boom
.length
; i
++) {