-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtraLife.java
More file actions
52 lines (50 loc) · 1.56 KB
/
ExtraLife.java
File metadata and controls
52 lines (50 loc) · 1.56 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
import java.awt.Image;
/**
* This class represents an extra life that the player can pick up.
*
* @author John Kurlak (kurlak)
* Weston Thayer (weston5)
* Panhavorn Hok (onehok1)
* @version 12.07.09
*/
public class ExtraLife extends PowerUp implements Collidable
{
/**
* This constructor creates a new extra life power-up.
*
* @param x The starting x position of the extra life
* @param yBlock The starting y block of the extra life
* @param yOffset The starting y offset into the block for the extra
* life
* @param spriteImages The images representing the sprite
* @param firstFrame The index of the first frame to be drawn during
* animation
* @param lastFrame The index of the last frame to be drawn during
* animation
* @param xPath The parameterized x function for the extra life's
* path
* @param yPath The parameterized y function for the extra life's
* path
*/
public ExtraLife(int x, int yBlock, int yOffset, Image[] spriteImages, int
firstFrame, int lastFrame, String xPath, String yPath)
{
super(x, yBlock, yOffset, spriteImages, firstFrame, lastFrame, xPath,
yPath);
}
/**
* This method handles what happens when the extra life power-up collides
* with something else.
*/
public void collision(Sprite object)
{
if (object instanceof Player)
{
Player player = (Player) object;
player.giveLife();
super.remove();
Sound laserSound = new Sound("item-pickup.wav");
laserSound.playOnce();
}
}
}