- Duidelijkere score (punten beloning * multiplier)
- Score animatie bij het balletje waar je punten mee scoort
This commit is contained in:
@@ -52,7 +52,7 @@ public class CoinAnimation extends DrawObject {
|
|||||||
// Coin omlaag verschuiven doordat Y * loops omlaag gaat.
|
// Coin omlaag verschuiven doordat Y * loops omlaag gaat.
|
||||||
// Per frame verschuift het balletje delta 10 op Y-as.
|
// Per frame verschuift het balletje delta 10 op Y-as.
|
||||||
try {
|
try {
|
||||||
coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + (1000 - 7 * PlayState.comboScore) / 20 * timerLoops,
|
coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + (1000 - 35 * PlayState.comboMulitplier) / 20 * timerLoops,
|
||||||
coinShape.getWidth(), coinShape.getHeight());
|
coinShape.getWidth(), coinShape.getHeight());
|
||||||
} catch (ArithmeticException a) { a.printStackTrace(); }
|
} catch (ArithmeticException a) { a.printStackTrace(); }
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ public class PlayState extends GameState {
|
|||||||
|
|
||||||
public static int sizeOfEnemy = 40;
|
public static int sizeOfEnemy = 40;
|
||||||
public static int currentScore = 0;
|
public static int currentScore = 0;
|
||||||
public static int comboScore = 0;
|
public static int comboMulitplier = 1;
|
||||||
public static int lastScoreChange = 0;
|
public static int lastScoreChange = 0;
|
||||||
public static int sinceScoreChanged = 75;
|
public static int sinceScoreChanged = 75;
|
||||||
public static double lifePoints = 100;
|
public static double lifePoints = 100;
|
||||||
@@ -62,9 +63,7 @@ public class PlayState extends GameState {
|
|||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
init = true;
|
init = true;
|
||||||
lifePoints = 100;
|
|
||||||
currentScore = 0;
|
currentScore = 0;
|
||||||
comboScore = 0;
|
|
||||||
oldProgress = 0;
|
oldProgress = 0;
|
||||||
|
|
||||||
enemies_hit = 0;
|
enemies_hit = 0;
|
||||||
@@ -121,7 +120,7 @@ public class PlayState extends GameState {
|
|||||||
lifePoints -= 5;
|
lifePoints -= 5;
|
||||||
lastScoreChange = -5;
|
lastScoreChange = -5;
|
||||||
sinceScoreChanged = 1;
|
sinceScoreChanged = 1;
|
||||||
comboScore /= 2;
|
comboMulitplier = 1;
|
||||||
enemies_missed++;
|
enemies_missed++;
|
||||||
}
|
}
|
||||||
if(closedEnemy == null)
|
if(closedEnemy == null)
|
||||||
@@ -137,13 +136,15 @@ public class PlayState extends GameState {
|
|||||||
|
|
||||||
infoPanel.updateIPanel();
|
infoPanel.updateIPanel();
|
||||||
|
|
||||||
if(lifePoints <= 0)
|
if(lifePoints <= 0) { // STERF!
|
||||||
|
currentScore = 0;
|
||||||
endGame();
|
endGame();
|
||||||
|
}
|
||||||
|
|
||||||
if(comboScore >= 100) {
|
if(comboMulitplier >= 20) { // '20' hit streak voor bonuspunten
|
||||||
comboScore = 0;
|
comboMulitplier = 1;
|
||||||
currentScore += 500;
|
|
||||||
sinceScoreChanged = 1;
|
sinceScoreChanged = 1;
|
||||||
|
currentScore += 500;
|
||||||
lastScoreChange = 500;
|
lastScoreChange = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,9 +213,10 @@ public class PlayState extends GameState {
|
|||||||
Enemy enemy = enemysInPath.next();
|
Enemy enemy = enemysInPath.next();
|
||||||
if (enemy.getDistanceFromStart() > Enemy.distanceToOctagon || enemy.getDistanceFromStart() > Enemy.distanceToOctagon + sizeOfEnemy) {
|
if (enemy.getDistanceFromStart() > Enemy.distanceToOctagon || enemy.getDistanceFromStart() > Enemy.distanceToOctagon + sizeOfEnemy) {
|
||||||
if (e.getButton().getColor().equals(enemy.getColor())) {
|
if (e.getButton().getColor().equals(enemy.getColor())) {
|
||||||
currentScore += enemy.getDistanceFromStart() - Enemy.distanceToOctagon;
|
currentScore += 5 * comboMulitplier;
|
||||||
comboScore += 5;
|
lastScoreChange = 5 * comboMulitplier;
|
||||||
lastScoreChange = 5;
|
comboMulitplier ++;
|
||||||
|
area.enemyDied((Point2D.Double) enemy.getEnemy().getP1());
|
||||||
sinceScoreChanged = 1;
|
sinceScoreChanged = 1;
|
||||||
lifePoints = Math.min(lifePoints+10, 100);
|
lifePoints = Math.min(lifePoints+10, 100);
|
||||||
area.setHitAreaColor(enemy.getColor());
|
area.setHitAreaColor(enemy.getColor());
|
||||||
@@ -227,12 +229,10 @@ public class PlayState extends GameState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
player.setBeat();
|
player.setBeat();
|
||||||
|
|
||||||
if(notHit)
|
if(notHit) {
|
||||||
{
|
|
||||||
if(area.paths.get(player.getIndex()).getEnemysInPath().size() > 0)
|
if(area.paths.get(player.getIndex()).getEnemysInPath().size() > 0)
|
||||||
lifePoints -= 1.5;
|
lifePoints -= 1.5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package model.objects;
|
|||||||
import image.Images;
|
import image.Images;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
|
|
||||||
import model.SongHandler;
|
import model.SongHandler;
|
||||||
import model.drawObjects.CoinAnimation;
|
import model.drawObjects.CoinAnimation;
|
||||||
|
import model.drawObjects.PointAnimation;
|
||||||
import model.gameState.PlayState;
|
import model.gameState.PlayState;
|
||||||
|
|
||||||
public class InfoPanel {
|
public class InfoPanel {
|
||||||
@@ -21,7 +23,7 @@ public class InfoPanel {
|
|||||||
|
|
||||||
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
|
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
|
||||||
|
|
||||||
|
|
||||||
public InfoPanel(int x, int y, SongHandler sh){
|
public InfoPanel(int x, int y, SongHandler sh){
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -32,13 +34,6 @@ public class InfoPanel {
|
|||||||
|
|
||||||
public void updateIPanel() {
|
public void updateIPanel() {
|
||||||
totalHighscore = "" + PlayState.currentScore;
|
totalHighscore = "" + PlayState.currentScore;
|
||||||
// time = "";
|
|
||||||
// long progress = (sh.getProgress() / 1000);
|
|
||||||
// time = progress%1000 + time;
|
|
||||||
// progress /= 1000;
|
|
||||||
// time = progress%1000 + ":" + time;
|
|
||||||
// progress /= 1000;
|
|
||||||
// time = progress + ":" + time;
|
|
||||||
|
|
||||||
long progress = (sh.getProgress() / 1000);
|
long progress = (sh.getProgress() / 1000);
|
||||||
String millis = ((progress) % 1000) + "".length() > 3 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000);
|
String millis = ((progress) % 1000) + "".length() > 3 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000);
|
||||||
@@ -70,10 +65,10 @@ public class InfoPanel {
|
|||||||
g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30);
|
g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30);
|
||||||
|
|
||||||
// Laatste punten in-/decrease tonen.
|
// Laatste punten in-/decrease tonen.
|
||||||
if (PlayState.sinceScoreChanged < 75 && PlayState.sinceScoreChanged != 0) {
|
if (PlayState.sinceScoreChanged < 60 && PlayState.sinceScoreChanged != 0) {
|
||||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(1 - (PlayState.sinceScoreChanged * 0.01))));
|
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(1 - (PlayState.sinceScoreChanged * 0.015))));
|
||||||
g2.setColor(Color.RED);
|
g2.setColor(Color.RED);
|
||||||
g2.drawString("+" + PlayState.lastScoreChange, 205, 40);
|
g2.drawString("+" + PlayState.lastScoreChange, 185, 40);
|
||||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
|
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,16 +89,16 @@ public class InfoPanel {
|
|||||||
coinAnimation.draw(g2);
|
coinAnimation.draw(g2);
|
||||||
// Score pas updaten wanneer coin in zijn laatste draw loop zit
|
// Score pas updaten wanneer coin in zijn laatste draw loop zit
|
||||||
if (coinAnimation.isLastLoop())
|
if (coinAnimation.isLastLoop())
|
||||||
tempComboScore = PlayState.comboScore;
|
tempComboScore = PlayState.currentScore;
|
||||||
} else
|
} else
|
||||||
tempComboScore = PlayState.comboScore;
|
tempComboScore = PlayState.currentScore;
|
||||||
|
|
||||||
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230);
|
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230);
|
||||||
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
|
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
|
||||||
g2.drawString(time, 25, 290);
|
g2.drawString(time, 25, 290);
|
||||||
|
|
||||||
g2.setColor(Color.YELLOW);
|
g2.setColor(Color.YELLOW);
|
||||||
g2.fillRect(25, 1000 - 7 * tempComboScore, 200, 7 * tempComboScore);
|
g2.fillRect(25, (int)(1000 - PlayState.comboMulitplier * 35), 200, 35 * ((int)PlayState.comboMulitplier));
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
infoPanel.createGraphics();
|
infoPanel.createGraphics();
|
||||||
}
|
}
|
||||||
@@ -111,7 +106,7 @@ public class InfoPanel {
|
|||||||
public void throwACoin() {
|
public void throwACoin() {
|
||||||
coinAnimation.start(); // Teller weer op 1 zetten
|
coinAnimation.start(); // Teller weer op 1 zetten
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2){
|
public void draw(Graphics2D g2){
|
||||||
g2.drawImage(infoPanel, 0, 0, 256,1024,null);
|
g2.drawImage(infoPanel, 0, 0, 256,1024,null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import java.awt.Stroke;
|
|||||||
import java.awt.Transparency;
|
import java.awt.Transparency;
|
||||||
import java.awt.geom.GeneralPath;
|
import java.awt.geom.GeneralPath;
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import model.drawObjects.Enemy;
|
import model.drawObjects.Enemy;
|
||||||
|
import model.drawObjects.PointAnimation;
|
||||||
import model.gameState.PlayState;
|
import model.gameState.PlayState;
|
||||||
|
|
||||||
public class PlayArea {
|
public class PlayArea {
|
||||||
@@ -32,6 +34,8 @@ public class PlayArea {
|
|||||||
maxCount = 100,
|
maxCount = 100,
|
||||||
pathID = -1,
|
pathID = -1,
|
||||||
oldPathId = pathID;
|
oldPathId = pathID;
|
||||||
|
|
||||||
|
private PointAnimation pointAnimation = new PointAnimation();
|
||||||
private Stroke stroke = new BasicStroke(5);
|
private Stroke stroke = new BasicStroke(5);
|
||||||
|
|
||||||
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
|
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
|
||||||
@@ -109,6 +113,9 @@ public class PlayArea {
|
|||||||
generateBackground();
|
generateBackground();
|
||||||
oldPathId = pathID;
|
oldPathId = pathID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pointAnimation.draw(g2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Line2D getLine(int index){
|
public Line2D getLine(int index){
|
||||||
@@ -172,4 +179,6 @@ public class PlayArea {
|
|||||||
g2.dispose();
|
g2.dispose();
|
||||||
background.createGraphics();
|
background.createGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user