Highscore + highscore bar added + life bar

This commit is contained in:
Remco
2015-05-28 14:48:29 +02:00
parent a7c52c04b6
commit 7263442ea3
3 changed files with 30 additions and 12 deletions
+4 -4
View File
@@ -12,14 +12,14 @@ import control.button.ButtonHandler;
public class GameModel implements ActionListener{
private GameView view;
private Timer update;
public static Color[] colors = {Color.MAGENTA,Color.RED,Color.GREEN,Color.YELLOW,Color.CYAN,Color.BLUE};
public static Color[] colors = {Color.MAGENTA,Color.RED,Color.GREEN,Color.YELLOW,Color.CYAN,Color.WHITE};
private GameStateManager gsm;
public GameModel(GameView view,GameStateManager gsm)
public GameModel(GameStateManager gsm)
{
this.view = view;
this.gsm = gsm;
update = new Timer(1000/30, this);
update.start();
+2 -3
View File
@@ -7,7 +7,6 @@ import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -44,7 +43,7 @@ public class PlayState extends GameState{
player = new Player(1280-1024+1024/2, 1024/2);
for(int i = 0; i < 8; i++){
Line2D line = area.getLine(i);
addEnemy(line, Color.BLUE, 200);
addEnemy(line, Color.RED, 200);
}
}
@@ -100,7 +99,7 @@ public class PlayState extends GameState{
//kijkt of de bullet die de enemy heeft gehit, ook dezelfde kleur heeft als de enemy, zoja verwijder de enemy
if(e.ColorHitMe(b)){
currentScore += 100;
currentScore += 1;
if(lifePoints < 100) {
lifePoints += 5;
}
+24 -5
View File
@@ -8,8 +8,9 @@ import model.gameState.PlayState;
public class InfoPanel {
public String totalHighscore = "XXXXXX";
private String totalLifePoints = "";
private String totalHighscore = "XXXXXX";
private int lifePercent;
private int upgradeScore = 0;
private int x, y;
public InfoPanel(int x, int y){
@@ -20,7 +21,16 @@ public class InfoPanel {
public void updateIPanel() {
totalHighscore = "Score: " + PlayState.currentScore;
totalLifePoints = "Hp: " + PlayState.lifePoints;
lifePercent =+ PlayState.lifePoints;
if(0 <= PlayState.currentScore && PlayState.currentScore <=100) {
upgradeScore = PlayState.currentScore;
}
if(PlayState.currentScore == 100) {
}
}
public void draw(Graphics2D g2){
@@ -28,9 +38,18 @@ public class InfoPanel {
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.drawString(totalHighscore, 25, 75);
g2.drawRect(25, 100, 200, 30);
g2.drawRect(25, 300, 200, 700);
g2.setColor(Color.GREEN);
g2.fillRect(25, 100, 2 * lifePercent, 30);
g2.setColor(Color.YELLOW);
g2.fillRect(25, 1000 - 7 * upgradeScore, 200, 0 + 7 * upgradeScore);
g2.setColor(Color.BLACK);
}