Merge branch 'master' of /home/stud/timmeja/SpaceScooter
This commit is contained in:
commit
25f3114c9f
@ -13,6 +13,8 @@ import de.teamteamteam.spacescooter.utility.GameConfig;
|
|||||||
public class Player extends ShootingEntity implements KeyboardListener {
|
public class Player extends ShootingEntity implements KeyboardListener {
|
||||||
|
|
||||||
private Keyboard keyboard = null;
|
private Keyboard keyboard = null;
|
||||||
|
private double healthPercent = 0;
|
||||||
|
private double shieldPercent = 0;
|
||||||
|
|
||||||
public Player(int x, int y) {
|
public Player(int x, int y) {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
@ -35,6 +37,12 @@ public class Player extends ShootingEntity implements KeyboardListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if (StaticValue.HealthPoints != 0) {
|
||||||
|
this.healthPercent = ((double) this.getHealthPoints() / (double) StaticValue.HealthPoints) * 100;
|
||||||
|
}
|
||||||
|
if (StaticValue.ShieldPoints != 0) {
|
||||||
|
this.shieldPercent = ((double) this.getShieldPoints() / (double) StaticValue.ShieldPoints) * 100;
|
||||||
|
}
|
||||||
if(this.canMove()) {
|
if(this.canMove()) {
|
||||||
super.update();
|
super.update();
|
||||||
int offset = 3;
|
int offset = 3;
|
||||||
@ -109,4 +117,12 @@ public class Player extends ShootingEntity implements KeyboardListener {
|
|||||||
|
|
||||||
public void keyTyped(KeyEvent e) {}
|
public void keyTyped(KeyEvent e) {}
|
||||||
|
|
||||||
|
public int getHealthPercent() {
|
||||||
|
return (int) this.healthPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShieldPercent() {
|
||||||
|
return (int) this.shieldPercent;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class HealthBar extends Entity {
|
|||||||
public void paint(Graphics2D g) {
|
public void paint(Graphics2D g) {
|
||||||
Player player = GameScreen.getPlayer();
|
Player player = GameScreen.getPlayer();
|
||||||
try {
|
try {
|
||||||
this.health = player.getHealthPoints();
|
this.health = player.getHealthPercent();
|
||||||
this.healthwidth = ((this.width) * this.health) / 100;
|
this.healthwidth = ((this.width) * this.health) / 100;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
this.healthwidth = 0;
|
this.healthwidth = 0;
|
||||||
|
@ -22,7 +22,7 @@ public class ShieldBar extends Entity {
|
|||||||
public void paint(Graphics2D g) {
|
public void paint(Graphics2D g) {
|
||||||
Player player = GameScreen.getPlayer();
|
Player player = GameScreen.getPlayer();
|
||||||
try {
|
try {
|
||||||
this.shield = player.getShieldPoints();
|
this.shield = player.getShieldPercent();
|
||||||
this.shieldwidth = ((this.width) * this.shield) / 100;
|
this.shieldwidth = ((this.width) * this.shield) / 100;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
this.shieldwidth = 0;
|
this.shieldwidth = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user