From 91a6ae718d2c888319ea3eb6d44bdc68e5d1decd Mon Sep 17 00:00:00 2001 From: Bilel Bghiel Date: Fri, 19 Jun 2015 13:36:17 +0200 Subject: [PATCH] betere animatie en een fix --- model/drawObjects/CoinAnimation.java | 20 +++++++++++++------- model/objects/InfoPanel.java | 8 +------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/model/drawObjects/CoinAnimation.java b/model/drawObjects/CoinAnimation.java index 21183c8..bc4a577 100644 --- a/model/drawObjects/CoinAnimation.java +++ b/model/drawObjects/CoinAnimation.java @@ -1,8 +1,11 @@ package model.drawObjects; +import model.gameState.PlayState; + import java.awt.*; import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; +import java.io.IOException; /** * Created by Bilel on 4-6-2015. @@ -17,22 +20,22 @@ public class CoinAnimation extends DrawObject { private Point2D.Double coinSetPoint; // Hoevaak de timer gelopen heeft - private static int timerLoops = 0; + private static int timerLoops = 0; 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, startY); + coinShape = new Ellipse2D.Double(startX, startY, 20, 20); } // Start public void start() { - timerLoops = 1; + timerLoops = 1; } public void draw(Graphics2D g2) { 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.fill(coinShape); @@ -49,8 +52,11 @@ public class CoinAnimation extends DrawObject { // Coin omlaag verschuiven doordat Y * loops omlaag gaat. // Per frame verschuift het balletje delta 10 op Y-as. - coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + 10 * timerLoops, - coinShape.getWidth(), coinShape.getHeight()); + try { + coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + (1000 - 7 * PlayState.comboScore) / 50 * timerLoops, + coinShape.getWidth(), coinShape.getHeight()); + } catch (ArithmeticException a) { a.printStackTrace(); } + timerLoops++; } diff --git a/model/objects/InfoPanel.java b/model/objects/InfoPanel.java index 8faa3c9..8e16157 100644 --- a/model/objects/InfoPanel.java +++ b/model/objects/InfoPanel.java @@ -44,8 +44,7 @@ public class InfoPanel { // time = progress + ":" + time; long progress = (sh.getProgress() / 1000); - - String millis = (((progress) % 1000) + "").length() > 2 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000); + String millis = ((progress) % 1000) + "".length() > 3 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000); 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); time = minute + ":" + second + ":" + millis; @@ -93,11 +92,6 @@ public class InfoPanel { g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230); g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260); 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.fillRect(25, 1000 - 7 * tempComboScore, 200, 7 * tempComboScore);