Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f48c07a55 | ||
|
|
a282f2186c | ||
|
|
79cc140d2f | ||
|
|
34f6d10532 | ||
|
|
bad1f459aa | ||
|
|
b4c0995ce8 | ||
|
|
811f778553 | ||
|
|
03dae66c71 |
@@ -67,8 +67,6 @@ public class SongInstance {
|
|||||||
|
|
||||||
public long getEndTime()
|
public long getEndTime()
|
||||||
{
|
{
|
||||||
if(objects.size() == 0)
|
|
||||||
return 0;
|
|
||||||
return objects.get(objects.size()-1).getTime();
|
return objects.get(objects.size()-1).getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import model.SongHandler;
|
||||||
import model.gameState.EndState;
|
import model.gameState.EndState;
|
||||||
import model.gameState.GameState;
|
import model.gameState.GameState;
|
||||||
import model.gameState.HelpState;
|
import model.gameState.HelpState;
|
||||||
@@ -47,7 +48,7 @@ public class GameStateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setState(State st) {
|
public void setState(State st) {
|
||||||
if (st.ordinal() > 0 && ( !(currentState instanceof TitleState) || !(currentState instanceof EndState) ))
|
if (st.ordinal() > 0 && !(currentState instanceof TitleState))
|
||||||
currentState.stopAudio();
|
currentState.stopAudio();
|
||||||
|
|
||||||
currentState = gamestates.get(st.ordinal());
|
currentState = gamestates.get(st.ordinal());
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class Button {
|
|||||||
|
|
||||||
private void setLed()
|
private void setLed()
|
||||||
{
|
{
|
||||||
if(Window.ON_ARCADE)
|
if(Window.ON_RASP)
|
||||||
{
|
{
|
||||||
ntw.setLed(ledID, color.getGreen(), color.getRed(), color.getBlue());
|
ntw.setLed(ledID, color.getGreen(), color.getRed(), color.getBlue());
|
||||||
ntw.show();
|
ntw.show();
|
||||||
|
|||||||
@@ -7,7 +7,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import main.Window;
|
import main.Window;
|
||||||
import model.GameModel;
|
|
||||||
|
import com.pi4j.io.gpio.GpioController;
|
||||||
|
import com.pi4j.io.gpio.GpioFactory;
|
||||||
|
import com.pi4j.io.gpio.GpioPinDigitalInput;
|
||||||
|
import com.pi4j.io.gpio.PinState;
|
||||||
|
import com.pi4j.io.gpio.RaspiPin;
|
||||||
|
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
|
||||||
|
import com.pi4j.io.gpio.event.GpioPinListenerDigital;
|
||||||
|
|
||||||
import control.NetworkHandler;
|
import control.NetworkHandler;
|
||||||
|
|
||||||
public class ButtonHandler implements KeyListener{
|
public class ButtonHandler implements KeyListener{
|
||||||
@@ -23,6 +31,38 @@ public class ButtonHandler implements KeyListener{
|
|||||||
listeners = new ArrayList<ButtonListener>();
|
listeners = new ArrayList<ButtonListener>();
|
||||||
buttons = new ArrayList<Button>();
|
buttons = new ArrayList<Button>();
|
||||||
|
|
||||||
|
// if (Window.ON_RASP)
|
||||||
|
// addGpioListeners();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addGpioListeners(){
|
||||||
|
ArrayList<GpioPinDigitalInput> inputpins = new ArrayList<GpioPinDigitalInput>();
|
||||||
|
final GpioController gpio = GpioFactory.getInstance();
|
||||||
|
|
||||||
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, "1")); //button 1 to 6 + start button
|
||||||
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_03, "2"));
|
||||||
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_13, "3"));
|
||||||
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_14, "4"));
|
||||||
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_00, "5"));
|
||||||
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_12, "6"));
|
||||||
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_06, "0"));
|
||||||
|
|
||||||
|
|
||||||
|
for(GpioPinDigitalInput p:inputpins){
|
||||||
|
p.addListener(new GpioPinListenerDigital() {
|
||||||
|
@Override
|
||||||
|
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent e) {
|
||||||
|
if(e.getState() == PinState.HIGH){
|
||||||
|
buttonRelease(buttons.get(Integer.parseInt(e.getPin().getName())));
|
||||||
|
System.out.println(e.getPin().getName() + " Released");
|
||||||
|
}else{
|
||||||
|
buttonPress(buttons.get(Integer.parseInt(e.getPin().getName())));
|
||||||
|
System.out.println(e.getPin().getName() + " Pressed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addButtonListener(ButtonListener toAdd) {
|
public void addButtonListener(ButtonListener toAdd) {
|
||||||
@@ -30,7 +70,7 @@ public class ButtonHandler implements KeyListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void buttonPress(Button b) {
|
public void buttonPress(Button b) {
|
||||||
if(Window.ON_ARCADE)
|
if(Window.ON_RASP)
|
||||||
{
|
{
|
||||||
Color c = b.getColor().brighter().brighter();
|
Color c = b.getColor().brighter().brighter();
|
||||||
ntw.setLed(b.getLedID(), c.getGreen(), c.getRed(), c.getBlue());
|
ntw.setLed(b.getLedID(), c.getGreen(), c.getRed(), c.getBlue());
|
||||||
@@ -42,7 +82,7 @@ public class ButtonHandler implements KeyListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void buttonRelease(Button b) {
|
public void buttonRelease(Button b) {
|
||||||
if(Window.ON_ARCADE)
|
if(Window.ON_RASP)
|
||||||
{
|
{
|
||||||
ntw.setLed(b.getLedID(), b.getColor().getGreen(), b.getColor().getRed(), b.getColor().getBlue());
|
ntw.setLed(b.getLedID(), b.getColor().getGreen(), b.getColor().getRed(), b.getColor().getBlue());
|
||||||
ntw.show();
|
ntw.show();
|
||||||
@@ -79,7 +119,7 @@ public class ButtonHandler implements KeyListener{
|
|||||||
buttonPress(buttons.get(6));
|
buttonPress(buttons.get(6));
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_ESCAPE:
|
case KeyEvent.VK_ESCAPE:
|
||||||
if(!Window.ON_ARCADE)
|
if(!Window.ON_RASP)
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -140,9 +180,5 @@ public class ButtonHandler implements KeyListener{
|
|||||||
buttons.add(new Button(4, -1, ntw));
|
buttons.add(new Button(4, -1, ntw));
|
||||||
buttons.add(new Button(5, 3, ntw));
|
buttons.add(new Button(5, 3, ntw));
|
||||||
buttons.add(new Button(6, 4, ntw));
|
buttons.add(new Button(6, 4, ntw));
|
||||||
|
|
||||||
for (int i = 1; i < buttons.size(); i++) {
|
|
||||||
buttons.get(i).setColor(GameModel.colors[i - 1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ public class SQLConnector
|
|||||||
Highscore hsc = null;
|
Highscore hsc = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(result.next() && result != null)
|
result.next();
|
||||||
|
if(result != null)
|
||||||
hsc = new Highscore(si, result.getString("username"), result.getInt("score"), result.getDate("date").getTime());
|
hsc = new Highscore(si, result.getString("username"), result.getInt("score"), result.getDate("date").getTime());
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
+16
-7
@@ -2,6 +2,8 @@ package main;
|
|||||||
|
|
||||||
|
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
@@ -11,33 +13,40 @@ import java.awt.image.BufferedImage;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
import model.GameModel;
|
import model.GameModel;
|
||||||
|
import model.SongHandler;
|
||||||
import view.GameView;
|
import view.GameView;
|
||||||
import control.GameControl;
|
import control.GameControl;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.NetworkHandler;
|
import control.NetworkHandler;
|
||||||
import control.SongHandler;
|
|
||||||
import control.button.ButtonHandler;
|
import control.button.ButtonHandler;
|
||||||
import control.joystick.JoystickHandler;
|
import control.joystick.JoystickHandler;
|
||||||
import data.io.SQLConnector;
|
import data.io.SQLConnector;
|
||||||
|
|
||||||
public class Window extends JFrame {
|
public class Window extends JFrame {
|
||||||
private static final long serialVersionUID = -9222956702898533696L;
|
private static final long serialVersionUID = -9222956702898533696L;
|
||||||
public static boolean ON_ARCADE;
|
public static boolean ON_RASP;
|
||||||
|
|
||||||
public final static int WIDTH = 1280;
|
public final static int WIDTH = 1280;
|
||||||
public final static int HEIGHT = 1024;
|
public final static int HEIGHT = 1024;
|
||||||
|
|
||||||
public Window(boolean ON_ARCADE)
|
public Window(boolean ON_RASP)
|
||||||
{
|
{
|
||||||
//Create window
|
//Create window
|
||||||
super("Arcade");
|
super("Arcade");
|
||||||
setSize(WIDTH, HEIGHT);
|
setSize(WIDTH, HEIGHT);
|
||||||
|
|
||||||
//Create Events
|
//Create Events
|
||||||
Window.ON_ARCADE = ON_ARCADE;
|
Window.ON_RASP = ON_RASP;
|
||||||
if(ON_ARCADE){ //Only on the arcade machine
|
if(ON_RASP){ //Only on the raspberry pi
|
||||||
//Remove cursor
|
// GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
setUndecorated(true);
|
// GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||||
|
//
|
||||||
|
// if (!devices[0].isFullScreenSupported ()){
|
||||||
|
// throw new UnsupportedOperationException ("Fullscreen mode is unsupported.");
|
||||||
|
// }else{
|
||||||
|
// devices[0].setFullScreenWindow(this);
|
||||||
|
// }
|
||||||
|
// //Remove cursor
|
||||||
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||||
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||||
this.setCursor(blankCursor);
|
this.setCursor(blankCursor);
|
||||||
|
|||||||
+12
-86
@@ -5,12 +5,11 @@ import java.awt.Color;
|
|||||||
import main.Window;
|
import main.Window;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.NetworkHandler;
|
import control.NetworkHandler;
|
||||||
import control.SongHandler;
|
import control.button.ButtonHandler;
|
||||||
|
|
||||||
public class GameModel {
|
public class GameModel {
|
||||||
|
|
||||||
public static Color[] colors = { Color.GREEN, Color.YELLOW, Color.RED, Color.MAGENTA, Color.CYAN, Color.BLUE };
|
public static Color[] colors = { Color.GREEN, Color.YELLOW, Color.RED, Color.MAGENTA, Color.CYAN, Color.BLUE };
|
||||||
private static String[] ledStripModes = {"full", "half", "quarter", "random"};
|
|
||||||
private GameStateManager gsm;
|
private GameStateManager gsm;
|
||||||
private NetworkHandler ntw;
|
private NetworkHandler ntw;
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
@@ -18,101 +17,28 @@ public class GameModel {
|
|||||||
public GameModel(SongHandler sh, GameStateManager gsm, NetworkHandler ntw) {
|
public GameModel(SongHandler sh, GameStateManager gsm, NetworkHandler ntw) {
|
||||||
this.gsm = gsm;
|
this.gsm = gsm;
|
||||||
this.ntw = ntw;
|
this.ntw = ntw;
|
||||||
|
|
||||||
|
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||||
|
ButtonHandler.getButtons().get(i).setColor(colors[i - 1]);
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
gsm.update(factor);
|
gsm.update(factor);
|
||||||
if (Window.ON_ARCADE)
|
|
||||||
updateLedStrip(factor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLedStrip(float factor)
|
Color c = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
||||||
{
|
|
||||||
|
|
||||||
count += factor;
|
if (Window.ON_RASP) {
|
||||||
if(count > 400)
|
count++;
|
||||||
{
|
if(count>15)
|
||||||
String mode = ledStripModes[(int) (Math.random() * (ledStripModes.length - 1) + 1)];
|
|
||||||
|
|
||||||
switch(mode)
|
|
||||||
{
|
{
|
||||||
default:
|
for (int i = 7; i < 54; i++) {
|
||||||
case "full":
|
|
||||||
|
|
||||||
Color c = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
|
|
||||||
for (int i = 6; i < 46; i++) {
|
|
||||||
ntw.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
|
ntw.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
|
||||||
}
|
}
|
||||||
|
|
||||||
ntw.show();
|
ntw.show();
|
||||||
|
count = 0;
|
||||||
break;
|
|
||||||
|
|
||||||
case "half":
|
|
||||||
|
|
||||||
Color c1 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
Color c2 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
while(c1==c2)
|
|
||||||
c2 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
|
|
||||||
for (int i = 6; i < 26; i++) {
|
|
||||||
ntw.setLed(i, c1.getRed(), c1.getGreen(), c1.getBlue());
|
|
||||||
}
|
|
||||||
for (int i = 27; i < 46; i++) {
|
|
||||||
ntw.setLed(i, c2.getRed(), c2.getGreen(), c2.getBlue());
|
|
||||||
}
|
|
||||||
|
|
||||||
ntw.show();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "quarter":
|
|
||||||
|
|
||||||
Color c3 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
Color c4 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
Color c5 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
Color c6 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
|
|
||||||
while(c3==c4)
|
|
||||||
c4 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
while(c4==c5)
|
|
||||||
c5 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
while(c5==c6)
|
|
||||||
c6 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
|
|
||||||
for (int i = 6; i < 16; i++) {
|
|
||||||
ntw.setLed(i, c3.getRed(), c3.getGreen(), c3.getBlue());
|
|
||||||
}
|
|
||||||
for (int i = 17; i < 26; i++) {
|
|
||||||
ntw.setLed(i, c4.getRed(), c4.getGreen(), c4.getBlue());
|
|
||||||
}
|
|
||||||
for (int i = 27; i < 36; i++) {
|
|
||||||
ntw.setLed(i, c5.getRed(), c5.getGreen(), c5.getBlue());
|
|
||||||
}
|
|
||||||
for (int i = 37; i <46; i++) {
|
|
||||||
ntw.setLed(i, c6.getRed(), c6.getGreen(), c6.getBlue());
|
|
||||||
}
|
|
||||||
|
|
||||||
ntw.show();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "random":
|
|
||||||
|
|
||||||
Color c7;
|
|
||||||
|
|
||||||
for (int i = 6; i < 46; i++) {
|
|
||||||
c7 = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
|
||||||
ntw.setLed(i, c7.getRed(), c7.getGreen(), c7.getBlue());
|
|
||||||
}
|
|
||||||
|
|
||||||
ntw.show();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package control;
|
package model;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -39,7 +39,7 @@ public class SongHandler {
|
|||||||
|
|
||||||
p = new AudioPlayer();
|
p = new AudioPlayer();
|
||||||
|
|
||||||
if(Window.ON_ARCADE)
|
if(Window.ON_RASP)
|
||||||
dir = new File(System.getProperty( "user.home" ) + "/ColorStrike/Songs/");
|
dir = new File(System.getProperty( "user.home" ) + "/ColorStrike/Songs/");
|
||||||
else
|
else
|
||||||
dir = new File(System.getProperty( "user.home" ) + "/Documents/songs/");
|
dir = new File(System.getProperty( "user.home" ) + "/Documents/songs/");
|
||||||
@@ -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; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,13 +12,13 @@ import java.awt.image.VolatileImage;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import model.GameModel;
|
import model.GameModel;
|
||||||
|
import model.SongHandler;
|
||||||
import model.objects.InfoPanel;
|
import model.objects.InfoPanel;
|
||||||
import model.objects.highscore.HighscoreName;
|
import model.objects.highscore.HighscoreName;
|
||||||
|
|
||||||
import com.google.zxing.WriterException;
|
import com.google.zxing.WriterException;
|
||||||
|
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.SongHandler;
|
|
||||||
import control.GameStateManager.State;
|
import control.GameStateManager.State;
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
import control.button.ButtonHandler;
|
import control.button.ButtonHandler;
|
||||||
@@ -37,9 +37,6 @@ public class EndState extends GameState {
|
|||||||
private boolean uploaded;
|
private boolean uploaded;
|
||||||
private BufferedImage QRimage;
|
private BufferedImage QRimage;
|
||||||
|
|
||||||
boolean timeOut = false;
|
|
||||||
float timeOutCounter = 0;
|
|
||||||
|
|
||||||
int frame;
|
int frame;
|
||||||
|
|
||||||
public EndState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
public EndState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||||
@@ -50,15 +47,11 @@ public class EndState extends GameState {
|
|||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
createBackground();
|
createBackground();
|
||||||
|
|
||||||
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||||
ButtonHandler.getButton(2).setColor(GameModel.colors[2]);
|
ButtonHandler.getButton(2).setColor(GameModel.colors[2]);
|
||||||
|
|
||||||
JoystickHandler.REPEAT = true;
|
JoystickHandler.REPEAT = true;
|
||||||
uploaded = false;
|
uploaded = false;
|
||||||
timeOut = true;
|
// System.out.println("Endgame: "+PlayState.won());
|
||||||
timeOutCounter = 0;
|
|
||||||
|
|
||||||
if(PlayState.won()){
|
if(PlayState.won()){
|
||||||
end = Images.getImage(Images.ImageType.youwon);
|
end = Images.getImage(Images.ImageType.youwon);
|
||||||
}else{
|
}else{
|
||||||
@@ -68,17 +61,6 @@ public class EndState extends GameState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
if(timeOut)
|
|
||||||
{
|
|
||||||
timeOutCounter += factor;
|
|
||||||
|
|
||||||
if(timeOutCounter > 800)
|
|
||||||
{
|
|
||||||
timeOut = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
image_x = ((frame / 5) % 5) * 40;
|
image_x = ((frame / 5) % 5) * 40;
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
@@ -102,65 +84,62 @@ public class EndState extends GameState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed(ButtonEvent e) {
|
public void buttonPressed(ButtonEvent e) {
|
||||||
if(!timeOut)
|
//System.out.println("Name: "+hsn.getName());
|
||||||
{
|
switch(e.getButton().getButtonID()){
|
||||||
switch(e.getButton().getButtonID()){
|
case 0:
|
||||||
case 0:
|
gsm.setState(State.TITLE_STATE);
|
||||||
gsm.setState(State.TITLE_STATE);
|
break;
|
||||||
break;
|
case 1:
|
||||||
case 1:
|
if(hsn.getName().trim().length() >= 3)
|
||||||
if(hsn.getName().trim().length() >= 3)
|
{
|
||||||
{
|
if(!uploaded){
|
||||||
if(!uploaded){
|
int id = sql.addHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance(), hsn.getName(), PlayState.currentScore);
|
||||||
int id = sql.addHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance(), hsn.getName(), PlayState.currentScore);
|
try {
|
||||||
try {
|
WebcamUploader.takePictureAndUpload(id);
|
||||||
WebcamUploader.takePictureAndUpload(id);
|
} catch (IOException e2) {
|
||||||
} catch (IOException e2) {
|
e2.printStackTrace();
|
||||||
e2.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
QRimage = WebcamUploader.createQRImage("http://portfolio.jancokock.me/colorstrike/message.php?id="+id, 400);
|
|
||||||
} catch (WriterException | IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
uploaded = true;
|
|
||||||
|
|
||||||
}else{
|
|
||||||
gsm.setState(State.MENU_STATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
QRimage = WebcamUploader.createQRImage("http://portfolio.jancokock.me/colorstrike/message.php?id="+id, 400);
|
||||||
|
} catch (WriterException | IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
uploaded = true;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
gsm.setState(State.MENU_STATE);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
gsm.setState(State.MENU_STATE);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
gsm.setState(State.MENU_STATE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonReleased(ButtonEvent e) {}
|
public void buttonReleased(ButtonEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onJoystickMoved(JoystickEvent e) {
|
public void onJoystickMoved(JoystickEvent e) {
|
||||||
if(!timeOut)
|
switch(e.getJoystick().getPos()){
|
||||||
{
|
case DOWN:
|
||||||
switch(e.getJoystick().getPos()){
|
hsn.down();
|
||||||
case DOWN:
|
break;
|
||||||
hsn.down();
|
case LEFT:
|
||||||
break;
|
hsn.left();
|
||||||
case LEFT:
|
break;
|
||||||
hsn.left();
|
case RIGHT:
|
||||||
break;
|
hsn.right();
|
||||||
case RIGHT:
|
break;
|
||||||
hsn.right();
|
case UP:
|
||||||
break;
|
hsn.up();
|
||||||
case UP:
|
break;
|
||||||
hsn.up();
|
default:
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
package model.gameState;
|
||||||
|
|
||||||
|
import image.Images;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.Transparency;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.VolatileImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import model.GameModel;
|
||||||
|
import model.SongHandler;
|
||||||
|
import model.objects.InfoPanel;
|
||||||
|
import model.objects.highscore.HighscoreName;
|
||||||
|
|
||||||
|
import com.google.zxing.WriterException;
|
||||||
|
|
||||||
|
import control.GameStateManager;
|
||||||
|
import control.GameStateManager.State;
|
||||||
|
import control.button.ButtonEvent;
|
||||||
|
import control.button.ButtonHandler;
|
||||||
|
import control.joystick.JoystickEvent;
|
||||||
|
import control.joystick.JoystickHandler;
|
||||||
|
import data.io.SQLConnector;
|
||||||
|
import data.io.WebcamUploader;
|
||||||
|
|
||||||
|
public class GameOverState extends GameState {
|
||||||
|
|
||||||
|
BufferedImage gameOver = Images.getImage(Images.ImageType.gameover);
|
||||||
|
VolatileImage background;
|
||||||
|
Font textFont = new Font("OCR A Extended", Font.BOLD, 70);
|
||||||
|
HighscoreName hsn;
|
||||||
|
int image_x = 0;
|
||||||
|
private boolean uploaded;
|
||||||
|
private BufferedImage QRimage;
|
||||||
|
|
||||||
|
int frame;
|
||||||
|
|
||||||
|
public GameOverState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||||
|
super(gsm, sh, sql);
|
||||||
|
hsn = new HighscoreName(640,717,5,textFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
createBackground();
|
||||||
|
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||||
|
ButtonHandler.getButton(2).setColor(GameModel.colors[2]);
|
||||||
|
JoystickHandler.REPEAT = true;
|
||||||
|
uploaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float factor) {
|
||||||
|
image_x = ((frame / 5) % 5) * 40;
|
||||||
|
frame++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics2D g2) {
|
||||||
|
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||||
|
g2.drawImage(gameOver.getSubimage(image_x, 0, 40, 26), 640-122, 400, 245, 130, null);
|
||||||
|
if(!uploaded)
|
||||||
|
hsn.drawName(g2);
|
||||||
|
else if(QRimage != null){
|
||||||
|
g2.drawImage(QRimage, (1280/2)-(QRimage.getWidth()/2), 600,null);
|
||||||
|
//1280 is de breedte van de panel
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buttonPressed(ButtonEvent e) {
|
||||||
|
//System.out.println("Name: "+hsn.getName());
|
||||||
|
switch(e.getButton().getButtonID()){
|
||||||
|
case 0:
|
||||||
|
gsm.setState(State.TITLE_STATE);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if(hsn.getName().trim().length() >= 3)
|
||||||
|
{
|
||||||
|
if(!uploaded){
|
||||||
|
int id = sql.addHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance(), hsn.getName(), PlayState.currentScore);
|
||||||
|
try {
|
||||||
|
WebcamUploader.takePictureAndUpload(id);
|
||||||
|
} catch (IOException e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
QRimage = WebcamUploader.createQRImage("http://portfolio.jancokock.me/colorstrike/message.php?id="+id, 400);
|
||||||
|
} catch (WriterException | IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
uploaded = true;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
gsm.setState(State.MENU_STATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
gsm.setState(State.MENU_STATE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void buttonReleased(ButtonEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onJoystickMoved(JoystickEvent e) {
|
||||||
|
switch(e.getJoystick().getPos()){
|
||||||
|
case DOWN:
|
||||||
|
hsn.down();
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
hsn.left();
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
hsn.right();
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
hsn.up();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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.setColor(Color.BLACK);
|
||||||
|
g2.setFont(textFont);
|
||||||
|
|
||||||
|
g2.drawString("High Score", 385, 212);
|
||||||
|
g2.drawString(InfoPanel.getTotalHighscore() + "", 390, 342);
|
||||||
|
g2.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,8 @@ package model.gameState;
|
|||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
|
import model.SongHandler;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.SongHandler;
|
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
import control.joystick.JoystickEvent;
|
import control.joystick.JoystickEvent;
|
||||||
import data.io.SQLConnector;
|
import data.io.SQLConnector;
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
|
|
||||||
import model.GameModel;
|
import model.GameModel;
|
||||||
|
import model.SongHandler;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.SongHandler;
|
|
||||||
import control.GameStateManager.State;
|
import control.GameStateManager.State;
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
import control.button.ButtonHandler;
|
import control.button.ButtonHandler;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import model.GameModel;
|
import model.GameModel;
|
||||||
|
import model.SongHandler;
|
||||||
import model.objects.DifficultyButton;
|
import model.objects.DifficultyButton;
|
||||||
import model.objects.MenuButton;
|
import model.objects.MenuButton;
|
||||||
import model.objects.highscore.Highscore;
|
import model.objects.highscore.Highscore;
|
||||||
@@ -27,7 +28,6 @@ import audio.sorting.SortAUTHOR;
|
|||||||
import audio.sorting.SortPLAYED;
|
import audio.sorting.SortPLAYED;
|
||||||
import audio.sorting.SortSCORE;
|
import audio.sorting.SortSCORE;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.SongHandler;
|
|
||||||
import control.GameStateManager.State;
|
import control.GameStateManager.State;
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
import control.button.ButtonHandler;
|
import control.button.ButtonHandler;
|
||||||
@@ -240,7 +240,7 @@ public class MenuState extends GameState {
|
|||||||
}
|
}
|
||||||
else if(e.getJoystick().getPos() == Joystick.Position.CENTER)
|
else if(e.getJoystick().getPos() == Joystick.Position.CENTER)
|
||||||
{
|
{
|
||||||
sh.set(selectedToSong(selected).getSongs().get( (sh.getCurrentSong().getSongs().size()-1) - difSelect));
|
sh.set(selectedToSong(selected).getSongs().get(difSelect));
|
||||||
}
|
}
|
||||||
//generateSubScreenForeground();
|
//generateSubScreenForeground();
|
||||||
}else{ //Screen for selecting song
|
}else{ //Screen for selecting song
|
||||||
@@ -419,10 +419,10 @@ public class MenuState extends GameState {
|
|||||||
boolean highscoresFound = true;
|
boolean highscoresFound = true;
|
||||||
int HIGHSCORES_TO_DISPLAY = 7;
|
int HIGHSCORES_TO_DISPLAY = 7;
|
||||||
|
|
||||||
List<Highscore> highscores = sql.getHighscoresToday(selectedToSong(selected), sh.getCurrentSong().getSongs().get((sh.getCurrentSong().getSongs().size() - 1) - difSelect));
|
List<Highscore> highscores = sql.getHighscoresToday(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||||
if(highscores.isEmpty())
|
if(highscores.isEmpty())
|
||||||
{
|
{
|
||||||
highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get((sh.getCurrentSong().getSongs().size() - 1) - difSelect));
|
highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||||
if(highscores.isEmpty())
|
if(highscores.isEmpty())
|
||||||
{
|
{
|
||||||
highscoresFound = false;
|
highscoresFound = false;
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ import java.awt.BasicStroke;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import model.SongHandler;
|
||||||
import model.drawObjects.Enemy;
|
import model.drawObjects.Enemy;
|
||||||
import model.drawObjects.Player;
|
import model.drawObjects.Player;
|
||||||
|
import model.drawObjects.PointAnimation;
|
||||||
import model.objects.InfoPanel;
|
import model.objects.InfoPanel;
|
||||||
import model.objects.Path;
|
import model.objects.Path;
|
||||||
import model.objects.PlayArea;
|
import model.objects.PlayArea;
|
||||||
@@ -16,7 +20,6 @@ import model.objects.highscore.Highscore;
|
|||||||
import audio.ButtonInstance;
|
import audio.ButtonInstance;
|
||||||
import audio.ObjectInstance;
|
import audio.ObjectInstance;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.SongHandler;
|
|
||||||
import control.GameStateManager.State;
|
import control.GameStateManager.State;
|
||||||
import control.button.Button;
|
import control.button.Button;
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
@@ -50,7 +53,7 @@ public class PlayState extends GameState {
|
|||||||
|
|
||||||
public PlayState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
public PlayState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||||
super(gsm, sh, sql);
|
super(gsm, sh, sql);
|
||||||
infoPanel = new InfoPanel(sh);
|
infoPanel = new InfoPanel(0, 0, sh);
|
||||||
area = new PlayArea(256, 1024, 1024, 125);
|
area = new PlayArea(256, 1024, 1024, 125);
|
||||||
player = new Player(1280 - 1024 + 1024 / 2, 1024 / 2);
|
player = new Player(1280 - 1024 + 1024 / 2, 1024 / 2);
|
||||||
stroke = new BasicStroke(sizeOfEnemy, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
|
stroke = new BasicStroke(sizeOfEnemy, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
|
||||||
@@ -74,6 +77,8 @@ public class PlayState extends GameState {
|
|||||||
if(h != null)
|
if(h != null)
|
||||||
infoPanel.init(h.getScore());
|
infoPanel.init(h.getScore());
|
||||||
|
|
||||||
|
infoPanel.init(sql.getHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance()).getScore());
|
||||||
|
|
||||||
for(Path p : area.paths)
|
for(Path p : area.paths)
|
||||||
{
|
{
|
||||||
p.getEnemysInPath().clear();
|
p.getEnemysInPath().clear();
|
||||||
@@ -103,7 +108,7 @@ public class PlayState extends GameState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*2500){
|
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*1000*2){
|
||||||
won = true;
|
won = true;
|
||||||
endGame();
|
endGame();
|
||||||
}
|
}
|
||||||
@@ -122,7 +127,7 @@ public class PlayState extends GameState {
|
|||||||
Enemy e = enemyIterator.next();
|
Enemy e = enemyIterator.next();
|
||||||
if (e.getDistanceFromStart() > Enemy.distanceToOctagon + (sizeOfEnemy * 1.5)) {
|
if (e.getDistanceFromStart() > Enemy.distanceToOctagon + (sizeOfEnemy * 1.5)) {
|
||||||
enemyIterator.remove();
|
enemyIterator.remove();
|
||||||
lifePoints -= 6;
|
lifePoints -= 5;
|
||||||
comboScore /= 2;
|
comboScore /= 2;
|
||||||
enemies_missed++;
|
enemies_missed++;
|
||||||
}
|
}
|
||||||
@@ -136,7 +141,7 @@ public class PlayState extends GameState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lifePoints -= 0.003 * factor;
|
lifePoints -= 0.002 * factor;
|
||||||
|
|
||||||
infoPanel.updateIPanel();
|
infoPanel.updateIPanel();
|
||||||
|
|
||||||
@@ -194,6 +199,19 @@ public class PlayState extends GameState {
|
|||||||
player.draw(g2);
|
player.draw(g2);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
// if(!Window.ON_RASP){
|
||||||
|
// int width,height;
|
||||||
|
// width = g2.getFontMetrics().stringWidth("");
|
||||||
|
// height = g2.getFontMetrics().getHeight();
|
||||||
|
// for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||||
|
// Ellipse2D oval = new Ellipse2D.Double(880+(50*i), 0, 50, 50);
|
||||||
|
// g2.setColor(ButtonHandler.getButton(i).getColor());
|
||||||
|
// g2.fill(oval);
|
||||||
|
// g2.setColor(Color.BLACK);
|
||||||
|
// width = g2.getFontMetrics().stringWidth(""+i);
|
||||||
|
// g2.drawString(""+i, (int)oval.getCenterX()-width/2,(int)oval.getMaxY()+height);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -204,12 +222,15 @@ public class PlayState extends GameState {
|
|||||||
Enemy enemy = enemysInPath.next();
|
Enemy enemy = enemysInPath.next();
|
||||||
if (enemy.getDistanceFromStart() > Enemy.distanceToOctagon || enemy.getDistanceFromStart() > Enemy.distanceToOctagon + sizeOfEnemy) {
|
if (enemy.getDistanceFromStart() > Enemy.distanceToOctagon || enemy.getDistanceFromStart() > Enemy.distanceToOctagon + sizeOfEnemy) {
|
||||||
if (e.getButton().getColor().equals(enemy.getColor())) {
|
if (e.getButton().getColor().equals(enemy.getColor())) {
|
||||||
currentScore += enemy.getDistanceFromStart() - Enemy.distanceToOctagon;
|
PointAnimation.LastPointIncrement = (int)(enemy.getDistanceFromStart() - Enemy.distanceToOctagon);
|
||||||
|
currentScore += PointAnimation.LastPointIncrement;
|
||||||
comboScore += 5;
|
comboScore += 5;
|
||||||
lifePoints = Math.min(lifePoints+8, 100);
|
lifePoints = Math.min(lifePoints+10, 100);
|
||||||
area.setHitAreaColor(enemy.getColor());
|
area.setHitAreaColor(enemy.getColor());
|
||||||
|
area.enemyDied((Point2D.Double) enemy.getEnemy().getP1());
|
||||||
area.hit();
|
area.hit();
|
||||||
enemies_hit++;
|
enemies_hit++;
|
||||||
|
infoPanel.throwACoin(enemy.getColor()); // Coin Animatie starten bij hit
|
||||||
enemysInPath.remove();
|
enemysInPath.remove();
|
||||||
notHit = false;
|
notHit = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import java.awt.Font;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import model.SongHandler;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.SongHandler;
|
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
import control.joystick.JoystickEvent;
|
import control.joystick.JoystickEvent;
|
||||||
import data.io.SQLConnector;
|
import data.io.SQLConnector;
|
||||||
@@ -18,6 +18,7 @@ public class PreGameState extends GameState {
|
|||||||
|
|
||||||
double index2 = 3;
|
double index2 = 3;
|
||||||
double index = 3;
|
double index = 3;
|
||||||
|
double timer;
|
||||||
int grootte = 150;
|
int grootte = 150;
|
||||||
BasicStroke s = new BasicStroke(20);
|
BasicStroke s = new BasicStroke(20);
|
||||||
|
|
||||||
@@ -30,9 +31,7 @@ public class PreGameState extends GameState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
grootte = 150;
|
|
||||||
index = 3;
|
|
||||||
index2 = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,12 +50,10 @@ public class PreGameState extends GameState {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
g2.drawImage(screenshot,0,0,1280,1024,null);
|
g2.drawImage(screenshot,0,0,1280,1024,null);
|
||||||
Font textFont = new Font("OCR A Extended", Font.BOLD,grootte);
|
g2.setFont(new Font("OCR A Extended", Font.BOLD,grootte));
|
||||||
g2.setFont(textFont);
|
|
||||||
g2.setStroke(s);
|
g2.setStroke(s);
|
||||||
g2.setColor(Color.RED);
|
g2.setColor(Color.RED);
|
||||||
String text = "" + index;
|
String text = "" + index;
|
||||||
int width = g2.getFontMetrics().stringWidth(text);
|
|
||||||
g2.drawString(text, 325, 400);
|
g2.drawString(text, 325, 400);
|
||||||
if(index < 1){
|
if(index < 1){
|
||||||
text = "GO!!!";
|
text = "GO!!!";
|
||||||
@@ -67,7 +64,7 @@ public class PreGameState extends GameState {
|
|||||||
else{
|
else{
|
||||||
text = "READY";
|
text = "READY";
|
||||||
}
|
}
|
||||||
width = g2.getFontMetrics().stringWidth(text);
|
int width = g2.getFontMetrics().stringWidth(text);
|
||||||
g2.drawString(text, (256+1024/2)-width/2, 600);
|
g2.drawString(text, (256+1024/2)-width/2, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import java.awt.Transparency;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
|
|
||||||
|
import model.SongHandler;
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.SongHandler;
|
|
||||||
import control.GameStateManager.State;
|
import control.GameStateManager.State;
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
import control.joystick.JoystickEvent;
|
import control.joystick.JoystickEvent;
|
||||||
@@ -21,76 +21,72 @@ import data.io.SQLConnector;
|
|||||||
|
|
||||||
public class TitleState extends GameState {
|
public class TitleState extends GameState {
|
||||||
|
|
||||||
BufferedImage pressStart = Images.getImage(ImageType.pressstart);
|
private BufferedImage pressStart = Images.getImage(ImageType.pressstart),
|
||||||
BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
|
colorStrike = Images.getImage(ImageType.colorstrike),
|
||||||
BufferedImage kast = Images.getImage(ImageType.kast);
|
kast = Images.getImage(ImageType.kast);
|
||||||
VolatileImage background;
|
private VolatileImage background;
|
||||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
|
|
||||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
|
private Font textFont = new Font("OCR A Extended", Font.BOLD, 15),
|
||||||
GradientPaint gp = new GradientPaint(300, 0, new Color(0, 0, 1, 0.6f), 980, 1024, new Color(0, 0, 1, 0.2f));
|
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));
|
||||||
|
|
||||||
|
|
||||||
int index = 0;
|
private int index = 0,
|
||||||
int varx = 0;
|
varx = 0,
|
||||||
|
indexKast = 0,
|
||||||
int frame = 0;
|
xKast = 0,
|
||||||
int image_x = 0;
|
frame;
|
||||||
|
|
||||||
|
|
||||||
int indexKast = 0;
|
|
||||||
int xKast=0;
|
|
||||||
|
|
||||||
public TitleState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
|
public TitleState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
|
||||||
super(gsm, sh, sql);
|
super(gsm, sh, sql);
|
||||||
if(!sh.isPlaying())
|
|
||||||
sh.play();
|
|
||||||
createBackground();
|
createBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
if(!sh.isPlaying())
|
sh.play();
|
||||||
sh.play();
|
|
||||||
|
|
||||||
frame = 0;
|
|
||||||
image_x = 0;
|
|
||||||
|
|
||||||
indexKast = 0;
|
|
||||||
xKast = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
image_x = ((frame / 6) % 6) * 49;
|
frame++;
|
||||||
frame++;
|
indexKast++;
|
||||||
|
|
||||||
indexKast++;
|
|
||||||
xKast = indexKast/10;
|
|
||||||
xKast%=4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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.
|
||||||
|
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);
|
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);
|
||||||
g2.drawImage(kast.getSubimage(xKast*600,0,600,800), 490,624,300,400,null);
|
g2.drawImage(kast.getSubimage(xKast*600,0,600,800), 490,624,300,400,null);
|
||||||
|
|
||||||
g2.setFont(textFont);
|
|
||||||
g2.setColor(Color.WHITE);
|
|
||||||
g2.drawString("©2015 Team Hamtaro", 550, 1012);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed(ButtonEvent e) {
|
public void buttonPressed(ButtonEvent e) {
|
||||||
|
|
||||||
switch (e.getButton().getButtonID()) {
|
switch (e.getButton().getButtonID()) {
|
||||||
case 0:
|
case 0:
|
||||||
gsm.setState(State.MENU_STATE);
|
gsm.setState(State.MENU_STATE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,31 +101,47 @@ 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 (frame > 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 (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.setColor(Color.RED);
|
|
||||||
g2.setFont(textFont2);
|
|
||||||
g2.drawString("Color", 385, 212);
|
|
||||||
g2.drawString("Strike", 390, 342);
|
|
||||||
g2.dispose();
|
|
||||||
background.createGraphics();
|
background.createGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ public class DifficultyButton {
|
|||||||
button = Images.initVolatileImage(305, 80, Transparency.OPAQUE);
|
button = Images.initVolatileImage(305, 80, Transparency.OPAQUE);
|
||||||
Graphics2D g2 = button.createGraphics();
|
Graphics2D g2 = button.createGraphics();
|
||||||
g2.setColor(Color.WHITE);
|
g2.setColor(Color.WHITE);
|
||||||
g2.fillRect(0, 0, 305, 80);
|
g2.fillRect(0, 0, 300, 75);
|
||||||
g2.setColor(Color.ORANGE);
|
g2.setColor(Color.ORANGE);
|
||||||
g2.drawRect(0, 0, 304, 79);
|
|
||||||
g2.drawRect(2, 2, 300, 75);
|
|
||||||
// g2.drawRect(0, 0, 300, 75);
|
// g2.drawRect(0, 0, 300, 75);
|
||||||
// g2.drawRect(0-2, 0-2, 304, 79);
|
// g2.drawRect(0-2, 0-2, 304, 79);
|
||||||
g2.drawRect(0, 0, 304, 79);
|
g2.drawRect(0, 0, 304, 79);
|
||||||
|
|||||||
@@ -9,21 +9,30 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.Transparency;
|
import java.awt.Transparency;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
|
|
||||||
import model.gameState.PlayState;
|
|
||||||
import control.SongHandler;
|
|
||||||
import control.button.ButtonHandler;
|
import control.button.ButtonHandler;
|
||||||
|
import main.Window;
|
||||||
|
import model.SongHandler;
|
||||||
|
import model.drawObjects.CoinAnimation;
|
||||||
|
import model.gameState.PlayState;
|
||||||
|
|
||||||
public class InfoPanel {
|
public class InfoPanel {
|
||||||
|
|
||||||
private static String totalHighscore = "000000";
|
private static String totalHighscore = "000000";
|
||||||
|
private int x, y;
|
||||||
private VolatileImage infoPanel;
|
private VolatileImage infoPanel;
|
||||||
private SongHandler sh;
|
private SongHandler sh;
|
||||||
private String time;
|
private String time;
|
||||||
private int highscore = 0;
|
private int highscore = 0,
|
||||||
|
tempComboScore = 0;
|
||||||
|
|
||||||
public InfoPanel(SongHandler sh){
|
private CoinAnimation coinAnimation = new CoinAnimation(27, 820);
|
||||||
|
|
||||||
|
public InfoPanel(int x, int y, SongHandler sh){
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
this.sh = sh;
|
this.sh = sh;
|
||||||
updateIPanel();
|
updateIPanel();
|
||||||
generateInfoPanel();
|
generateInfoPanel();
|
||||||
@@ -56,10 +65,10 @@ public class InfoPanel {
|
|||||||
g2.setPaint(gp);
|
g2.setPaint(gp);
|
||||||
|
|
||||||
g2.setColor(Color.GREEN);
|
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.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.setColor(Color.BLACK);
|
||||||
|
|
||||||
@@ -70,63 +79,91 @@ public class InfoPanel {
|
|||||||
g2.setFont(scoreFont);
|
g2.setFont(scoreFont);
|
||||||
g2.drawString("Score: ", 25, 75);
|
g2.drawString("Score: ", 25, 75);
|
||||||
|
|
||||||
g2.drawString(sh.getCurrentSong().getTitle(), 25, 215);
|
|
||||||
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 295);
|
|
||||||
g2.drawString(time, 25, 375);
|
|
||||||
g2.drawString("" + highscore, 25, 455);
|
|
||||||
|
|
||||||
Font scoreFont2 = new Font("OCR A Extended", Font.BOLD, 25);
|
Font scoreFont2 = new Font("OCR A Extended", Font.BOLD, 25);
|
||||||
g2.setFont(scoreFont2);
|
g2.setFont(scoreFont2);
|
||||||
g2.drawString("Title: ", 25, 185);
|
int charsPerLine = 10;
|
||||||
g2.drawString("Difficulty: ", 25, 265);
|
int linesNeeded = sh.getCurrentSong().getTitle().length() / charsPerLine + 1; // 9 chars per regel
|
||||||
g2.drawString("Time: ", 25, 345);
|
g2.drawString("Title: ", 25, 225 - (linesNeeded) * 30);
|
||||||
g2.drawString("Best: ", 25, 425);
|
g2.drawString("Time: ", 25, 265);
|
||||||
|
g2.drawString("Best: ", 25, 345);
|
||||||
|
|
||||||
|
Font scoreFont3 = new Font("OCR A Extended", Font.BOLD, 35);
|
||||||
Font scoreFont3 = new Font("OCR A Extended", Font.BOLD, 45);
|
|
||||||
g2.setFont(scoreFont3);
|
g2.setFont(scoreFont3);
|
||||||
g2.drawString("" + totalHighscore, 25, 115);
|
|
||||||
|
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){
|
||||||
|
Ellipse2D oval1 = new Ellipse2D.Double(25, 650, 50, 50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ellipse2D oval1 = new Ellipse2D.Double(25, 700, 50, 50);
|
|
||||||
g2.setColor(ButtonHandler.getButton(1).getColor());
|
g2.setColor(ButtonHandler.getButton(1).getColor());
|
||||||
g2.fill(oval1);
|
g2.fill(oval1);
|
||||||
|
|
||||||
Ellipse2D oval2 = new Ellipse2D.Double(85, 700, 50, 50);
|
Ellipse2D oval2 = new Ellipse2D.Double(85, 650, 50, 50);
|
||||||
g2.setColor(ButtonHandler.getButton(2).getColor());
|
g2.setColor(ButtonHandler.getButton(2).getColor());
|
||||||
g2.fill(oval2);
|
g2.fill(oval2);
|
||||||
|
|
||||||
Ellipse2D oval3 = new Ellipse2D.Double(145, 700, 50, 50);
|
Ellipse2D oval3 = new Ellipse2D.Double(145, 650, 50, 50);
|
||||||
g2.setColor(ButtonHandler.getButton(3).getColor());
|
g2.setColor(ButtonHandler.getButton(3).getColor());
|
||||||
g2.fill(oval3);
|
g2.fill(oval3);
|
||||||
|
|
||||||
Ellipse2D oval4 = new Ellipse2D.Double(50, 760, 50, 50);
|
Ellipse2D oval4 = new Ellipse2D.Double(50, 710, 50, 50);
|
||||||
g2.setColor(ButtonHandler.getButton(4).getColor());
|
g2.setColor(ButtonHandler.getButton(4).getColor());
|
||||||
g2.fill(oval4);
|
g2.fill(oval4);
|
||||||
|
|
||||||
Ellipse2D oval5 = new Ellipse2D.Double(110, 760, 50, 50);
|
Ellipse2D oval5 = new Ellipse2D.Double(110, 710, 50, 50);
|
||||||
g2.setColor(ButtonHandler.getButton(5).getColor());
|
g2.setColor(ButtonHandler.getButton(5).getColor());
|
||||||
g2.fill(oval5);
|
g2.fill(oval5);
|
||||||
|
|
||||||
Ellipse2D oval6 = new Ellipse2D.Double(170, 760, 50, 50);
|
Ellipse2D oval6 = new Ellipse2D.Double(170, 710, 50, 50);
|
||||||
g2.setColor(ButtonHandler.getButton(6).getColor());
|
g2.setColor(ButtonHandler.getButton(6).getColor());
|
||||||
g2.fill(oval6);
|
g2.fill(oval6);
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
g2.dispose();
|
||||||
infoPanel.createGraphics();
|
infoPanel.createGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2){
|
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()
|
public static String getTotalHighscore()
|
||||||
{
|
{
|
||||||
return totalHighscore;
|
return totalHighscore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void throwACoin(Color c) {
|
||||||
|
coinAnimation.start(c); // Teller weer op 1 zetten
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,17 @@ import java.awt.Polygon;
|
|||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.Transparency;
|
import java.awt.Transparency;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.geom.GeneralPath;
|
import java.awt.geom.GeneralPath;
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import model.drawObjects.Enemy;
|
import model.drawObjects.Enemy;
|
||||||
|
import model.drawObjects.PointAnimation;
|
||||||
import model.gameState.PlayState;
|
import model.gameState.PlayState;
|
||||||
|
|
||||||
public class PlayArea {
|
public class PlayArea {
|
||||||
@@ -29,6 +32,7 @@ public class PlayArea {
|
|||||||
private boolean hit = false;
|
private boolean hit = false;
|
||||||
private int count = 0,maxCount = 100,pathID = -1;
|
private int count = 0,maxCount = 100,pathID = -1;
|
||||||
private Stroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
|
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);
|
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
|
||||||
|
|
||||||
@@ -121,6 +125,12 @@ public class PlayArea {
|
|||||||
g2.setColor(pathColor);
|
g2.setColor(pathColor);
|
||||||
g2.draw(paths.get(pathID));
|
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){
|
public Line2D getLine(int index){
|
||||||
@@ -157,4 +167,6 @@ public class PlayArea {
|
|||||||
this.pathID = pathID;
|
this.pathID = pathID;
|
||||||
this.pathColor = pathColor;
|
this.pathColor = pathColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p, hitAreaColor); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user