-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExplosion.java
More file actions
64 lines (56 loc) · 1.28 KB
/
Explosion.java
File metadata and controls
64 lines (56 loc) · 1.28 KB
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
57
58
59
60
61
62
63
64
import java.awt.Graphics;
import java.awt.Image;
/**
* This class represents an explosion.
*
* @author John Kurlak (kurlak)
* Weston Thayer (weston5)
* Panhavorn Hok (onehok1)
* @version 12.07.09
*/
public class Explosion extends Sprite
{
private static final Image EXPLOSION1 = Utilities
.loadImage("explosion1.png");
private static final Image EXPLOSION2 = Utilities
.loadImage("explosion2.png");
private static final Image EXPLOSION3 = Utilities
.loadImage("explosion3.png");
private int iterator = 0;
/**
* This constructor creates a new explosion.
*
* @param x The starting x position of the explosion
* @param y The starting y position of the explosion
*/
public Explosion(int x, int y)
{
super(x, y, new Image[] { EXPLOSION1, EXPLOSION2, EXPLOSION3,
EXPLOSION2, EXPLOSION1 }, 0, 4);
}
/**
* This method draws the explosion on the screen.
*/
public void draw(Graphics g)
{
super.draw(g);
iterator++;
if (iterator == 2)
{
boolean iterated = super.iterate();
if (!iterated)
{
remove();
}
iterator = 0;
}
}
/**
* This method updates the position of the explosion.
*/
public void updatePosition()
{
offsetX(1);
offsetY(-1);
}
}