Draw a small white border around the HealthBar.
This commit is contained in:
parent
1f78309a98
commit
50a898aeef
|
@ -11,36 +11,27 @@ import de.teamteamteam.spacescooter.screen.Screen;
|
||||||
public class HealthBar extends Entity {
|
public class HealthBar extends Entity {
|
||||||
|
|
||||||
private int width = 100;
|
private int width = 100;
|
||||||
private int height = 20;
|
private int height = 24;
|
||||||
private Graphics2D g;
|
|
||||||
|
|
||||||
public HealthBar(int x, int y) {
|
public HealthBar(int x, int y) {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paint(Graphics2D g) {
|
public void paint(Graphics2D g) {
|
||||||
|
Player player = null;
|
||||||
ConcurrentIterator<Entity> entities = Screen.currentScreen.getEntityIterator();
|
ConcurrentIterator<Entity> entities = Screen.currentScreen.getEntityIterator();
|
||||||
while(entities.hasNext()) {
|
while(entities.hasNext()) {
|
||||||
Entity e = entities.next();
|
Entity e = entities.next();
|
||||||
if(e instanceof Player){
|
if(e instanceof Player){
|
||||||
this.width = ((Player) e).getHealthPoints();
|
player = ((Player) e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Graphics2D grpahic = (Graphics2D) g;
|
g.setColor(Color.GREEN);
|
||||||
this.g = grpahic;
|
g.fillRect(this.getX(), this.getY(), (this.width / 100) * player.getHealthPoints(), this.height);
|
||||||
this.g.setColor(new Color(0,255,0));
|
g.setColor(Color.WHITE);
|
||||||
this.g.fillRect(this.getX(), this.getY(), this.width, this.height);
|
g.drawRect(this.getX(), this.getY(), this.width, this.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {}
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue