Author SHA1 Message Date
Bilel Bghiel 6f48c07a55 Merge branch 'develop' of https://github.com/ProjectGroepA2/Arcade into infoPanel 2015-07-09 13:55:14 +02:00
Bilel Bghiel a282f2186c ok 2015-07-09 13:36:27 +02:00
Bilel Bghiel 79cc140d2f - 2015-07-09 11:27:05 +02:00
Daniel 5679b20616 Changed infopanel 2015-07-09 11:24:42 +02:00
Bilel Bghiel 34f6d10532 - coin ani redesign
- Score balk
- point animation units memorise color
- Song title scalen in info Panel
2015-07-08 18:10:01 +02:00
Daniel bad1f459aa error gefixed als er geen highscore is 2015-07-08 13:05:19 +02:00
Daniel b4c0995ce8 Info panel af gemaakt 2015-07-07 12:41:55 +02:00
Bilel Bghiel 811f778553 - Quick Fixes 2015-07-06 15:25:09 +02:00
Bilel Bghiel 03dae66c71 - Title Stage boot animation
- Coin Animation readded
- Point Animation added
2015-07-01 13:08:39 +02:00
7 changed files with 300 additions and 98 deletions
+75
View File
@@ -0,0 +1,75 @@
package model.drawObjects;
import model.gameState.PlayState;
import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
/**
* 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.
*
* * Init (startX, startY): Punt waar de animatie begint met vallen
*
* start(): aanroepen om te starten
* *
* *
**/
public class CoinAnimation extends DrawObject {
private Ellipse2D coinShape;
private Point2D.Double coinSetPoint;
// Hoevaak de timer gelopen heeft
private static int timerLoops = 0;
private double reach = 0;
private Color color;
public CoinAnimation(int startX, int startY) {
coinSetPoint = new Point2D.Double(startX + 180, startY - 10);
coinShape = new Ellipse2D.Double(startX + 180, startY - 10, 20, 20);
}
// 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(color); // GEEL
g2.draw(coinShape); // MUNTJE TEKENEN
g2.fill(coinShape);
g2.setColor(oldColor);
}
// 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() - reach * timerLoops, coinSetPoint.getY(),
coinShape.getWidth(), coinShape.getHeight());
} catch (ArithmeticException a) { a.printStackTrace(); }
timerLoops++;
}
// Zijn we al begonnen/klaar?
public boolean areWeDoneYet() {
if ((timerLoops > 14 || timerLoops == 0) || (reach * timerLoops > 180)) {
timerLoops = 0;
return true;
}
return false;
}
// Zitten we in de laatste loop?
public boolean isLastLoop() { return (timerLoops == 13) ? true : false; }
}
+54
View File
@@ -0,0 +1,54 @@
package model.drawObjects;
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 {
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, 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);
}
}
@Override
public void update(float factor) {
for (int x = 0; x < puntenPos.size(); x++) {
puntenPos.get(x).setLocation(puntenPos.get(x).getX(), puntenPos.get(x).getY() - 3);
iterations.set(x, iterations.get(x) + 1);
if (iterations.get(x) > 100) {
puntenPos.remove(x);
iterations.remove(x);
puntenGain.remove(x);
colors.remove(x);
}
}
}
}
+9 -1
View File
@@ -4,12 +4,15 @@ import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Iterator;
import model.SongHandler;
import model.drawObjects.Enemy;
import model.drawObjects.Player;
import model.drawObjects.PointAnimation;
import model.objects.InfoPanel;
import model.objects.Path;
import model.objects.PlayArea;
@@ -74,6 +77,8 @@ public class PlayState extends GameState {
if(h != null)
infoPanel.init(h.getScore());
infoPanel.init(sql.getHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance()).getScore());
for(Path p : area.paths)
{
p.getEnemysInPath().clear();
@@ -217,12 +222,15 @@ public class PlayState extends GameState {
Enemy enemy = enemysInPath.next();
if (enemy.getDistanceFromStart() > Enemy.distanceToOctagon || enemy.getDistanceFromStart() > Enemy.distanceToOctagon + sizeOfEnemy) {
if (e.getButton().getColor().equals(enemy.getColor())) {
currentScore += enemy.getDistanceFromStart() - Enemy.distanceToOctagon;
PointAnimation.LastPointIncrement = (int)(enemy.getDistanceFromStart() - Enemy.distanceToOctagon);
currentScore += PointAnimation.LastPointIncrement;
comboScore += 5;
lifePoints = Math.min(lifePoints+10, 100);
area.setHitAreaColor(enemy.getColor());
area.enemyDied((Point2D.Double) enemy.getEnemy().getP1());
area.hit();
enemies_hit++;
infoPanel.throwACoin(enemy.getColor()); // Coin Animatie starten bij hit
enemysInPath.remove();
notHit = false;
break;
+2 -4
View File
@@ -50,12 +50,10 @@ public class PreGameState extends GameState {
@Override
public void draw(Graphics2D g2) {
g2.drawImage(screenshot,0,0,1280,1024,null);
Font textFont = new Font("OCR A Extended", Font.BOLD,grootte);
g2.setFont(textFont);
g2.setFont(new Font("OCR A Extended", Font.BOLD,grootte));
g2.setStroke(s);
g2.setColor(Color.RED);
String text = "" + index;
int width = g2.getFontMetrics().stringWidth(text);
g2.drawString(text, 325, 400);
if(index < 1){
text = "GO!!!";
@@ -66,7 +64,7 @@ public class PreGameState extends GameState {
else{
text = "READY";
}
width = g2.getFontMetrics().stringWidth(text);
int width = g2.getFontMetrics().stringWidth(text);
g2.drawString(text, (256+1024/2)-width/2, 600);
}
+75 -56
View File
@@ -21,50 +21,58 @@ import data.io.SQLConnector;
public class TitleState extends GameState {
BufferedImage pressStart = Images.getImage(ImageType.pressstart);
BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
BufferedImage kast = Images.getImage(ImageType.kast);
VolatileImage background;
Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
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));
private BufferedImage pressStart = Images.getImage(ImageType.pressstart),
colorStrike = Images.getImage(ImageType.colorstrike),
kast = Images.getImage(ImageType.kast);
private VolatileImage background;
int index = 0;
int varx = 0;
int frame;
private Font textFont = new Font("OCR A Extended", Font.BOLD, 15),
textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
private GradientPaint gp = new GradientPaint(300, 0, new Color(0, 0, 1, 0.6f), 980, 1024, new Color(0, 0, 1, 0.2f));
private int index = 0,
varx = 0,
indexKast = 0,
xKast = 0,
frame;
int indexKast = 0;
int xKast=0;
public TitleState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
super(gsm, sh, sql);
if(!sh.isPlaying())
sh.play();
createBackground();
}
@Override
public void init() {
if(!sh.isPlaying())
sh.play();
sh.play();
}
@Override
public void update(float factor) {
frame+=5;
indexKast++;
frame++;
indexKast++;
}
@Override
public void draw(Graphics2D g2) {
// Scherm beelt wat kleurrijke rectangles op het scherm.
if (frame > 0) {
g2.drawImage(background, 0, 0, 1280, 1024, null);
createBackground();
}
if (frame > 160) {
// Code die de arcadekast en 'Press Start' toont.
int image_x = ((frame / 6) % 6) * 49;
g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640 - 122, 512, 245, 130, null);
xKast = indexKast / 10;
xKast %= 4;
g2.drawImage(kast.getSubimage(xKast * 300, 0, 300, 400), 100, 300, 300, 400, null);
}
g2.drawImage(background, 0, 0, 1280, 1024, null);
int image_x = ((frame / 6) % 6) * 49;
g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640-122, 512, 245, 130, null);
xKast = indexKast/10;
xKast%=4;
//g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 640-122,650,300,400,null);
@@ -75,11 +83,10 @@ public class TitleState extends GameState {
public void buttonPressed(ButtonEvent e) {
switch (e.getButton().getButtonID()) {
case 0:
gsm.setState(State.MENU_STATE);
break;
case 0:
gsm.setState(State.MENU_STATE);
break;
}
}
@Override
@@ -94,35 +101,47 @@ public class TitleState extends GameState {
public void createBackground() {
background = Images.initVolatileImage(1280, 1024, Transparency.OPAQUE);
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));
g2.fillRect(0, 0, 100, 1024);
g2.fillRect(1180, 0, 100, 1024);
if (frame > 0) {
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHints(rh);
}
if (frame > 20) {
g2.setColor(new Color(1, 1, 1, 0.3f));
g2.fillRect(0, 0, 1280, 1024);
}
if (frame > 40) {
g2.setColor(new Color(0, 1, 0, 0.7f));
g2.fillRect(0, 0, 100, 1024);
g2.fillRect(1180, 0, 100, 1024);
}
if (frame > 60) {
g2.setColor(new Color(1, 1, 0, 0.7f));
g2.fillRect(100, 0, 100, 1024);
g2.fillRect(1080, 0, 100, 1024);
}
if (frame > 80) {
g2.setColor(new Color(1, 0, 0, 0.7f));
g2.fillRect(200, 0, 100, 1024);
g2.fillRect(980, 0, 100, 1024);
}
if (frame > 100) {
g2.setPaint(gp);
g2.fillRect(300, 0, 680, 1024);
}
if (frame > 120) {
g2.setFont(textFont);
g2.setColor(Color.WHITE);
g2.drawString("©2015 Team Hamtaro", 550, 1012);
}
if (frame > 140) {
g2.setColor(Color.RED);
g2.setFont(textFont2);
g2.drawString("Color", 385, 212);
g2.drawString("Strike", 390, 342);
g2.dispose();
}
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();
}
+73 -37
View File
@@ -9,11 +9,13 @@ import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Transparency;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.VolatileImage;
import control.button.ButtonHandler;
import main.Window;
import model.SongHandler;
import model.drawObjects.CoinAnimation;
import model.gameState.PlayState;
public class InfoPanel {
@@ -23,7 +25,10 @@ public class InfoPanel {
private VolatileImage infoPanel;
private SongHandler sh;
private String time;
private int highscore;
private int highscore = 0,
tempComboScore = 0;
private CoinAnimation coinAnimation = new CoinAnimation(27, 820);
public InfoPanel(int x, int y, SongHandler sh){
this.x = x;
@@ -59,75 +64,106 @@ public class InfoPanel {
GradientPaint gp = new GradientPaint(0, 0, new Color(245,245,245), 256, 1024, Color.WHITE);
g2.setPaint(gp);
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
g2.setFont(scoreFont);
g2.setColor(Color.GREEN);
g2.fillRect(25, 900, (int)(2 * PlayState.lifePoints), 30);
g2.fillRect(25, 900, (int) (2 * PlayState.lifePoints), 30);
g2.setColor(Color.YELLOW);
g2.fillRect(25, 950, (int)(2 * PlayState.comboScore), 30);
g2.fillRect(25, 950, (2 * PlayState.comboScore), 30);
g2.setColor(Color.BLACK);
g2.drawRect(25, 900, 200, 30);
g2.drawRect(25, 950, 200, 30);
g2.drawString("Score: " + totalHighscore, 25, 75);
g2.drawString(sh.getCurrentSong().getTitle(), 25, 125);
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 175);
g2.drawString("" + highscore, 25, 225);
g2.drawString(time, 25, 275);
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 35);
g2.setFont(scoreFont);
g2.drawString("Score: ", 25, 75);
Font scoreFont2 = new Font("OCR A Extended", Font.BOLD, 25);
g2.setFont(scoreFont2);
int charsPerLine = 10;
int linesNeeded = sh.getCurrentSong().getTitle().length() / charsPerLine + 1; // 9 chars per regel
g2.drawString("Title: ", 25, 225 - (linesNeeded) * 30);
g2.drawString("Time: ", 25, 265);
g2.drawString("Best: ", 25, 345);
Font scoreFont3 = new Font("OCR A Extended", Font.BOLD, 35);
g2.setFont(scoreFont3);
g2.drawString("" + totalHighscore, 25, 105);
// Aanpassen zodat hele titel zichtbaar is in infoP
for (int count = 0; count < linesNeeded; count++)
if (sh.getCurrentSong().getTitle().length() == count * charsPerLine + charsPerLine - 1)
g2.drawString( sh.getCurrentSong().getTitle().substring(count * charsPerLine,
count * charsPerLine + charsPerLine - 1),
25,
235 - (linesNeeded - count) * 30);
else
g2.drawString( sh.getCurrentSong().getTitle().substring(count * charsPerLine,
sh.getCurrentSong().getTitle().length()),
25,
235 - (linesNeeded - 1 - count) * 30);
/* g2.drawString(sh.getCurrentSong().getTitle(), 25, 215);*/
g2.drawString(time, 25, 295);
g2.drawString("" + highscore, 25, 375);
if(!Window.ON_RASP){
int width,height;
width = g2.getFontMetrics().stringWidth("");
height = g2.getFontMetrics().getHeight();
Ellipse2D oval1 = new Ellipse2D.Double(15, 700, 50, 50);
Ellipse2D oval1 = new Ellipse2D.Double(25, 650, 50, 50);
g2.setColor(ButtonHandler.getButton(1).getColor());
g2.fill(oval1);
Ellipse2D oval2 = new Ellipse2D.Double(75, 700, 50, 50);
Ellipse2D oval2 = new Ellipse2D.Double(85, 650, 50, 50);
g2.setColor(ButtonHandler.getButton(2).getColor());
g2.fill(oval2);
Ellipse2D oval3 = new Ellipse2D.Double(135, 700, 50, 50);
Ellipse2D oval3 = new Ellipse2D.Double(145, 650, 50, 50);
g2.setColor(ButtonHandler.getButton(3).getColor());
g2.fill(oval3);
Ellipse2D oval4 = new Ellipse2D.Double(40, 760, 50, 50);
Ellipse2D oval4 = new Ellipse2D.Double(50, 710, 50, 50);
g2.setColor(ButtonHandler.getButton(4).getColor());
g2.fill(oval4);
Ellipse2D oval5 = new Ellipse2D.Double(100, 760, 50, 50);
Ellipse2D oval5 = new Ellipse2D.Double(110, 710, 50, 50);
g2.setColor(ButtonHandler.getButton(5).getColor());
g2.fill(oval5);
Ellipse2D oval6 = new Ellipse2D.Double(160, 760, 50, 50);
Ellipse2D oval6 = new Ellipse2D.Double(170, 710, 50, 50);
g2.setColor(ButtonHandler.getButton(6).getColor());
g2.fill(oval6);
}
// g2.setColor(Color.BLACK);
// width = g2.getFontMetrics().stringWidth(""+i);
// g2.drawString(""+i, (int)oval.getCenterX()-width/2,(int)oval.getMaxY()+height);
if (!coinAnimation.areWeDoneYet()) {
coinAnimation.draw(g2);
// Score pas updaten wanneer coin in zijn laatste draw loop zit
if (coinAnimation.isLastLoop())
tempComboScore = PlayState.comboScore;
} else
tempComboScore = PlayState.comboScore;
//* Score/Coin animation bar
g2.setColor(Color.BLACK);
g2.fillRect(25, 800, 2 * tempComboScore, 40);
g2.drawRect(25, 800, 200, 40);
g2.dispose();
infoPanel.createGraphics();
}
public void draw(Graphics2D g2){
g2.drawImage(infoPanel, 0, 0, 256,1024,null);
g2.drawImage(infoPanel, 0, 0, 256, 1024,null);
}
public static String getTotalHighscore()
{
return totalHighscore;
}
public void throwACoin(Color c) {
coinAnimation.start(c); // Teller weer op 1 zetten
}
}
+12
View File
@@ -9,14 +9,17 @@ import java.awt.Polygon;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.Transparency;
import java.awt.*;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.VolatileImage;
import java.util.ArrayList;
import java.util.List;
import model.drawObjects.Enemy;
import model.drawObjects.PointAnimation;
import model.gameState.PlayState;
public class PlayArea {
@@ -29,6 +32,7 @@ public class PlayArea {
private boolean hit = false;
private int count = 0,maxCount = 100,pathID = -1;
private Stroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
private PointAnimation pointAnimation = new PointAnimation();
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
@@ -121,6 +125,12 @@ public class PlayArea {
g2.setColor(pathColor);
g2.draw(paths.get(pathID));
}
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 40);
Font tempFont = g2.getFont();
g2.setFont(scoreFont);
pointAnimation.draw(g2);
g2.setFont(tempFont);
}
public Line2D getLine(int index){
@@ -157,4 +167,6 @@ public class PlayArea {
this.pathID = pathID;
this.pathColor = pathColor;
}
public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p, hitAreaColor); }
}