- Bugs en verbeteringen
This commit is contained in:
@@ -8,12 +8,16 @@ import java.awt.geom.Point2D;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Bilel on 4-6-2015.
|
|
||||||
*
|
|
||||||
* CoinAnimation klasse: Weergeeft een balletje (resembleerd een muntje) dat omlaag valt.
|
* CoinAnimation klasse: Weergeeft een balletje (resembleerd een muntje) dat omlaag valt.
|
||||||
* Je hoeft alleen achter elkaar de paint(Graphics2D) methode aan te roepen, deze roep automatisch een 'reposition' aan,
|
* Je hoeft alleen achter elkaar de paint(Graphics2D) methode aan te roepen, deze roep automatisch een 'reposition' aan,
|
||||||
* waardoor je het balletje alleen snel achter elkaar hoeft te repainten.
|
* waardoor je het balletje alleen snel achter elkaar hoeft te repainten.
|
||||||
*/
|
*
|
||||||
|
* * Init (startX, startY): Punt waar de animatie begint met vallen
|
||||||
|
*
|
||||||
|
* start(): aanroepen om te starten
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
**/
|
||||||
public class CoinAnimation extends DrawObject {
|
public class CoinAnimation extends DrawObject {
|
||||||
|
|
||||||
private Ellipse2D coinShape;
|
private Ellipse2D coinShape;
|
||||||
@@ -33,26 +37,20 @@ public class CoinAnimation extends DrawObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
|
|
||||||
update(timerLoops); // UPDATE
|
update(timerLoops); // UPDATE
|
||||||
g2.setColor(new Color(255, 255, 0)); // GEEL
|
g2.setColor(new Color(255, 255, 0)); // GEEL
|
||||||
g2.draw(coinShape); // MUNTJE TEKENEN
|
g2.draw(coinShape); // MUNTJE TEKENEN
|
||||||
g2.fill(coinShape);
|
g2.fill(coinShape);
|
||||||
|
System.out.println("ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wordt na elke paint aangeroepen
|
// Wordt na elke paint aangeroepen
|
||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
|
|
||||||
// Alleen tekenen wanner de animatie ingesteld is om te tekenen (zie: areWeDoneYet()), anders doei.
|
|
||||||
if (areWeDoneYet()) {
|
|
||||||
System.out.println("Call initCoin(int startX, startY) first!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 - 35 * PlayState.comboMulitplier) / 20 * timerLoops,
|
coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + (1000 - 35 * PlayState.comboMulitplier) / 25 * timerLoops,
|
||||||
coinShape.getWidth(), coinShape.getHeight());
|
coinShape.getWidth(), coinShape.getHeight());
|
||||||
} catch (ArithmeticException a) { a.printStackTrace(); }
|
} catch (ArithmeticException a) { a.printStackTrace(); }
|
||||||
|
|
||||||
@@ -61,7 +59,7 @@ public class CoinAnimation extends DrawObject {
|
|||||||
|
|
||||||
// Zijn we al begonnen/klaar?
|
// Zijn we al begonnen/klaar?
|
||||||
public boolean areWeDoneYet() {
|
public boolean areWeDoneYet() {
|
||||||
if (timerLoops > 19 || timerLoops == 0) {
|
if (timerLoops > 24 || timerLoops == 0) {
|
||||||
timerLoops = 0;
|
timerLoops = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -69,6 +67,6 @@ public class CoinAnimation extends DrawObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Zitten we in de laatste loop?
|
// Zitten we in de laatste loop?
|
||||||
public boolean isLastLoop() { return (timerLoops == 49) ? true : false; }
|
public boolean isLastLoop() { return (timerLoops == 24) ? true : false; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,20 +8,17 @@ import java.util.HashMap;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Bilel on 20-6-2015.
|
|
||||||
*/
|
|
||||||
public class PointAnimation extends DrawObject {
|
public class PointAnimation extends DrawObject {
|
||||||
|
|
||||||
LinkedList<Point2D.Double> puntenPos = new LinkedList<>();
|
LinkedList<Point2D.Double> puntenPos = new LinkedList<>();
|
||||||
LinkedList<Integer> puntenGain = new LinkedList<>();
|
LinkedList<Integer> puntenGain = new LinkedList<>();
|
||||||
LinkedList<Integer> iterations = new LinkedList<>();
|
LinkedList<Integer> iterations = new LinkedList<>();
|
||||||
|
|
||||||
public PointAnimation() { }
|
public PointAnimation() { }
|
||||||
|
|
||||||
public void enemyDied(Point2D.Double p) {
|
public void enemyDied(Point2D.Double p) {
|
||||||
puntenPos.add(new Point2D.Double(p.getX(), p.getY()));
|
puntenPos.add(new Point2D.Double(p.getX(), p.getY()));
|
||||||
puntenGain.add(new Integer(PlayState.lastScoreChange));
|
puntenGain.add(PlayState.lastScoreChange);
|
||||||
iterations.add(0);
|
iterations.add(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ public abstract class GameState {
|
|||||||
this.gsm = gsm;
|
this.gsm = gsm;
|
||||||
this.sh = sh;
|
this.sh = sh;
|
||||||
this.sql = sql;
|
this.sql = sql;
|
||||||
|
|
||||||
int kleurButton1 = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void init();
|
public abstract void init();
|
||||||
|
|||||||
@@ -37,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 comboMulitplier = 1;
|
public static int comboMulitplier = 0;
|
||||||
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;
|
||||||
@@ -120,7 +120,7 @@ public class PlayState extends GameState {
|
|||||||
lastScoreChange = -5;
|
lastScoreChange = -5;
|
||||||
lifePoints -= lastScoreChange;
|
lifePoints -= lastScoreChange;
|
||||||
sinceScoreChanged = 1;
|
sinceScoreChanged = 1;
|
||||||
comboMulitplier = 1;
|
comboMulitplier = 0;
|
||||||
enemies_missed++;
|
enemies_missed++;
|
||||||
}
|
}
|
||||||
if(closedEnemy == null)
|
if(closedEnemy == null)
|
||||||
@@ -133,15 +133,13 @@ public class PlayState extends GameState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lifePoints -= 0.002 * factor;
|
lifePoints -= 0.002 * factor;
|
||||||
|
|
||||||
infoPanel.updateIPanel();
|
infoPanel.updateIPanel();
|
||||||
|
|
||||||
if(lifePoints <= 0) { // STERF!
|
if(lifePoints <= 0) // STERF!
|
||||||
currentScore = 0; comboMulitplier = 0; endGame();
|
endGame();
|
||||||
}
|
|
||||||
|
|
||||||
if(comboMulitplier >= 20) { // '20' hit streak voor bonuspunten
|
if(comboMulitplier >= 20) { // '20' hit streak voor bonuspunten
|
||||||
comboMulitplier = 1;
|
comboMulitplier = 0;
|
||||||
sinceScoreChanged = 1;
|
sinceScoreChanged = 1;
|
||||||
lastScoreChange = 500;
|
lastScoreChange = 500;
|
||||||
currentScore += lastScoreChange;
|
currentScore += lastScoreChange;
|
||||||
@@ -160,6 +158,8 @@ public class PlayState extends GameState {
|
|||||||
sql.addPlaydata(sh.getCurrentSong(), sh.getCurrentSongInstance(), sh.getProgress()/1000, enemies_missed, enemies_hit, buttons_pressed, joystick_moved);
|
sql.addPlaydata(sh.getCurrentSong(), sh.getCurrentSongInstance(), sh.getProgress()/1000, enemies_missed, enemies_hit, buttons_pressed, joystick_moved);
|
||||||
sh.getCurrentSongInstance().played();
|
sh.getCurrentSongInstance().played();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
comboMulitplier = 0;
|
||||||
|
|
||||||
if(currentScore == 0)
|
if(currentScore == 0)
|
||||||
gsm.setState(State.MENU_STATE);
|
gsm.setState(State.MENU_STATE);
|
||||||
@@ -212,9 +212,9 @@ 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())) {
|
||||||
|
comboMulitplier++;
|
||||||
lastScoreChange = 5 * comboMulitplier;
|
lastScoreChange = 5 * comboMulitplier;
|
||||||
currentScore += lastScoreChange;
|
currentScore += lastScoreChange;
|
||||||
comboMulitplier++;
|
|
||||||
sinceScoreChanged = 1;
|
sinceScoreChanged = 1;
|
||||||
area.enemyDied((Point2D.Double) enemy.getEnemy().getP1());
|
area.enemyDied((Point2D.Double) enemy.getEnemy().getP1());
|
||||||
lifePoints = Math.min(lifePoints+10, 100);
|
lifePoints = Math.min(lifePoints+10, 100);
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public class TitleState extends GameState {
|
|||||||
|
|
||||||
private int index = 0,
|
private int index = 0,
|
||||||
varx = 0,
|
varx = 0,
|
||||||
frame,
|
|
||||||
indexKast = 0,
|
indexKast = 0,
|
||||||
xKast = 0;
|
xKast = 0,
|
||||||
|
frame;
|
||||||
|
|
||||||
public TitleState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
|
public TitleState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
|
||||||
super(gsm, sh, sql);
|
super(gsm, sh, sql);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class InfoPanel {
|
|||||||
private SongHandler sh;
|
private SongHandler sh;
|
||||||
private String time;
|
private String time;
|
||||||
|
|
||||||
private int tempComboScore;
|
private int tempComboMulitplier;
|
||||||
|
|
||||||
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
|
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
|
||||||
|
|
||||||
@@ -89,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.currentScore;
|
tempComboMulitplier = PlayState.comboMulitplier;
|
||||||
} else
|
} else
|
||||||
tempComboScore = PlayState.currentScore;
|
tempComboMulitplier = PlayState.comboMulitplier;
|
||||||
|
|
||||||
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, (int)(1000 - PlayState.comboMulitplier * 35), 200, 35 * ((int)PlayState.comboMulitplier));
|
g2.fillRect(25, 1000 - tempComboMulitplier * 35, 200, 35 * tempComboMulitplier);
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
infoPanel.createGraphics();
|
infoPanel.createGraphics();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ public class PlayArea {
|
|||||||
|
|
||||||
return paths.get(index);
|
return paths.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setHitAreaColor(Color color) {
|
public void setHitAreaColor(Color color) {
|
||||||
hitAreaColor = color;
|
hitAreaColor = color;
|
||||||
|
|||||||
Reference in New Issue
Block a user