-
This commit is contained in:
@@ -23,22 +23,26 @@ public class CoinAnimation extends DrawObject {
|
||||
private Point2D.Double coinSetPoint;
|
||||
|
||||
// Hoevaak de timer gelopen heeft
|
||||
private static int timerLoops = 0;
|
||||
private static int timerLoops = 0;
|
||||
private double reach = 0;
|
||||
private Color color;
|
||||
|
||||
public CoinAnimation(int startX, int startY) {
|
||||
coinSetPoint = new Point2D.Double(startX, startY);
|
||||
coinShape = new Ellipse2D.Double(startX, startY, 20, 20);
|
||||
coinSetPoint = new Point2D.Double(startX + 180, startY - 10);
|
||||
coinShape = new Ellipse2D.Double(startX + 180, startY - 10, 20, 20);
|
||||
}
|
||||
|
||||
// Start
|
||||
public void start() {
|
||||
public void start(Color c) {
|
||||
timerLoops = 1;
|
||||
reach = (180 - PlayState.comboScore * 2) / 14; // 'Eindbestemming' van het muntje
|
||||
color = c;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2) {
|
||||
Color oldColor = g2.getColor();
|
||||
update(timerLoops); // UPDATE
|
||||
g2.setColor(new Color(255, 255, 0)); // GEEL
|
||||
g2.setColor(color); // GEEL
|
||||
g2.draw(coinShape); // MUNTJE TEKENEN
|
||||
g2.fill(coinShape);
|
||||
g2.setColor(oldColor);
|
||||
@@ -46,14 +50,11 @@ public class CoinAnimation extends DrawObject {
|
||||
|
||||
// Wordt na elke paint aangeroepen
|
||||
public void update(float factor) {
|
||||
|
||||
// Coin omlaag verschuiven doordat Y * loops omlaag gaat.
|
||||
// Per frame verschuift het balletje delta 10 op Y-as.
|
||||
try {
|
||||
coinShape.setFrame(coinSetPoint.getX() * timerLoops * 10, coinSetPoint.getY() * timerLoops,
|
||||
coinShape.setFrame(coinSetPoint.getX() - reach * timerLoops, coinSetPoint.getY(),
|
||||
coinShape.getWidth(), coinShape.getHeight());
|
||||
/* coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + (1000 - 35 * PlayState.comboScore) / 25 * timerLoops,
|
||||
coinShape.getWidth(), coinShape.getHeight());*/
|
||||
} catch (ArithmeticException a) { a.printStackTrace(); }
|
||||
|
||||
timerLoops++;
|
||||
@@ -61,7 +62,7 @@ public class CoinAnimation extends DrawObject {
|
||||
|
||||
// Zijn we al begonnen/klaar?
|
||||
public boolean areWeDoneYet() {
|
||||
if (timerLoops > 24 || timerLoops == 0) {
|
||||
if ((timerLoops > 14 || timerLoops == 0) || (reach * timerLoops > 180)) {
|
||||
timerLoops = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -69,6 +70,6 @@ public class CoinAnimation extends DrawObject {
|
||||
}
|
||||
|
||||
// Zitten we in de laatste loop?
|
||||
public boolean isLastLoop() { return (timerLoops == 24) ? true : false; }
|
||||
public boolean isLastLoop() { return (timerLoops == 13) ? true : false; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user