highscore added
This commit is contained in:
@@ -32,6 +32,8 @@ public class PlayState extends GameState{
|
||||
private Iterator<Enemy> enemyIterator;
|
||||
private Iterator<Bullet> bulletIterator;
|
||||
|
||||
public static int currentScore = 0;
|
||||
public static int lifePoints = 100;
|
||||
|
||||
public PlayState(GameStateManager gsm) {
|
||||
super(gsm);
|
||||
@@ -76,6 +78,11 @@ public class PlayState extends GameState{
|
||||
e.update();
|
||||
//als de enemy de octagon raakt verwijder hem
|
||||
if(area.octagon.intersects(e.getCircle().getBounds2D())){
|
||||
lifePoints -= 5;
|
||||
|
||||
if(lifePoints < 10){
|
||||
lifePoints += 10; //Dit is voor te testen.
|
||||
}
|
||||
enemyIterator.remove();
|
||||
}
|
||||
|
||||
@@ -87,17 +94,23 @@ public class PlayState extends GameState{
|
||||
Bullet b = bulletIterator.next();
|
||||
|
||||
//kijkt of de enemy een bullet tegen komt, zoja verwijder de bullet, zoniet update de enemy.
|
||||
if(e.bulletHitMe(b)){
|
||||
if(e.bulletHitMe(b)){
|
||||
bulletIterator.remove();
|
||||
|
||||
//kijkt of de bullet die de enemy heeft gehit, ook dezelfde kleur heeft als de enemy, zoja verwijder de enemy
|
||||
if(e.ColorHitMe(b)){
|
||||
if(e.ColorHitMe(b)){
|
||||
|
||||
currentScore += 100;
|
||||
if(lifePoints < 100) {
|
||||
lifePoints += 5;
|
||||
}
|
||||
enemyIterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
infoPanel.updateIPanel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,37 @@
|
||||
package model.objects;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
public class InfoPanel {
|
||||
import model.gameState.PlayState;
|
||||
|
||||
public class InfoPanel {
|
||||
|
||||
public String totalHighscore = "XXXXXX";
|
||||
private String totalLifePoints = "";
|
||||
private int x, y;
|
||||
|
||||
public InfoPanel(int x, int y){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
updateIPanel();
|
||||
}
|
||||
|
||||
public void updateIPanel() {
|
||||
totalHighscore = "Score: " + PlayState.currentScore;
|
||||
totalLifePoints = "Hp: " + PlayState.lifePoints;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2){
|
||||
g2.fillRect(x, y, 256, 1024);
|
||||
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
|
||||
g2.setFont(scoreFont);
|
||||
g2.setColor(Color.ORANGE);
|
||||
g2.drawString(totalHighscore, 25, 150);
|
||||
g2.drawString(totalLifePoints, 25, 190);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user