This commit is contained in:
Bilel Bghiel
2015-07-09 11:27:05 +02:00
parent 34f6d10532
commit 79cc140d2f
6 changed files with 86 additions and 54 deletions
+12 -11
View File
@@ -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; }
}
+11 -5
View File
@@ -4,29 +4,34 @@ import model.gameState.PlayState;
import java.awt.*;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.LinkedList;
public class PointAnimation extends DrawObject {
LinkedList<Point2D.Double> puntenPos = new LinkedList<>();
LinkedList<Integer> puntenGain = new LinkedList<>();
LinkedList<Integer> iterations = new LinkedList<>();
ArrayList<Point2D.Double> puntenPos = new ArrayList<>();
ArrayList<Integer> puntenGain = new ArrayList<>();
ArrayList<Integer> iterations = new ArrayList<>();
ArrayList<Color> colors = new ArrayList<>();
public static double LastPointIncrement = 0;
public PointAnimation() { }
public void enemyDied(Point2D.Double p) {
public void enemyDied(Point2D.Double p, Color c) {
puntenPos.add(new Point2D.Double(p.getX(), p.getY()));
puntenGain.add((int)LastPointIncrement);
iterations.add(0);
colors.add(c);
}
@Override
public void draw(Graphics2D g2) {
for (int x = 0; x < puntenPos.size(); x++) {
Color oldColor = g2.getColor();
g2.setColor(colors.get(x));
g2.drawString("" + puntenGain.get(x), (int) puntenPos.get(x).getX(), (int) puntenPos.get(x).getY());
g2.setColor(oldColor);
update(0);
}
}
@@ -42,6 +47,7 @@ public class PointAnimation extends DrawObject {
puntenPos.remove(x);
iterations.remove(x);
puntenGain.remove(x);
colors.remove(x);
}
}
}