diff --git a/model/drawObjects/CoinAnimation.java b/model/drawObjects/CoinAnimation.java index 5bd4c4c..10a1a9a 100644 --- a/model/drawObjects/CoinAnimation.java +++ b/model/drawObjects/CoinAnimation.java @@ -52,7 +52,7 @@ public class CoinAnimation extends DrawObject { // Coin omlaag verschuiven doordat Y * loops omlaag gaat. // Per frame verschuift het balletje delta 10 op Y-as. 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()); } catch (ArithmeticException a) { a.printStackTrace(); } diff --git a/model/gameState/PlayState.java b/model/gameState/PlayState.java index 103aa80..f6b6bdc 100644 --- a/model/gameState/PlayState.java +++ b/model/gameState/PlayState.java @@ -5,6 +5,7 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.Stroke; import java.awt.geom.Ellipse2D; +import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.Iterator; @@ -36,7 +37,7 @@ public class PlayState extends GameState { public static int sizeOfEnemy = 40; public static int currentScore = 0; - public static int comboScore = 0; + public static int comboMulitplier = 1; public static int lastScoreChange = 0; public static int sinceScoreChanged = 75; public static double lifePoints = 100; @@ -62,9 +63,7 @@ public class PlayState extends GameState { @Override public void init() { init = true; - lifePoints = 100; currentScore = 0; - comboScore = 0; oldProgress = 0; enemies_hit = 0; @@ -121,7 +120,7 @@ public class PlayState extends GameState { lifePoints -= 5; lastScoreChange = -5; sinceScoreChanged = 1; - comboScore /= 2; + comboMulitplier = 1; enemies_missed++; } if(closedEnemy == null) @@ -137,13 +136,15 @@ public class PlayState extends GameState { infoPanel.updateIPanel(); - if(lifePoints <= 0) + if(lifePoints <= 0) { // STERF! + currentScore = 0; endGame(); + } - if(comboScore >= 100) { - comboScore = 0; - currentScore += 500; + if(comboMulitplier >= 20) { // '20' hit streak voor bonuspunten + comboMulitplier = 1; sinceScoreChanged = 1; + currentScore += 500; lastScoreChange = 500; } @@ -212,9 +213,10 @@ public class PlayState extends GameState { Enemy enemy = enemysInPath.next(); if (enemy.getDistanceFromStart() > Enemy.distanceToOctagon || enemy.getDistanceFromStart() > Enemy.distanceToOctagon + sizeOfEnemy) { if (e.getButton().getColor().equals(enemy.getColor())) { - currentScore += enemy.getDistanceFromStart() - Enemy.distanceToOctagon; - comboScore += 5; - lastScoreChange = 5; + currentScore += 5 * comboMulitplier; + lastScoreChange = 5 * comboMulitplier; + comboMulitplier ++; + area.enemyDied((Point2D.Double) enemy.getEnemy().getP1()); sinceScoreChanged = 1; lifePoints = Math.min(lifePoints+10, 100); area.setHitAreaColor(enemy.getColor()); @@ -227,12 +229,10 @@ public class PlayState extends GameState { } } } - player.setBeat(); - if(notHit) - { + if(notHit) { if(area.paths.get(player.getIndex()).getEnemysInPath().size() > 0) lifePoints -= 1.5; } diff --git a/model/objects/InfoPanel.java b/model/objects/InfoPanel.java index b5f183a..41bc81c 100644 --- a/model/objects/InfoPanel.java +++ b/model/objects/InfoPanel.java @@ -3,10 +3,12 @@ package model.objects; import image.Images; import java.awt.*; +import java.awt.geom.Point2D; import java.awt.image.VolatileImage; import model.SongHandler; import model.drawObjects.CoinAnimation; +import model.drawObjects.PointAnimation; import model.gameState.PlayState; public class InfoPanel { @@ -21,7 +23,7 @@ public class InfoPanel { private CoinAnimation coinAnimation = new CoinAnimation(125, 300); - + public InfoPanel(int x, int y, SongHandler sh){ this.x = x; this.y = y; @@ -32,13 +34,6 @@ public class InfoPanel { public void updateIPanel() { 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); 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); // Laatste punten in-/decrease tonen. - if (PlayState.sinceScoreChanged < 75 && PlayState.sinceScoreChanged != 0) { - g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(1 - (PlayState.sinceScoreChanged * 0.01)))); + if (PlayState.sinceScoreChanged < 60 && PlayState.sinceScoreChanged != 0) { + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(1 - (PlayState.sinceScoreChanged * 0.015)))); g2.setColor(Color.RED); - g2.drawString("+" + PlayState.lastScoreChange, 205, 40); + g2.drawString("+" + PlayState.lastScoreChange, 185, 40); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f)); } @@ -94,16 +89,16 @@ public class InfoPanel { coinAnimation.draw(g2); // Score pas updaten wanneer coin in zijn laatste draw loop zit if (coinAnimation.isLastLoop()) - tempComboScore = PlayState.comboScore; + tempComboScore = PlayState.currentScore; } else - tempComboScore = PlayState.comboScore; + tempComboScore = PlayState.currentScore; g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230); g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260); g2.drawString(time, 25, 290); 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(); infoPanel.createGraphics(); } @@ -111,7 +106,7 @@ public class InfoPanel { public void throwACoin() { coinAnimation.start(); // Teller weer op 1 zetten } - + public void draw(Graphics2D g2){ g2.drawImage(infoPanel, 0, 0, 256,1024,null); } diff --git a/model/objects/PlayArea.java b/model/objects/PlayArea.java index 31f4552..431a169 100644 --- a/model/objects/PlayArea.java +++ b/model/objects/PlayArea.java @@ -12,12 +12,14 @@ import java.awt.Stroke; import java.awt.Transparency; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; +import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.VolatileImage; import java.util.ArrayList; import java.util.List; import model.drawObjects.Enemy; +import model.drawObjects.PointAnimation; import model.gameState.PlayState; public class PlayArea { @@ -32,6 +34,8 @@ public class PlayArea { maxCount = 100, pathID = -1, oldPathId = pathID; + + private PointAnimation pointAnimation = new PointAnimation(); private Stroke stroke = new BasicStroke(5); private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024); @@ -109,6 +113,9 @@ public class PlayArea { generateBackground(); oldPathId = pathID; } + + pointAnimation.draw(g2); + } public Line2D getLine(int index){ @@ -172,4 +179,6 @@ public class PlayArea { g2.dispose(); background.createGraphics(); } + + public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p); } }