- Scorebalk kleur krijgt geen Alpha meer mee
- Scorebalk renderde niet opnieuw wanneer speler score verliest. - Boot Animatie toegevoegd. - Nog wat kleine verbeteringen.
This commit is contained in:
@@ -6,6 +6,10 @@ import java.awt.geom.Point2D;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Bilel on 4-6-2015.
|
* Created by Bilel on 4-6-2015.
|
||||||
|
*
|
||||||
|
* 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,
|
||||||
|
* waardoor je het balletje alleen snel achter elkaar hoeft te repainten.
|
||||||
*/
|
*/
|
||||||
public class CoinAnimation extends DrawObject {
|
public class CoinAnimation extends DrawObject {
|
||||||
|
|
||||||
@@ -27,41 +31,39 @@ public class CoinAnimation extends DrawObject {
|
|||||||
|
|
||||||
public void draw(Graphics2D g2) {
|
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, (255 - timerLoops * 5))); // GEEL
|
||||||
g2.draw(coinShape); // MUNTJE TEKENEN
|
g2.draw(coinShape); // MUNTJE TEKENEN
|
||||||
g2.fill(coinShape);
|
g2.fill(coinShape);
|
||||||
update(timerLoops); // UPDATE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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()) {
|
if (areWeDoneYet()) {
|
||||||
System.out.println("Call initCoin(int startX, startY) first!");
|
System.out.println("Call initCoin(int startX, startY) first!");
|
||||||
return;
|
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.
|
||||||
coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + 10 * timerLoops,
|
coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + 10 * timerLoops,
|
||||||
coinShape.getWidth(), coinShape.getHeight());
|
coinShape.getWidth(), coinShape.getHeight());
|
||||||
|
|
||||||
timerLoops++;
|
timerLoops++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zijn we al begonnen/klaar?
|
// Zijn we al begonnen/klaar?
|
||||||
public boolean areWeDoneYet() {
|
public boolean areWeDoneYet() {
|
||||||
if (timerLoops > 50 || timerLoops == 0) {
|
if (timerLoops > 49 || timerLoops == 0) {
|
||||||
timerLoops = 0;
|
timerLoops = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLastLoop() {
|
// Zitten we in de laatste loop?
|
||||||
if (timerLoops == 49)
|
public boolean isLastLoop() { return (timerLoops == 49) ? true : false; }
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -181,12 +181,11 @@ public class PlayState extends GameState {
|
|||||||
area.hit();
|
area.hit();
|
||||||
enemysInPath.remove();
|
enemysInPath.remove();
|
||||||
notHit = false;
|
notHit = false;
|
||||||
infoPanel.throwACoin();
|
infoPanel.throwACoin(); // Coin Animatie starten bij hit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
player.setBeat();
|
player.setBeat();
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import java.awt.GradientPaint;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.Transparency;
|
import java.awt.Transparency;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
|
|
||||||
@@ -18,7 +20,9 @@ import control.GameStateManager.State;
|
|||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
import control.joystick.JoystickEvent;
|
import control.joystick.JoystickEvent;
|
||||||
|
|
||||||
public class TitleState extends GameState {
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class TitleState extends GameState implements ActionListener {
|
||||||
|
|
||||||
BufferedImage pressStart = Images.getImage(ImageType.pressstart);
|
BufferedImage pressStart = Images.getImage(ImageType.pressstart);
|
||||||
BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
|
BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
|
||||||
@@ -28,18 +32,21 @@ public class TitleState extends GameState {
|
|||||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
|
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
|
||||||
GradientPaint gp = new GradientPaint(300, 0, new Color(0, 0, 1, 0.6f), 980, 1024, new Color(0, 0, 1, 0.2f));
|
GradientPaint gp = new GradientPaint(300, 0, new Color(0, 0, 1, 0.6f), 980, 1024, new Color(0, 0, 1, 0.2f));
|
||||||
|
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int varx = 0;
|
int varx = 0;
|
||||||
int frame;
|
int frame;
|
||||||
|
|
||||||
|
private Timer timer;
|
||||||
|
|
||||||
|
int showInLoops = 1;
|
||||||
|
|
||||||
int indexKast = 0;
|
int indexKast = 0;
|
||||||
int xKast=0;
|
int xKast=0;
|
||||||
|
|
||||||
public TitleState(GameStateManager gsm, SongHandler sh){
|
public TitleState(GameStateManager gsm, SongHandler sh){
|
||||||
super(gsm, sh);
|
super(gsm, sh);
|
||||||
createBackground();
|
// Logica zit in ActionListener (dus actionPerformed())
|
||||||
|
(timer = new Timer(1000/3, this)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,23 +56,26 @@ public class TitleState extends GameState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
|
|
||||||
frame++;
|
frame++;
|
||||||
indexKast++;
|
indexKast++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
// Scherm beelt wat kleurrijke rectangles op het scherm.
|
||||||
int image_x = ((frame / 6) % 6) * 49;
|
if (showInLoops > 0) {
|
||||||
g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640-122, 512, 245, 130, null);
|
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||||
|
createBackground();
|
||||||
|
}
|
||||||
|
if (showInLoops > 18) {
|
||||||
xKast = indexKast/10;
|
// Code die de arcadekast en 'Press Start' toont.
|
||||||
xKast%=4;
|
int image_x = ((frame / 6) % 6) * 49;
|
||||||
//g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 640-122,650,300,400,null);
|
g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640 - 122, 512, 245, 130, null);
|
||||||
g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 100,300,300,400,null);
|
|
||||||
|
xKast = indexKast / 10;
|
||||||
|
xKast %= 4;
|
||||||
|
g2.drawImage(kast.getSubimage(xKast * 300, 0, 300, 400), 100, 300, 300, 400, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,36 +101,58 @@ public class TitleState extends GameState {
|
|||||||
public void createBackground() {
|
public void createBackground() {
|
||||||
background = Images.initVolatileImage(1280, 1024, Transparency.OPAQUE);
|
background = Images.initVolatileImage(1280, 1024, Transparency.OPAQUE);
|
||||||
Graphics2D g2 = background.createGraphics();
|
Graphics2D g2 = background.createGraphics();
|
||||||
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
g2.setRenderingHints(rh);
|
|
||||||
g2.setColor(new Color(1, 1, 1, 0.3f));
|
|
||||||
g2.fillRect(0, 0, 1280, 1024);
|
|
||||||
|
|
||||||
g2.setColor(new Color(0, 1, 0, 0.7f));
|
if (showInLoops > 0) {
|
||||||
g2.fillRect(0, 0, 100, 1024);
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
g2.fillRect(1180, 0, 100, 1024);
|
g2.setRenderingHints(rh);
|
||||||
|
}
|
||||||
|
if (showInLoops > 2) {
|
||||||
|
g2.setColor(new Color(1, 1, 1, 0.3f));
|
||||||
|
g2.fillRect(0, 0, 1280, 1024);
|
||||||
|
}
|
||||||
|
if (showInLoops > 4) {
|
||||||
|
g2.setColor(new Color(0, 1, 0, 0.7f));
|
||||||
|
g2.fillRect(0, 0, 100, 1024);
|
||||||
|
g2.fillRect(1180, 0, 100, 1024);
|
||||||
|
}
|
||||||
|
if (showInLoops > 6) {
|
||||||
|
g2.setColor(new Color(1, 1, 0, 0.7f));
|
||||||
|
g2.fillRect(100, 0, 100, 1024);
|
||||||
|
g2.fillRect(1080, 0, 100, 1024);
|
||||||
|
}
|
||||||
|
if (showInLoops > 8) {
|
||||||
|
g2.setColor(new Color(1, 0, 0, 0.7f));
|
||||||
|
g2.fillRect(200, 0, 100, 1024);
|
||||||
|
g2.fillRect(980, 0, 100, 1024);
|
||||||
|
}
|
||||||
|
if (showInLoops > 12) {
|
||||||
|
g2.setPaint(gp);
|
||||||
|
g2.fillRect(300, 0, 680, 1024);
|
||||||
|
}
|
||||||
|
if (showInLoops > 14) {
|
||||||
|
g2.setFont(textFont);
|
||||||
|
g2.setColor(Color.WHITE);
|
||||||
|
g2.drawString("©2015 Team Hamtaro", 550, 1012);
|
||||||
|
}
|
||||||
|
if (showInLoops > 16) {
|
||||||
|
g2.setColor(Color.RED);
|
||||||
|
g2.setFont(textFont2);
|
||||||
|
g2.drawString("Color", 385, 212);
|
||||||
|
g2.drawString("Strike", 390, 342);
|
||||||
|
g2.dispose();
|
||||||
|
}
|
||||||
|
if (showInLoops > 18) {
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
g2.setColor(new Color(1, 1, 0, 0.7f));
|
|
||||||
g2.fillRect(100, 0, 100, 1024);
|
|
||||||
g2.fillRect(1080, 0, 100, 1024);
|
|
||||||
|
|
||||||
g2.setColor(new Color(1, 0, 0, 0.7f));
|
|
||||||
g2.fillRect(200, 0, 100, 1024);
|
|
||||||
g2.fillRect(980, 0, 100, 1024);
|
|
||||||
|
|
||||||
g2.setPaint(gp);
|
|
||||||
g2.fillRect(300, 0, 680, 1024);
|
|
||||||
|
|
||||||
g2.setFont(textFont);
|
|
||||||
g2.setColor(Color.WHITE);
|
|
||||||
g2.drawString("©2015 Team Hamtaro", 550, 1012);
|
|
||||||
|
|
||||||
g2.setColor(Color.RED);
|
|
||||||
g2.setFont(textFont2);
|
|
||||||
g2.drawString("Color", 385, 212);
|
|
||||||
g2.drawString("Strike", 390, 342);
|
|
||||||
g2.dispose();
|
|
||||||
background.createGraphics();
|
background.createGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
createBackground();
|
||||||
|
showInLoops++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,13 +84,14 @@ public class InfoPanel {
|
|||||||
|
|
||||||
if (!coinAnimation.areWeDoneYet()) {
|
if (!coinAnimation.areWeDoneYet()) {
|
||||||
coinAnimation.draw(g2);
|
coinAnimation.draw(g2);
|
||||||
|
// Score pas updaten wanneer coin klaar is met afspelen
|
||||||
if (coinAnimation.isLastLoop())
|
if (coinAnimation.isLastLoop())
|
||||||
tempComboScore = PlayState.comboScore;
|
tempComboScore = PlayState.comboScore;
|
||||||
}
|
} else
|
||||||
|
tempComboScore = PlayState.comboScore;
|
||||||
|
|
||||||
|
g2.setColor(Color.YELLOW);
|
||||||
g2.fillRect(25, 1000 - 7 * tempComboScore, 200, 7 * tempComboScore);
|
g2.fillRect(25, 1000 - 7 * tempComboScore, 200, 7 * tempComboScore);
|
||||||
g2.setColor(Color.YELLOW);
|
|
||||||
|
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
infoPanel.createGraphics();
|
infoPanel.createGraphics();
|
||||||
|
|||||||
Reference in New Issue
Block a user