Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4d0706443 | ||
|
|
5c239b17f7 | ||
|
|
78acc6aa5f | ||
|
|
55f9c1a623 | ||
|
|
d322e0ca3f | ||
|
|
04ad4edc2b | ||
|
|
675daadd13 | ||
|
|
137eb5384f | ||
|
|
9d50e6d9f9 | ||
|
|
06a3d74445 | ||
|
|
7ebf6a18e8 | ||
|
|
4250e99682 | ||
|
|
c0123378aa | ||
|
|
cb57ce7fe6 | ||
|
|
b39e62d69b | ||
|
|
86cec99367 | ||
|
|
fc21037006 | ||
|
|
da934f7111 | ||
|
|
f771fb4e2d | ||
|
|
e32165f654 | ||
|
|
67455ccd72 | ||
|
|
6dda54928c | ||
|
|
56710c1b46 | ||
|
|
b81c5c73f9 | ||
|
|
3f08675d9e | ||
|
|
9380506d06 |
@@ -67,6 +67,8 @@ public class SongInstance {
|
||||
|
||||
public long getEndTime()
|
||||
{
|
||||
if(objects.size() == 0)
|
||||
return 0;
|
||||
return objects.get(objects.size()-1).getTime();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import model.SongHandler;
|
||||
import model.gameState.EndState;
|
||||
import model.gameState.GameState;
|
||||
import model.gameState.HelpState;
|
||||
@@ -48,7 +47,7 @@ public class GameStateManager {
|
||||
}
|
||||
|
||||
public void setState(State st) {
|
||||
if (st.ordinal() > 0 && !(currentState instanceof TitleState))
|
||||
if (st.ordinal() > 0 && ( !(currentState instanceof TitleState) || !(currentState instanceof EndState) ))
|
||||
currentState.stopAudio();
|
||||
|
||||
currentState = gamestates.get(st.ordinal());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package model;
|
||||
package control;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -39,7 +39,7 @@ public class SongHandler {
|
||||
|
||||
p = new AudioPlayer();
|
||||
|
||||
if(Window.ON_RASP)
|
||||
if(Window.ON_ARCADE)
|
||||
dir = new File(System.getProperty( "user.home" ) + "/ColorStrike/Songs/");
|
||||
else
|
||||
dir = new File(System.getProperty( "user.home" ) + "/Documents/songs/");
|
||||
@@ -25,7 +25,7 @@ public class Button {
|
||||
|
||||
private void setLed()
|
||||
{
|
||||
if(Window.ON_RASP)
|
||||
if(Window.ON_ARCADE)
|
||||
{
|
||||
ntw.setLed(ledID, color.getGreen(), color.getRed(), color.getBlue());
|
||||
ntw.show();
|
||||
|
||||
@@ -7,15 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import main.Window;
|
||||
|
||||
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 model.GameModel;
|
||||
import control.NetworkHandler;
|
||||
|
||||
public class ButtonHandler implements KeyListener{
|
||||
@@ -30,47 +22,15 @@ public class ButtonHandler implements KeyListener{
|
||||
|
||||
listeners = new ArrayList<ButtonListener>();
|
||||
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) {
|
||||
listeners.add(toAdd);
|
||||
}
|
||||
|
||||
public void buttonPress(Button b) {
|
||||
if(Window.ON_RASP)
|
||||
if(Window.ON_ARCADE)
|
||||
{
|
||||
Color c = b.getColor().brighter().brighter();
|
||||
ntw.setLed(b.getLedID(), c.getGreen(), c.getRed(), c.getBlue());
|
||||
@@ -82,7 +42,7 @@ public class ButtonHandler implements KeyListener{
|
||||
}
|
||||
|
||||
public void buttonRelease(Button b) {
|
||||
if(Window.ON_RASP)
|
||||
if(Window.ON_ARCADE)
|
||||
{
|
||||
ntw.setLed(b.getLedID(), b.getColor().getGreen(), b.getColor().getRed(), b.getColor().getBlue());
|
||||
ntw.show();
|
||||
@@ -119,7 +79,7 @@ public class ButtonHandler implements KeyListener{
|
||||
buttonPress(buttons.get(6));
|
||||
break;
|
||||
case KeyEvent.VK_ESCAPE:
|
||||
if(!Window.ON_RASP)
|
||||
if(!Window.ON_ARCADE)
|
||||
System.exit(0);
|
||||
break;
|
||||
}
|
||||
@@ -180,5 +140,9 @@ public class ButtonHandler implements KeyListener{
|
||||
buttons.add(new Button(4, -1, ntw));
|
||||
buttons.add(new Button(5, 3, 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,8 +61,7 @@ public class SQLConnector
|
||||
Highscore hsc = null;
|
||||
|
||||
try {
|
||||
result.next();
|
||||
if(result != null)
|
||||
if(result.next() && result != null)
|
||||
hsc = new Highscore(si, result.getString("username"), result.getInt("score"), result.getDate("date").getTime());
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
+7
-16
@@ -2,8 +2,6 @@ package main;
|
||||
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
@@ -13,40 +11,33 @@ import java.awt.image.BufferedImage;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import model.GameModel;
|
||||
import model.SongHandler;
|
||||
import view.GameView;
|
||||
import control.GameControl;
|
||||
import control.GameStateManager;
|
||||
import control.NetworkHandler;
|
||||
import control.SongHandler;
|
||||
import control.button.ButtonHandler;
|
||||
import control.joystick.JoystickHandler;
|
||||
import data.io.SQLConnector;
|
||||
|
||||
public class Window extends JFrame {
|
||||
private static final long serialVersionUID = -9222956702898533696L;
|
||||
public static boolean ON_RASP;
|
||||
public static boolean ON_ARCADE;
|
||||
|
||||
public final static int WIDTH = 1280;
|
||||
public final static int HEIGHT = 1024;
|
||||
|
||||
public Window(boolean ON_RASP)
|
||||
public Window(boolean ON_ARCADE)
|
||||
{
|
||||
//Create window
|
||||
super("Arcade");
|
||||
setSize(WIDTH, HEIGHT);
|
||||
|
||||
//Create Events
|
||||
Window.ON_RASP = ON_RASP;
|
||||
if(ON_RASP){ //Only on the raspberry pi
|
||||
// GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||
//
|
||||
// if (!devices[0].isFullScreenSupported ()){
|
||||
// throw new UnsupportedOperationException ("Fullscreen mode is unsupported.");
|
||||
// }else{
|
||||
// devices[0].setFullScreenWindow(this);
|
||||
// }
|
||||
// //Remove cursor
|
||||
Window.ON_ARCADE = ON_ARCADE;
|
||||
if(ON_ARCADE){ //Only on the arcade machine
|
||||
//Remove cursor
|
||||
setUndecorated(true);
|
||||
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||
this.setCursor(blankCursor);
|
||||
|
||||
+88
-14
@@ -5,11 +5,12 @@ import java.awt.Color;
|
||||
import main.Window;
|
||||
import control.GameStateManager;
|
||||
import control.NetworkHandler;
|
||||
import control.button.ButtonHandler;
|
||||
import control.SongHandler;
|
||||
|
||||
public class GameModel {
|
||||
|
||||
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 NetworkHandler ntw;
|
||||
private int count = 0;
|
||||
@@ -17,28 +18,101 @@ public class GameModel {
|
||||
public GameModel(SongHandler sh, GameStateManager gsm, NetworkHandler ntw) {
|
||||
this.gsm = gsm;
|
||||
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) {
|
||||
gsm.update(factor);
|
||||
|
||||
Color c = colors[(int) (Math.random() * (colors.length - 1) + 1)];
|
||||
|
||||
if (Window.ON_RASP) {
|
||||
count++;
|
||||
if(count>15)
|
||||
if (Window.ON_ARCADE)
|
||||
updateLedStrip(factor);
|
||||
}
|
||||
|
||||
private void updateLedStrip(float factor)
|
||||
{
|
||||
|
||||
count += factor;
|
||||
if(count > 400)
|
||||
{
|
||||
String mode = ledStripModes[(int) (Math.random() * (ledStripModes.length - 1) + 1)];
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
for (int i = 7; i < 54; i++) {
|
||||
default:
|
||||
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.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,75 +0,0 @@
|
||||
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; }
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
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 model.GameModel;
|
||||
import model.SongHandler;
|
||||
import model.objects.InfoPanel;
|
||||
import model.objects.highscore.HighscoreName;
|
||||
|
||||
import com.google.zxing.WriterException;
|
||||
|
||||
import control.GameStateManager;
|
||||
import control.SongHandler;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.button.ButtonHandler;
|
||||
@@ -37,6 +37,9 @@ public class EndState extends GameState {
|
||||
private boolean uploaded;
|
||||
private BufferedImage QRimage;
|
||||
|
||||
boolean timeOut = false;
|
||||
float timeOutCounter = 0;
|
||||
|
||||
int frame;
|
||||
|
||||
public EndState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||
@@ -47,11 +50,15 @@ public class EndState extends GameState {
|
||||
@Override
|
||||
public void init() {
|
||||
createBackground();
|
||||
|
||||
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||
ButtonHandler.getButton(2).setColor(GameModel.colors[2]);
|
||||
|
||||
JoystickHandler.REPEAT = true;
|
||||
uploaded = false;
|
||||
// System.out.println("Endgame: "+PlayState.won());
|
||||
timeOut = true;
|
||||
timeOutCounter = 0;
|
||||
|
||||
if(PlayState.won()){
|
||||
end = Images.getImage(Images.ImageType.youwon);
|
||||
}else{
|
||||
@@ -61,6 +68,17 @@ public class EndState extends GameState {
|
||||
|
||||
@Override
|
||||
public void update(float factor) {
|
||||
if(timeOut)
|
||||
{
|
||||
timeOutCounter += factor;
|
||||
|
||||
if(timeOutCounter > 800)
|
||||
{
|
||||
timeOut = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
image_x = ((frame / 5) % 5) * 40;
|
||||
frame++;
|
||||
}
|
||||
@@ -84,62 +102,65 @@ public class EndState extends GameState {
|
||||
|
||||
@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();
|
||||
if(!timeOut)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
public void buttonReleased(ButtonEvent e) {
|
||||
|
||||
}
|
||||
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;
|
||||
if(!timeOut)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
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 model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.SongHandler;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.JoystickEvent;
|
||||
import data.io.SQLConnector;
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
import model.GameModel;
|
||||
import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.SongHandler;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.button.ButtonHandler;
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import model.GameModel;
|
||||
import model.SongHandler;
|
||||
import model.objects.DifficultyButton;
|
||||
import model.objects.MenuButton;
|
||||
import model.objects.highscore.Highscore;
|
||||
@@ -28,6 +27,7 @@ import audio.sorting.SortAUTHOR;
|
||||
import audio.sorting.SortPLAYED;
|
||||
import audio.sorting.SortSCORE;
|
||||
import control.GameStateManager;
|
||||
import control.SongHandler;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.button.ButtonHandler;
|
||||
@@ -240,7 +240,7 @@ public class MenuState extends GameState {
|
||||
}
|
||||
else if(e.getJoystick().getPos() == Joystick.Position.CENTER)
|
||||
{
|
||||
sh.set(selectedToSong(selected).getSongs().get(difSelect));
|
||||
sh.set(selectedToSong(selected).getSongs().get( (sh.getCurrentSong().getSongs().size()-1) - difSelect));
|
||||
}
|
||||
//generateSubScreenForeground();
|
||||
}else{ //Screen for selecting song
|
||||
@@ -419,10 +419,10 @@ public class MenuState extends GameState {
|
||||
boolean highscoresFound = true;
|
||||
int HIGHSCORES_TO_DISPLAY = 7;
|
||||
|
||||
List<Highscore> highscores = sql.getHighscoresToday(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||
List<Highscore> highscores = sql.getHighscoresToday(selectedToSong(selected), sh.getCurrentSong().getSongs().get((sh.getCurrentSong().getSongs().size() - 1) - difSelect));
|
||||
if(highscores.isEmpty())
|
||||
{
|
||||
highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||
highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get((sh.getCurrentSong().getSongs().size() - 1) - difSelect));
|
||||
if(highscores.isEmpty())
|
||||
{
|
||||
highscoresFound = false;
|
||||
|
||||
@@ -4,15 +4,11 @@ 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;
|
||||
@@ -20,6 +16,7 @@ import model.objects.highscore.Highscore;
|
||||
import audio.ButtonInstance;
|
||||
import audio.ObjectInstance;
|
||||
import control.GameStateManager;
|
||||
import control.SongHandler;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.Button;
|
||||
import control.button.ButtonEvent;
|
||||
@@ -53,7 +50,7 @@ public class PlayState extends GameState {
|
||||
|
||||
public PlayState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||
super(gsm, sh, sql);
|
||||
infoPanel = new InfoPanel(0, 0, sh);
|
||||
infoPanel = new InfoPanel(sh);
|
||||
area = new PlayArea(256, 1024, 1024, 125);
|
||||
player = new Player(1280 - 1024 + 1024 / 2, 1024 / 2);
|
||||
stroke = new BasicStroke(sizeOfEnemy, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
|
||||
@@ -77,8 +74,6 @@ 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();
|
||||
@@ -108,7 +103,7 @@ public class PlayState extends GameState {
|
||||
}
|
||||
|
||||
|
||||
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*1000*2){
|
||||
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*2500){
|
||||
won = true;
|
||||
endGame();
|
||||
}
|
||||
@@ -127,7 +122,7 @@ public class PlayState extends GameState {
|
||||
Enemy e = enemyIterator.next();
|
||||
if (e.getDistanceFromStart() > Enemy.distanceToOctagon + (sizeOfEnemy * 1.5)) {
|
||||
enemyIterator.remove();
|
||||
lifePoints -= 5;
|
||||
lifePoints -= 6;
|
||||
comboScore /= 2;
|
||||
enemies_missed++;
|
||||
}
|
||||
@@ -141,7 +136,7 @@ public class PlayState extends GameState {
|
||||
}
|
||||
}
|
||||
|
||||
lifePoints -= 0.002 * factor;
|
||||
lifePoints -= 0.003 * factor;
|
||||
|
||||
infoPanel.updateIPanel();
|
||||
|
||||
@@ -199,19 +194,6 @@ public class PlayState extends GameState {
|
||||
player.draw(g2);
|
||||
} 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
|
||||
@@ -222,15 +204,12 @@ 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())) {
|
||||
PointAnimation.LastPointIncrement = (int)(enemy.getDistanceFromStart() - Enemy.distanceToOctagon);
|
||||
currentScore += PointAnimation.LastPointIncrement;
|
||||
currentScore += enemy.getDistanceFromStart() - Enemy.distanceToOctagon;
|
||||
comboScore += 5;
|
||||
lifePoints = Math.min(lifePoints+10, 100);
|
||||
lifePoints = Math.min(lifePoints+8, 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;
|
||||
|
||||
@@ -8,8 +8,8 @@ import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.SongHandler;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.JoystickEvent;
|
||||
import data.io.SQLConnector;
|
||||
@@ -18,7 +18,6 @@ public class PreGameState extends GameState {
|
||||
|
||||
double index2 = 3;
|
||||
double index = 3;
|
||||
double timer;
|
||||
int grootte = 150;
|
||||
BasicStroke s = new BasicStroke(20);
|
||||
|
||||
@@ -31,7 +30,9 @@ public class PreGameState extends GameState {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
grootte = 150;
|
||||
index = 3;
|
||||
index2 = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,10 +51,12 @@ public class PreGameState extends GameState {
|
||||
@Override
|
||||
public void draw(Graphics2D g2) {
|
||||
g2.drawImage(screenshot,0,0,1280,1024,null);
|
||||
g2.setFont(new Font("OCR A Extended", Font.BOLD,grootte));
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD,grootte);
|
||||
g2.setFont(textFont);
|
||||
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!!!";
|
||||
@@ -64,7 +67,7 @@ public class PreGameState extends GameState {
|
||||
else{
|
||||
text = "READY";
|
||||
}
|
||||
int width = g2.getFontMetrics().stringWidth(text);
|
||||
width = g2.getFontMetrics().stringWidth(text);
|
||||
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.VolatileImage;
|
||||
|
||||
import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.SongHandler;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.joystick.JoystickEvent;
|
||||
@@ -21,72 +21,76 @@ import data.io.SQLConnector;
|
||||
|
||||
public class TitleState extends GameState {
|
||||
|
||||
private BufferedImage pressStart = Images.getImage(ImageType.pressstart),
|
||||
colorStrike = Images.getImage(ImageType.colorstrike),
|
||||
kast = Images.getImage(ImageType.kast);
|
||||
private VolatileImage background;
|
||||
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 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 index = 0;
|
||||
int varx = 0;
|
||||
|
||||
int frame = 0;
|
||||
int image_x = 0;
|
||||
|
||||
|
||||
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() {
|
||||
sh.play();
|
||||
if(!sh.isPlaying())
|
||||
sh.play();
|
||||
|
||||
frame = 0;
|
||||
image_x = 0;
|
||||
|
||||
indexKast = 0;
|
||||
xKast = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float factor) {
|
||||
frame++;
|
||||
indexKast++;
|
||||
image_x = ((frame / 6) % 6) * 49;
|
||||
frame++;
|
||||
|
||||
indexKast++;
|
||||
xKast = indexKast/10;
|
||||
xKast%=4;
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
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
|
||||
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
|
||||
@@ -101,47 +105,31 @@ 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);
|
||||
|
||||
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(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.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();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,10 @@ public class DifficultyButton {
|
||||
button = Images.initVolatileImage(305, 80, Transparency.OPAQUE);
|
||||
Graphics2D g2 = button.createGraphics();
|
||||
g2.setColor(Color.WHITE);
|
||||
g2.fillRect(0, 0, 300, 75);
|
||||
g2.fillRect(0, 0, 305, 80);
|
||||
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-2, 0-2, 304, 79);
|
||||
g2.drawRect(0, 0, 304, 79);
|
||||
|
||||
@@ -9,30 +9,21 @@ 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;
|
||||
import control.SongHandler;
|
||||
import control.button.ButtonHandler;
|
||||
|
||||
public class InfoPanel {
|
||||
|
||||
private static String totalHighscore = "000000";
|
||||
private int x, y;
|
||||
private VolatileImage infoPanel;
|
||||
private SongHandler sh;
|
||||
private String time;
|
||||
private int highscore = 0,
|
||||
tempComboScore = 0;
|
||||
|
||||
private CoinAnimation coinAnimation = new CoinAnimation(27, 820);
|
||||
private int highscore = 0;
|
||||
|
||||
public InfoPanel(int x, int y, SongHandler sh){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
public InfoPanel(SongHandler sh){
|
||||
this.sh = sh;
|
||||
updateIPanel();
|
||||
generateInfoPanel();
|
||||
@@ -65,10 +56,10 @@ public class InfoPanel {
|
||||
g2.setPaint(gp);
|
||||
|
||||
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, (2 * PlayState.comboScore), 30);
|
||||
g2.fillRect(25, 950, (int)(2 * PlayState.comboScore), 30);
|
||||
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
@@ -79,91 +70,63 @@ public class InfoPanel {
|
||||
g2.setFont(scoreFont);
|
||||
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);
|
||||
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.drawString("Title: ", 25, 185);
|
||||
g2.drawString("Difficulty: ", 25, 265);
|
||||
g2.drawString("Time: ", 25, 345);
|
||||
g2.drawString("Best: ", 25, 425);
|
||||
|
||||
|
||||
Font scoreFont3 = new Font("OCR A Extended", Font.BOLD, 45);
|
||||
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.fill(oval1);
|
||||
|
||||
Ellipse2D oval2 = new Ellipse2D.Double(85, 650, 50, 50);
|
||||
|
||||
Ellipse2D oval2 = new Ellipse2D.Double(85, 700, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(2).getColor());
|
||||
g2.fill(oval2);
|
||||
|
||||
Ellipse2D oval3 = new Ellipse2D.Double(145, 650, 50, 50);
|
||||
|
||||
Ellipse2D oval3 = new Ellipse2D.Double(145, 700, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(3).getColor());
|
||||
g2.fill(oval3);
|
||||
|
||||
Ellipse2D oval4 = new Ellipse2D.Double(50, 710, 50, 50);
|
||||
|
||||
Ellipse2D oval4 = new Ellipse2D.Double(50, 760, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(4).getColor());
|
||||
g2.fill(oval4);
|
||||
|
||||
Ellipse2D oval5 = new Ellipse2D.Double(110, 710, 50, 50);
|
||||
|
||||
Ellipse2D oval5 = new Ellipse2D.Double(110, 760, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(5).getColor());
|
||||
g2.fill(oval5);
|
||||
|
||||
Ellipse2D oval6 = new Ellipse2D.Double(170, 710, 50, 50);
|
||||
|
||||
Ellipse2D oval6 = new Ellipse2D.Double(170, 760, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(6).getColor());
|
||||
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();
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,14 @@ 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 {
|
||||
@@ -32,7 +29,6 @@ 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);
|
||||
|
||||
@@ -125,12 +121,6 @@ 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){
|
||||
@@ -167,6 +157,4 @@ public class PlayArea {
|
||||
this.pathID = pathID;
|
||||
this.pathColor = pathColor;
|
||||
}
|
||||
|
||||
public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p, hitAreaColor); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user