betere animatie en een fix

This commit is contained in:
Bilel Bghiel
2015-06-19 13:36:17 +02:00
parent 5b1138936d
commit 91a6ae718d
2 changed files with 14 additions and 14 deletions
+13 -7
View File
@@ -1,8 +1,11 @@
package model.drawObjects; package model.drawObjects;
import model.gameState.PlayState;
import java.awt.*; import java.awt.*;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.io.IOException;
/** /**
* Created by Bilel on 4-6-2015. * Created by Bilel on 4-6-2015.
@@ -17,22 +20,22 @@ public class CoinAnimation extends DrawObject {
private Point2D.Double coinSetPoint; private Point2D.Double coinSetPoint;
// Hoevaak de timer gelopen heeft // Hoevaak de timer gelopen heeft
private static int timerLoops = 0; private static int timerLoops = 0;
public CoinAnimation(int startX, int startY) { public CoinAnimation(int startX, int startY) {
coinSetPoint = new Point2D.Double(startX, startY); coinSetPoint = new Point2D.Double(startX, startY);
coinShape = new Ellipse2D.Double(startX, startY, 20, 20); coinShape = new Ellipse2D.Double(startX, startY, 20, 20);
} }
// Start // Start
public void start() { public void start() {
timerLoops = 1; timerLoops = 1;
} }
public void draw(Graphics2D g2) { public void draw(Graphics2D g2) {
update(timerLoops); // UPDATE update(timerLoops); // UPDATE
g2.setColor(new Color(255, 255, 0, (255 - timerLoops * 5))); // 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);
@@ -49,8 +52,11 @@ 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.
coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + 10 * timerLoops, try {
coinShape.getWidth(), coinShape.getHeight()); coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + (1000 - 7 * PlayState.comboScore) / 50 * timerLoops,
coinShape.getWidth(), coinShape.getHeight());
} catch (ArithmeticException a) { a.printStackTrace(); }
timerLoops++; timerLoops++;
} }
+1 -7
View File
@@ -44,8 +44,7 @@ public class InfoPanel {
// time = progress + ":" + time; // 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() > 2 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000);
String second = ((progress / 1000) % 60 + "").length() <= 1 ? "0" +((progress / 1000) % 60) : "" + ((progress / 1000) % 60); String second = ((progress / 1000) % 60 + "").length() <= 1 ? "0" +((progress / 1000) % 60) : "" + ((progress / 1000) % 60);
String minute = ((progress / (1000 * 60)) % 60 + "").length() <= 1 ? "0" +((progress / (1000 * 60)) % 60) : "" + ((progress / (1000 * 60)) % 60); String minute = ((progress / (1000 * 60)) % 60 + "").length() <= 1 ? "0" +((progress / (1000 * 60)) % 60) : "" + ((progress / (1000 * 60)) % 60);
time = minute + ":" + second + ":" + millis; time = minute + ":" + second + ":" + millis;
@@ -93,11 +92,6 @@ public class InfoPanel {
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);
// GradientPaint gp = new GradientPaint(300, 0, new Color(200,200,255), 256, 1024, Color.WHITE);
// g2.setPaint(gp);
// g2.fillRect(x, y, 256, 1024);
g2.setColor(Color.BLACK); g2.setColor(Color.BLACK);
g2.fillRect(25, 1000 - 7 * tempComboScore, 200, 7 * tempComboScore); g2.fillRect(25, 1000 - 7 * tempComboScore, 200, 7 * tempComboScore);