-
Notifications
You must be signed in to change notification settings - Fork 2
/
Lives.java
30 lines (28 loc) · 849 Bytes
/
Lives.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Lives here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Lives extends Actor
{
private GreenfootImage full = new GreenfootImage("/lives/heartfull.png");
private GreenfootImage half = new GreenfootImage("/lives/hearthalf.png");
private GreenfootImage container;
public Lives(){
}
public void updateLives(int lives){
int x = 13;
int y = 3;
container = new GreenfootImage("/lives/livescontainer.png");
for(int i = 0 ; i < lives/2 ; i++){
container.drawImage(full, x , y);
x += 25;
}
if(lives%2 == 1){
container.drawImage(half, x, y);
}
setImage(container);
}
}