Compare commits
56
Commits
develop
...
feature/new
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b526152957 | ||
|
|
32fadbbec1 | ||
|
|
25828bdbf9 | ||
|
|
6d354d0675 | ||
|
|
1a12edf752 | ||
|
|
9f2f84c608 | ||
|
|
8a8323e547 | ||
|
|
93e4cb3d6e | ||
|
|
db68f35835 | ||
|
|
a855764ee6 | ||
|
|
11811ef6af | ||
|
|
412ed60dfe | ||
|
|
bfc62c2b62 | ||
|
|
42228aa9f7 | ||
|
|
b86ce91755 | ||
|
|
2ba069c0e2 | ||
|
|
5ce6454824 | ||
|
|
1ed5ac1be2 | ||
|
|
e6050715fc | ||
|
|
c019fdeea3 | ||
|
|
d92cd7333b | ||
|
|
864b6efa52 | ||
|
|
91a6ae718d | ||
|
|
5b1138936d | ||
|
|
9b779537b6 | ||
|
|
8b18077fff | ||
|
|
d21bcb3b54 | ||
|
|
f72d54202f | ||
|
|
a54c3e2991 | ||
|
|
8adc39f00f | ||
|
|
d86d4dc62e | ||
|
|
2ed5ceeaba | ||
|
|
93cb22b0c0 | ||
|
|
3d2e0c666c | ||
|
|
fb08e22b0e | ||
|
|
f2fd2b5993 | ||
|
|
1c1b6f0c8e | ||
|
|
3f22402bc4 | ||
|
|
1520a6a104 | ||
|
|
ec2d6cbc29 | ||
|
|
5ce2cca4df | ||
|
|
b60ff37301 | ||
|
|
75ec5ccf37 | ||
|
|
ef36b2052e | ||
|
|
ec8f1e5bb3 | ||
|
|
5248ae94d1 | ||
|
|
df35dbeb8d | ||
|
|
d1a4ccf150 | ||
|
|
665f04ceef | ||
|
|
699c58952a | ||
|
|
6a86f2a522 | ||
|
|
1f44b5b487 | ||
|
|
702ce6a245 | ||
|
|
b1a194c45d | ||
|
|
d1e50f823a | ||
|
|
b89ea8a5df |
@@ -35,17 +35,15 @@ public class AudioPlayer{
|
|||||||
} catch (JavaLayerException | FileNotFoundException e1) {
|
} catch (JavaLayerException | FileNotFoundException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(() -> {
|
||||||
@Override
|
while (clip != null){
|
||||||
public void run() {
|
|
||||||
if(clip != null){
|
|
||||||
try {
|
try {
|
||||||
clip.play();
|
clip.play();
|
||||||
} catch (JavaLayerException e) {
|
} catch (JavaLayerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,14 +52,13 @@ public class AudioPlayer{
|
|||||||
{
|
{
|
||||||
clip.close();
|
clip.close();
|
||||||
clip = null;
|
clip = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(fis != null)
|
if(fis != null)
|
||||||
fis.close();
|
fis.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(thread != null && thread.isAlive())
|
|
||||||
thread.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,4 +155,14 @@ public class Song implements Comparable<Song>{
|
|||||||
public int compareTo(Song s) {
|
public int compareTo(Song s) {
|
||||||
return getTitle().compareTo(s.getTitle());
|
return getTitle().compareTo(s.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimesPlayed()
|
||||||
|
{
|
||||||
|
int timesPlayed = 0;
|
||||||
|
for(SongInstance s : songs)
|
||||||
|
{
|
||||||
|
timesPlayed += s.getTimesPlayed();
|
||||||
|
}
|
||||||
|
return timesPlayed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
public class SongInstance {
|
public class SongInstance {
|
||||||
|
|
||||||
private String difficulty;
|
private String difficulty;
|
||||||
|
private int timesPlayed;
|
||||||
|
|
||||||
private List<ObjectInstance> objects;
|
private List<ObjectInstance> objects;
|
||||||
private List<ButtonInstance> buttons;
|
private List<ButtonInstance> buttons;
|
||||||
@@ -13,6 +14,7 @@ public class SongInstance {
|
|||||||
public SongInstance(String difficulty)
|
public SongInstance(String difficulty)
|
||||||
{
|
{
|
||||||
this.difficulty = difficulty;
|
this.difficulty = difficulty;
|
||||||
|
this.timesPlayed = 0;
|
||||||
|
|
||||||
objects = new ArrayList<ObjectInstance>();
|
objects = new ArrayList<ObjectInstance>();
|
||||||
buttons = new ArrayList<ButtonInstance>();
|
buttons = new ArrayList<ButtonInstance>();
|
||||||
@@ -83,4 +85,17 @@ public class SongInstance {
|
|||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimesPlayed() {
|
||||||
|
return timesPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimesPlayed(int timesPlayed) {
|
||||||
|
this.timesPlayed = timesPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void played()
|
||||||
|
{
|
||||||
|
timesPlayed++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package audio.io;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import audio.Song;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Song s = null;
|
|
||||||
try {
|
|
||||||
s = JSONReader.readSong(new File("C:\\Users\\Kenneth\\Development\\Java Development\\SimApplicatie\\Arcade\\songs\\NAME_OF_SONG\\NAME_OF_SONG.csf"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("---");
|
|
||||||
System.out.println(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,12 @@ public class SortPLAYED implements Comparator<Song> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Song s1, Song s2) {
|
public int compare(Song s1, Song s2) {
|
||||||
return s1.getAuthor().compareTo(s2.getAuthor());
|
if(s1.getTimesPlayed() < s2.getTimesPlayed())
|
||||||
|
return 1;
|
||||||
|
else if(s1.getTimesPlayed() > s2.getTimesPlayed())
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return s1.getTitle().compareTo(s2.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-13
@@ -15,36 +15,33 @@ import control.joystick.JoystickListener;
|
|||||||
public class GameControl implements JoystickListener, ButtonListener, ActionListener {
|
public class GameControl implements JoystickListener, ButtonListener, ActionListener {
|
||||||
|
|
||||||
private long lastTime = System.currentTimeMillis();
|
private long lastTime = System.currentTimeMillis();
|
||||||
GameModel model;
|
private GameModel model;
|
||||||
GameView view;
|
private GameView view;
|
||||||
GameStateManager gsm;
|
private GameStateManager gsm;
|
||||||
Timer update;
|
private Timer update;
|
||||||
|
|
||||||
public GameControl(final GameModel model, final GameView view,GameStateManager gsm)
|
public GameControl(final GameModel model, final GameView view,GameStateManager gsm) {
|
||||||
{
|
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.gsm = gsm;
|
this.gsm = gsm;
|
||||||
|
|
||||||
view.setIgnoreRepaint(true);
|
view.setIgnoreRepaint(true);
|
||||||
update = new Timer(1000/60,this);
|
(update = new Timer(1000/60,this)).start();
|
||||||
update.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed(ButtonEvent e) {
|
public void buttonPressed(ButtonEvent e) {
|
||||||
// System.out.println("Game control, button pressed: "+e.getButton().getButtonID());
|
gsm.buttonPressed(e);
|
||||||
gsm.currentState.buttonPressed(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonReleased(ButtonEvent e) {
|
public void buttonReleased(ButtonEvent e) {
|
||||||
// System.out.println("Game control, button released: "+e.getButton().getButtonID());
|
gsm.buttonReleased(e);
|
||||||
gsm.currentState.buttonReleased(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onJoystickMoved(JoystickEvent e) {
|
public void onJoystickMoved(JoystickEvent e) {
|
||||||
gsm.currentState.onJoystickMoved(e);
|
gsm.onJoystickMoved(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,56 +5,62 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import model.SongHandler;
|
import model.SongHandler;
|
||||||
import model.gameState.GameOverState;
|
import model.gameState.*;
|
||||||
import model.gameState.GameState;
|
|
||||||
import model.gameState.HelpState;
|
|
||||||
import model.gameState.MenuState;
|
|
||||||
import model.gameState.PlayState;
|
|
||||||
import model.gameState.TitleState;
|
|
||||||
import control.button.Button;
|
import control.button.Button;
|
||||||
|
import control.button.ButtonEvent;
|
||||||
import control.button.ButtonHandler;
|
import control.button.ButtonHandler;
|
||||||
|
import control.joystick.JoystickEvent;
|
||||||
import control.joystick.JoystickHandler;
|
import control.joystick.JoystickHandler;
|
||||||
import data.io.SQLConnector;
|
import data.io.SQLConnector;
|
||||||
|
|
||||||
public class GameStateManager {
|
public class GameStateManager {
|
||||||
|
|
||||||
private List<GameState> gamestates;
|
private List<GameState> gamestates;
|
||||||
public GameState currentState;
|
|
||||||
private int index = 0;
|
public GameState currentState;
|
||||||
public int fps;
|
private SongHandler sh;
|
||||||
|
|
||||||
|
private int index = 0;
|
||||||
|
public int fps;
|
||||||
|
private float timeOfNoAction = 0,
|
||||||
|
maxTimeToHaveNoAction = 45000;
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
TITLE_STATE,
|
TITLE_STATE,
|
||||||
MENU_STATE,
|
MENU_STATE,
|
||||||
HELP_STATE,
|
HELP_STATE,
|
||||||
PLAY_STATE,
|
PLAY_STATE,
|
||||||
GAMEOVER_STATE
|
GAMEOVER_STATE,
|
||||||
|
PRE_GAME_STATE
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameStateManager(SongHandler sh, SQLConnector sql){
|
public GameStateManager(SongHandler sh, SQLConnector sql){
|
||||||
gamestates = new ArrayList<GameState>();
|
this.sh = sh;
|
||||||
|
gamestates = new ArrayList<>();
|
||||||
gamestates.add(new TitleState(this, sh, sql));
|
gamestates.add(new TitleState(this, sh, sql));
|
||||||
gamestates.add(new MenuState(this, sh, sql));
|
gamestates.add(new MenuState(this, sh, sql));
|
||||||
gamestates.add(new HelpState(this, sh, sql));
|
gamestates.add(new HelpState(this, sh, sql));
|
||||||
gamestates.add(new PlayState(this, sh, sql));
|
gamestates.add(new PlayState(this, sh, sql));
|
||||||
gamestates.add(new GameOverState(this, sh, sql));
|
gamestates.add(new GameOverState(this, sh, sql));
|
||||||
|
gamestates.add(new PreGameState(this, sh, sql));
|
||||||
setState(State.TITLE_STATE);
|
setState(State.TITLE_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(State st)
|
public void setState(State st)
|
||||||
{
|
{
|
||||||
|
if (currentState != null)
|
||||||
|
currentState.stopAudio();
|
||||||
|
|
||||||
currentState = gamestates.get(st.ordinal());
|
currentState = gamestates.get(st.ordinal());
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void next() {
|
|
||||||
index++;
|
|
||||||
index %= gamestates.size();
|
|
||||||
currentState = gamestates.get(index);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(float factor){
|
public void update(float factor){
|
||||||
|
timeOfNoAction += factor;
|
||||||
|
if(timeOfNoAction > maxTimeToHaveNoAction){
|
||||||
|
setState(State.TITLE_STATE);
|
||||||
|
timeOfNoAction = 0;
|
||||||
|
}
|
||||||
currentState.update(factor);
|
currentState.update(factor);
|
||||||
fps = (int) (60/(factor/10));
|
fps = (int) (60/(factor/10));
|
||||||
}
|
}
|
||||||
@@ -68,4 +74,19 @@ public class GameStateManager {
|
|||||||
}
|
}
|
||||||
currentState.init();
|
currentState.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void buttonPressed(ButtonEvent e) {
|
||||||
|
timeOfNoAction = 0;
|
||||||
|
currentState.buttonPressed(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buttonReleased(ButtonEvent e) {
|
||||||
|
timeOfNoAction = 0;
|
||||||
|
currentState.buttonReleased(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onJoystickMoved(JoystickEvent e) {
|
||||||
|
timeOfNoAction = 0;
|
||||||
|
currentState.onJoystickMoved(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-30
@@ -3,27 +3,29 @@ package control;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import control.button.ButtonHandler;
|
import control.button.ButtonHandler;
|
||||||
import control.joystick.Joystick.Position;
|
import control.joystick.Joystick.Position;
|
||||||
import control.joystick.JoystickHandler;
|
import control.joystick.JoystickHandler;
|
||||||
|
|
||||||
public class NetworkHandler implements Runnable{
|
public class NetworkHandler implements Runnable{
|
||||||
|
|
||||||
DatagramSocket udp;
|
private DatagramSocket udp;
|
||||||
|
|
||||||
String host;
|
private String host;
|
||||||
int port;
|
private int port;
|
||||||
|
|
||||||
boolean running;
|
private boolean running;
|
||||||
Thread t;
|
private Thread t;
|
||||||
|
|
||||||
byte[] send;
|
private byte[] send,
|
||||||
byte[] receive;
|
receive;
|
||||||
|
|
||||||
ButtonHandler bth;
|
private ButtonHandler bth;
|
||||||
JoystickHandler jth;
|
private JoystickHandler jth;
|
||||||
|
|
||||||
public NetworkHandler(String host, int port, ButtonHandler bth, JoystickHandler jth)
|
public NetworkHandler(String host, int port, ButtonHandler bth, JoystickHandler jth)
|
||||||
{
|
{
|
||||||
@@ -39,7 +41,7 @@ public class NetworkHandler implements Runnable{
|
|||||||
receive = new byte[1024];
|
receive = new byte[1024];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
udp = new DatagramSocket(1112);
|
udp = new DatagramSocket(1113);
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -60,15 +62,7 @@ public class NetworkHandler implements Runnable{
|
|||||||
send(cmd);
|
send(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void send(String str)
|
private void send(String str) { }
|
||||||
{
|
|
||||||
send = str.getBytes();
|
|
||||||
try {
|
|
||||||
udp.send(new DatagramPacket(send, send.length));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
@@ -90,10 +84,7 @@ public class NetworkHandler implements Runnable{
|
|||||||
}
|
}
|
||||||
String sentence = new String( receivePacket.getData());
|
String sentence = new String( receivePacket.getData());
|
||||||
|
|
||||||
if(sentence.length() != 21)
|
sentence = sentence.trim();
|
||||||
return;
|
|
||||||
|
|
||||||
System.out.println("RECEIVED: " + sentence);
|
|
||||||
|
|
||||||
String[] controls = sentence.split("\\|");
|
String[] controls = sentence.split("\\|");
|
||||||
int[] control = new int[controls.length];
|
int[] control = new int[controls.length];
|
||||||
@@ -103,7 +94,6 @@ public class NetworkHandler implements Runnable{
|
|||||||
for(int i = 0; i < 7; i++){
|
for(int i = 0; i < 7; i++){
|
||||||
if(control[i] != ButtonHandler.getButton(i).pressed)
|
if(control[i] != ButtonHandler.getButton(i).pressed)
|
||||||
{
|
{
|
||||||
System.out.println("PRESS BITCH " + controls[i]);
|
|
||||||
ButtonHandler.getButton(i).pressed = control[i];
|
ButtonHandler.getButton(i).pressed = control[i];
|
||||||
if(control[i] == 0)
|
if(control[i] == 0)
|
||||||
bth.buttonPress(ButtonHandler.getButton(i));
|
bth.buttonPress(ButtonHandler.getButton(i));
|
||||||
@@ -166,8 +156,13 @@ public class NetworkHandler implements Runnable{
|
|||||||
JoystickHandler.j.setPosition(Position.DOWN);
|
JoystickHandler.j.setPosition(Position.DOWN);
|
||||||
jth.onJoystickMoved(JoystickHandler.j);
|
jth.onJoystickMoved(JoystickHandler.j);
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
if(JoystickHandler.j.getPos() != Position.CENTER){
|
||||||
|
JoystickHandler.j.setPosition(Position.CENTER);
|
||||||
|
jth.onJoystickMoved(JoystickHandler.j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-13
@@ -7,14 +7,14 @@ import control.NetworkHandler;
|
|||||||
|
|
||||||
public class Button {
|
public class Button {
|
||||||
|
|
||||||
Color color;
|
private Color color;
|
||||||
int ledID;
|
private int ledID,
|
||||||
int buttonID;
|
buttonID;
|
||||||
NetworkHandler ntw;
|
public int pressed;
|
||||||
public int pressed;
|
|
||||||
|
private NetworkHandler ntw;
|
||||||
|
|
||||||
public Button(int buttonID, int ledID, NetworkHandler ntw)
|
public Button(int buttonID, int ledID, NetworkHandler ntw) {
|
||||||
{
|
|
||||||
color = new Color(255,255,255);
|
color = new Color(255,255,255);
|
||||||
this.ledID = ledID;
|
this.ledID = ledID;
|
||||||
this.buttonID = buttonID;
|
this.buttonID = buttonID;
|
||||||
@@ -23,17 +23,14 @@ public class Button {
|
|||||||
setLed();
|
setLed();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLed()
|
private void setLed() {
|
||||||
{
|
if(Window.ON_RASP) {
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Color newColor)
|
public void setColor(Color newColor) {
|
||||||
{
|
|
||||||
color = newColor;
|
color = newColor;
|
||||||
setLed();
|
setLed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,19 +20,15 @@ import control.NetworkHandler;
|
|||||||
|
|
||||||
public class ButtonHandler implements KeyListener{
|
public class ButtonHandler implements KeyListener{
|
||||||
|
|
||||||
List<ButtonListener> listeners;
|
private List<ButtonListener> listeners;
|
||||||
static List<Button> buttons;
|
public static List<Button> buttons;
|
||||||
NetworkHandler ntw;
|
private NetworkHandler ntw;
|
||||||
|
|
||||||
public ButtonHandler()
|
public ButtonHandler()
|
||||||
{
|
{
|
||||||
this.ntw = null;
|
this.ntw = null;
|
||||||
|
|
||||||
listeners = new ArrayList<ButtonListener>();
|
listeners = new ArrayList<ButtonListener>();
|
||||||
buttons = new ArrayList<Button>();
|
buttons = new ArrayList<Button>();
|
||||||
|
|
||||||
// if (Window.ON_RASP)
|
|
||||||
// addGpioListeners();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +44,6 @@ public class ButtonHandler implements KeyListener{
|
|||||||
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_12, "6"));
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_12, "6"));
|
||||||
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_06, "0"));
|
inputpins.add(gpio.provisionDigitalInputPin(RaspiPin.GPIO_06, "0"));
|
||||||
|
|
||||||
|
|
||||||
for(GpioPinDigitalInput p:inputpins){
|
for(GpioPinDigitalInput p:inputpins){
|
||||||
p.addListener(new GpioPinListenerDigital() {
|
p.addListener(new GpioPinListenerDigital() {
|
||||||
@Override
|
@Override
|
||||||
@@ -82,12 +77,12 @@ public class ButtonHandler implements KeyListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void buttonRelease(Button b) {
|
public void buttonRelease(Button b) {
|
||||||
if(Window.ON_RASP)
|
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();
|
||||||
}
|
}
|
||||||
ButtonEvent e = new ButtonEvent(b, System.currentTimeMillis());
|
ButtonEvent e = new ButtonEvent(b, System.currentTimeMillis());
|
||||||
|
|
||||||
for (ButtonListener bt : listeners)
|
for (ButtonListener bt : listeners)
|
||||||
bt.buttonReleased(e);
|
bt.buttonReleased(e);
|
||||||
}
|
}
|
||||||
@@ -161,12 +156,9 @@ public class ButtonHandler implements KeyListener{
|
|||||||
public static Button getButton(int id)
|
public static Button getButton(int id)
|
||||||
{
|
{
|
||||||
for(Button b : buttons)
|
for(Button b : buttons)
|
||||||
{
|
|
||||||
if(b.getButtonID() == id)
|
if(b.getButtonID() == id)
|
||||||
{
|
|
||||||
return b;
|
return b;
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package control.button;
|
package control.button;
|
||||||
|
|
||||||
public interface ButtonListener {
|
public interface ButtonListener {
|
||||||
public void buttonPressed(ButtonEvent e);
|
void buttonPressed(ButtonEvent e);
|
||||||
public void buttonReleased(ButtonEvent e);
|
void buttonReleased(ButtonEvent e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
/SQLConnector.class
|
/SQLConnector.class
|
||||||
|
/WebcamUploader.class
|
||||||
|
|||||||
+31
-41
@@ -8,25 +8,24 @@ import java.sql.Statement;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.crypto.provider.RSACipher;
|
||||||
|
|
||||||
import model.objects.highscore.Highscore;
|
import model.objects.highscore.Highscore;
|
||||||
import audio.Song;
|
import audio.Song;
|
||||||
import audio.SongInstance;
|
import audio.SongInstance;
|
||||||
|
|
||||||
public class SQLConnector
|
public class SQLConnector
|
||||||
{
|
{
|
||||||
|
|
||||||
private Connection myConn = null;
|
private Connection myConn = null;
|
||||||
|
public SQLConnector()
|
||||||
public SQLConnector()
|
|
||||||
{
|
{
|
||||||
this("178.62.254.153", "3306","colorstrike","csadmin","aardbei123");
|
this("178.62.254.153", "3306","colorstrike","csadmin","aardbei123");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start connection with Databse
|
//Start connection with Database
|
||||||
public SQLConnector(String host, String port, String dbName, String userName, String password)
|
public SQLConnector(String host, String port, String dbName, String userName, String password)
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
String url = "jdbc:mysql://" + host + ":" + port + "/"+ dbName + "?user="
|
String url = "jdbc:mysql://" + host + ":" + port + "/"+ dbName + "?user="
|
||||||
+ userName
|
+ userName
|
||||||
+ "&password="
|
+ "&password="
|
||||||
@@ -34,8 +33,7 @@ public class SQLConnector
|
|||||||
Class.forName("com.mysql.jdbc.Driver").newInstance ();
|
Class.forName("com.mysql.jdbc.Driver").newInstance ();
|
||||||
myConn = DriverManager.getConnection(url);
|
myConn = DriverManager.getConnection(url);
|
||||||
}
|
}
|
||||||
catch( SQLException ex)
|
catch( SQLException ex) {
|
||||||
{
|
|
||||||
System.out.println("SQLException: " + ex.getMessage());
|
System.out.println("SQLException: " + ex.getMessage());
|
||||||
System.out.println("SQLState: " + ex.getSQLState());
|
System.out.println("SQLState: " + ex.getSQLState());
|
||||||
System.out.println("VendorError: " + ex.getErrorCode());
|
System.out.println("VendorError: " + ex.getErrorCode());
|
||||||
@@ -52,7 +50,8 @@ public class SQLConnector
|
|||||||
//System.out.println(query);
|
//System.out.println(query);
|
||||||
Statement st = executeResultQuery(query);
|
Statement st = executeResultQuery(query);
|
||||||
ResultSet result = null;
|
ResultSet result = null;
|
||||||
List<Highscore> hsc = new ArrayList<Highscore>();
|
List<Highscore> hsc = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = st.getResultSet();
|
result = st.getResultSet();
|
||||||
} catch (SQLException e1) {
|
} catch (SQLException e1) {
|
||||||
@@ -60,9 +59,7 @@ public class SQLConnector
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
while(result.next())
|
while(result.next())
|
||||||
{
|
|
||||||
hsc.add(new Highscore(si, result.getString("username"), result.getInt("score"), result.getDate("date").getTime()));
|
hsc.add(new Highscore(si, result.getString("username"), result.getInt("score"), result.getDate("date").getTime()));
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -74,7 +71,7 @@ public class SQLConnector
|
|||||||
{
|
{
|
||||||
Statement st = executeResultQuery("SELECT * FROM highscore WHERE date=CURDATE() AND songinstance = (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')) ORDER BY score DESC");
|
Statement st = executeResultQuery("SELECT * FROM highscore WHERE date=CURDATE() AND songinstance = (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')) ORDER BY score DESC");
|
||||||
ResultSet result = null;
|
ResultSet result = null;
|
||||||
List<Highscore> hsc = new ArrayList<Highscore>();
|
List<Highscore> hsc = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
result = st.getResultSet();
|
result = st.getResultSet();
|
||||||
} catch (SQLException e1) {
|
} catch (SQLException e1) {
|
||||||
@@ -93,8 +90,7 @@ public class SQLConnector
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int addHighscore(Song s, SongInstance si, String name, int currentScore) {
|
public int addHighscore(Song s, SongInstance si, String name, int currentScore) {
|
||||||
if(name.length() <= 5 && currentScore <= Integer.MAX_VALUE)
|
if(name.length() <= 5 && currentScore <= Integer.MAX_VALUE) {
|
||||||
{
|
|
||||||
String query = "INSERT INTO highscore (username, score, date, songinstance) VALUES ('" + name.trim() + "', " + currentScore + ", CURDATE(), (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')))";
|
String query = "INSERT INTO highscore (username, score, date, songinstance) VALUES ('" + name.trim() + "', " + currentScore + ", CURDATE(), (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')))";
|
||||||
//System.out.println(query);
|
//System.out.println(query);
|
||||||
return executeInsertQuery(query);
|
return executeInsertQuery(query);
|
||||||
@@ -107,7 +103,6 @@ public class SQLConnector
|
|||||||
String query = "INSERT INTO playdata (enemies_missed, enemies_hit, buttons_pressed, joystick_moved, start_time, play_time, songinstance) VALUES (" + enemies_missed + ", " + enemies_hit + ", " + buttons_pressed + ", " + joystick_moved + ", NOW(), " + time + ", (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')))";
|
String query = "INSERT INTO playdata (enemies_missed, enemies_hit, buttons_pressed, joystick_moved, start_time, play_time, songinstance) VALUES (" + enemies_missed + ", " + enemies_hit + ", " + buttons_pressed + ", " + joystick_moved + ", NOW(), " + time + ", (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')))";
|
||||||
//System.out.println(query);
|
//System.out.println(query);
|
||||||
executeInsertQuery(query);
|
executeInsertQuery(query);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(List<Song> songs)
|
public void update(List<Song> songs)
|
||||||
@@ -129,25 +124,18 @@ public class SQLConnector
|
|||||||
rs.close();
|
rs.close();
|
||||||
st.close();
|
st.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
System.out.println("Empty return set");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(id != -1)
|
if(id != -1) {
|
||||||
{
|
for(SongInstance si : s.getSongs()) {
|
||||||
for(SongInstance si : s.getSongs())
|
|
||||||
{
|
|
||||||
Statement st2 = executeResultQuery("SELECT id FROM songinstance WHERE song=" + id + " AND difficulty='" + si.getDifficulty() + "'");
|
Statement st2 = executeResultQuery("SELECT id FROM songinstance WHERE song=" + id + " AND difficulty='" + si.getDifficulty() + "'");
|
||||||
|
|
||||||
ResultSet rs2 = null;
|
ResultSet rs2 = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rs2 = st2.getResultSet();
|
rs2 = st2.getResultSet();
|
||||||
if(rs2.first())
|
if(!rs2.first()) {
|
||||||
{
|
|
||||||
//System.err.println("SongInstance Already Exists ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
executeInsertQuery("INSERT INTO songinstance (song, enemies, difficulty) VALUES (" + id + ", " + si.getObjects().size() + ", '" + si.getDifficulty() + "');");
|
executeInsertQuery("INSERT INTO songinstance (song, enemies, difficulty) VALUES (" + id + ", " + si.getObjects().size() + ", '" + si.getDifficulty() + "');");
|
||||||
//System.out.println("Songinstance Added");
|
//System.out.println("Songinstance Added");
|
||||||
}
|
}
|
||||||
@@ -156,12 +144,19 @@ public class SQLConnector
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Statement st3 = executeResultQuery("SELECT COUNT(1) FROM playdata WHERE songinstance = (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "'))");
|
||||||
|
try {
|
||||||
|
ResultSet rs3 = st3.getResultSet();
|
||||||
|
rs3.next();
|
||||||
|
int i = rs3.getInt(1);
|
||||||
|
si.setTimesPlayed(i);
|
||||||
|
System.out.println(s.getTitle() + " - " + si.getDifficulty() + ": " + i);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//System.err.println("Insert Failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,11 +167,11 @@ public class SQLConnector
|
|||||||
Statement s = myConn.createStatement();
|
Statement s = myConn.createStatement();
|
||||||
s.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
|
s.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
|
||||||
ResultSet rs = s.getGeneratedKeys();
|
ResultSet rs = s.getGeneratedKeys();
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
if(rs.next())
|
if(rs.next())
|
||||||
{
|
|
||||||
id = rs.getInt(1);
|
id = rs.getInt(1);
|
||||||
}
|
|
||||||
s.close();
|
s.close();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -197,11 +192,9 @@ public class SQLConnector
|
|||||||
private Statement executeResultQuery(String query)
|
private Statement executeResultQuery(String query)
|
||||||
{
|
{
|
||||||
Statement s = null;
|
Statement s = null;
|
||||||
|
try {
|
||||||
try{
|
|
||||||
s = myConn.createStatement();
|
s = myConn.createStatement();
|
||||||
s.executeQuery(query);
|
s.executeQuery(query);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( SQLException ex)
|
catch( SQLException ex)
|
||||||
{
|
{
|
||||||
@@ -209,8 +202,7 @@ public class SQLConnector
|
|||||||
System.out.println("SQLState: " + ex.getSQLState());
|
System.out.println("SQLState: " + ex.getSQLState());
|
||||||
System.out.println("VendorError: " + ex.getErrorCode());
|
System.out.println("VendorError: " + ex.getErrorCode());
|
||||||
}
|
}
|
||||||
catch( Exception ex)
|
catch( Exception ex) {
|
||||||
{
|
|
||||||
System.out.println("getMeasurement: " + ex.getMessage());
|
System.out.println("getMeasurement: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,10 +214,8 @@ public class SQLConnector
|
|||||||
public void finalize() throws Throwable
|
public void finalize() throws Throwable
|
||||||
{
|
{
|
||||||
// Close database connection
|
// Close database connection
|
||||||
if( myConn != null )
|
if( myConn != null ) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
myConn.close();
|
myConn.close();
|
||||||
System.out.println("Database connection terminated");
|
System.out.println("Database connection terminated");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ import com.google.zxing.qrcode.QRCodeWriter;
|
|||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
|
||||||
public class WebcamUploader {
|
public class WebcamUploader {
|
||||||
public static void takePictureAndUpload(int id) throws IOException{
|
|
||||||
|
public static void takePictureAndUpload(int id) throws IOException{
|
||||||
|
|
||||||
Runtime.getRuntime().exec("streamer -c /dev/video0 -b 16 -o" + System.getProperty( "user.home" ) + "/ColorStrike/picture.jpeg");
|
Runtime.getRuntime().exec("streamer -c /dev/video0 -b 16 -o" + System.getProperty( "user.home" ) + "/ColorStrike/picture.jpeg");
|
||||||
|
|
||||||
HttpURLConnection httpUrlConnection = (HttpURLConnection)new URL("http://178.62.254.153/colorstrike/images/photoupload.php?filename="+id+".jpeg").openConnection();
|
HttpURLConnection httpUrlConnection = (HttpURLConnection)new URL("http://178.62.254.153/colorstrike/images/photoupload.php?filename="+id+".jpeg").openConnection();
|
||||||
|
|||||||
+6
-3
@@ -17,10 +17,9 @@ import main.Main;
|
|||||||
|
|
||||||
public class Images {
|
public class Images {
|
||||||
|
|
||||||
public static ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
|
public static ArrayList<BufferedImage> images = new ArrayList<>();
|
||||||
|
|
||||||
public Images() {
|
public Images() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -34,6 +33,7 @@ public class Images {
|
|||||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/kast.png"))));
|
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/kast.png"))));
|
||||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/gameover.png"))));
|
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/gameover.png"))));
|
||||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/help.png"))));
|
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/help.png"))));
|
||||||
|
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/screenshot.png")))); // HELP, MAAR NOG GEEN JUIST PLAATJE
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,10 @@ public class Images {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum ImageType {
|
public enum ImageType {
|
||||||
pulse,cursor,pressstart,colorstrike,background,aanwijzers,kast,gameover,help
|
pulse, cursor, pressstart,
|
||||||
|
colorstrike, background, aanwijzers,
|
||||||
|
kast, gameover, help,
|
||||||
|
screenshot
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage readImage(File f) {
|
public static BufferedImage readImage(File f) {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
+4
-1
@@ -55,8 +55,10 @@ public class Window extends JFrame {
|
|||||||
ButtonHandler bth = new ButtonHandler();
|
ButtonHandler bth = new ButtonHandler();
|
||||||
JoystickHandler jsh = new JoystickHandler();
|
JoystickHandler jsh = new JoystickHandler();
|
||||||
|
|
||||||
|
|
||||||
final SQLConnector sql = new SQLConnector();
|
final SQLConnector sql = new SQLConnector();
|
||||||
NetworkHandler ntw = new NetworkHandler("192.168.1.6", 1113, bth, jsh);
|
|
||||||
|
NetworkHandler ntw = new NetworkHandler("10.42.0.5", 1113, bth, jsh);
|
||||||
|
|
||||||
bth.setNetwork(ntw);
|
bth.setNetwork(ntw);
|
||||||
|
|
||||||
@@ -89,6 +91,7 @@ public class Window extends JFrame {
|
|||||||
jsh.addJoystickListener(control);
|
jsh.addJoystickListener(control);
|
||||||
|
|
||||||
//Display
|
//Display
|
||||||
|
setResizable(false);
|
||||||
pack();
|
pack();
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ public class GameModel {
|
|||||||
|
|
||||||
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||||
ButtonHandler.getButtons().get(i).setColor(colors[i - 1]);
|
ButtonHandler.getButtons().get(i).setColor(colors[i - 1]);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,8 +30,7 @@ public class GameModel {
|
|||||||
|
|
||||||
if (Window.ON_RASP) {
|
if (Window.ON_RASP) {
|
||||||
count++;
|
count++;
|
||||||
if(count>15)
|
if(count>15) {
|
||||||
{
|
|
||||||
for (int i = 7; i < 54; i++) {
|
for (int i = 7; i < 54; i++) {
|
||||||
ntw.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
|
ntw.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import audio.Song;
|
|||||||
import audio.SongInstance;
|
import audio.SongInstance;
|
||||||
import audio.io.DirScanner;
|
import audio.io.DirScanner;
|
||||||
import audio.sorting.SortALPHA;
|
import audio.sorting.SortALPHA;
|
||||||
|
import audio.sorting.SortPLAYED;
|
||||||
import data.io.SQLConnector;
|
import data.io.SQLConnector;
|
||||||
|
|
||||||
public class SongHandler {
|
public class SongHandler {
|
||||||
@@ -21,7 +22,7 @@ public class SongHandler {
|
|||||||
private Song currentSong;
|
private Song currentSong;
|
||||||
private SongInstance currentSongInstance;
|
private SongInstance currentSongInstance;
|
||||||
private int currentIndex;
|
private int currentIndex;
|
||||||
SQLConnector sql;
|
private SQLConnector sql;
|
||||||
|
|
||||||
private File dir;
|
private File dir;
|
||||||
|
|
||||||
@@ -32,7 +33,6 @@ public class SongHandler {
|
|||||||
this.sql = sql;
|
this.sql = sql;
|
||||||
|
|
||||||
songs = new ArrayList<Song>();
|
songs = new ArrayList<Song>();
|
||||||
|
|
||||||
currentSong = null;
|
currentSong = null;
|
||||||
currentSongInstance = null;
|
currentSongInstance = null;
|
||||||
currentIndex = 0;
|
currentIndex = 0;
|
||||||
@@ -46,10 +46,10 @@ public class SongHandler {
|
|||||||
|
|
||||||
songs = DirScanner.scanDirectories(dir);
|
songs = DirScanner.scanDirectories(dir);
|
||||||
|
|
||||||
sort(new SortALPHA());
|
|
||||||
|
|
||||||
sql.update(songs);
|
sql.update(songs);
|
||||||
|
|
||||||
|
sort(new SortPLAYED());
|
||||||
|
|
||||||
updatePlayer();
|
updatePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package model.drawObjects;
|
||||||
|
|
||||||
|
import model.gameState.PlayState;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public CoinAnimation(int startX, int startY) {
|
||||||
|
coinSetPoint = new Point2D.Double(startX, startY);
|
||||||
|
coinShape = new Ellipse2D.Double(startX, startY, 20, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start
|
||||||
|
public void start() {
|
||||||
|
timerLoops = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(Graphics2D g2) {
|
||||||
|
Color oldColor = g2.getColor();
|
||||||
|
update(timerLoops); // UPDATE
|
||||||
|
g2.setColor(new Color(255, 255, 0)); // 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(), coinSetPoint.getY() + (1000 - 35 * PlayState.comboMulitplier) / 25 * timerLoops,
|
||||||
|
coinShape.getWidth(), coinShape.getHeight());
|
||||||
|
} catch (ArithmeticException a) { a.printStackTrace(); }
|
||||||
|
|
||||||
|
timerLoops++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zijn we al begonnen/klaar?
|
||||||
|
public boolean areWeDoneYet() {
|
||||||
|
if (timerLoops > 24 || timerLoops == 0) {
|
||||||
|
timerLoops = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zitten we in de laatste loop?
|
||||||
|
public boolean isLastLoop() { return (timerLoops == 24) ? true : false; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,10 +5,13 @@ import java.awt.geom.AffineTransform;
|
|||||||
|
|
||||||
public abstract class DrawObject {
|
public abstract class DrawObject {
|
||||||
|
|
||||||
|
|
||||||
protected AffineTransform transform;
|
protected AffineTransform transform;
|
||||||
protected double width,height;
|
|
||||||
|
protected double width,
|
||||||
|
height;
|
||||||
|
|
||||||
protected int index = 0;
|
protected int index = 0;
|
||||||
|
|
||||||
public DrawObject() {
|
public DrawObject() {
|
||||||
transform = new AffineTransform();
|
transform = new AffineTransform();
|
||||||
}
|
}
|
||||||
@@ -20,8 +23,7 @@ public abstract class DrawObject {
|
|||||||
public void setIndex(int index){
|
public void setIndex(int index){
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract void draw(Graphics2D g2);
|
public abstract void draw(Graphics2D g2);
|
||||||
public abstract void update(float factor);
|
public abstract void update(float factor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ import model.objects.Path;
|
|||||||
|
|
||||||
public class Enemy extends DrawObject {
|
public class Enemy extends DrawObject {
|
||||||
|
|
||||||
public static final double distanceToOctagon = 1000,secondsToEnd = 5.0;
|
public static final double distanceToOctagon = 1000,
|
||||||
private int length;
|
secondsToEnd = 5.0;
|
||||||
private double lengthOf1Side,distanceFromStart;//lengthOf1Side wordt alleen gebruikt als de lijn een schuine lijn is.
|
private int length;
|
||||||
public Line2D enemy;
|
private double lengthOf1Side,
|
||||||
private Color c;
|
distanceFromStart; //lengthOf1Side wordt alleen gebruikt als de lijn een schuine lijn is.
|
||||||
private Path path;
|
public Line2D enemy;
|
||||||
|
private Color c;
|
||||||
|
private Path path;
|
||||||
|
|
||||||
public Enemy(int pathID,int lengthOfEnemy,Color c,Path path){
|
public Enemy(int pathID,int lengthOfEnemy,Color c,Path path){
|
||||||
super();
|
super();
|
||||||
@@ -89,9 +91,7 @@ public class Enemy extends DrawObject {
|
|||||||
double angleX,angleY;
|
double angleX,angleY;
|
||||||
angleX = Math.cos(Math.toRadians(45))*distanceFromStart;
|
angleX = Math.cos(Math.toRadians(45))*distanceFromStart;
|
||||||
angleY = Math.sin(Math.toRadians(45))*distanceFromStart;
|
angleY = Math.sin(Math.toRadians(45))*distanceFromStart;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch(index){
|
switch(index){
|
||||||
case 0:
|
case 0:
|
||||||
y1 = path.getY1() + distanceFromStart;
|
y1 = path.getY1() + distanceFromStart;
|
||||||
|
|||||||
@@ -29,31 +29,26 @@ public class Player extends DrawObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2){//
|
public void draw(Graphics2D g2){//
|
||||||
subImgX = (indexCursor % 8)*100;
|
subImgX = (indexCursor % 8) * 100;
|
||||||
subImgY = (indexCursor / 8)*100;
|
subImgY = (indexCursor / 8) * 100;
|
||||||
|
subImgXBeat = (indexBeat % 9 ) * 100;
|
||||||
subImgXBeat = (indexBeat % 9)*100;
|
|
||||||
|
|
||||||
|
|
||||||
BufferedImage subImg2 = pulse.getSubimage(subImgXBeat,0,100,100);
|
BufferedImage subImg2 = pulse.getSubimage(subImgXBeat,0,100,100);
|
||||||
g2.drawImage(subImg2, transform, null);
|
g2.drawImage(subImg2, transform, null);
|
||||||
|
|
||||||
|
|
||||||
BufferedImage subImg = img.getSubimage(subImgX,subImgY,100,100);
|
BufferedImage subImg = img.getSubimage(subImgX,subImgY,100,100);
|
||||||
g2.drawImage(subImg, transform, null);
|
g2.drawImage(subImg, transform, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float update){
|
public void update(float update){
|
||||||
if(beat){
|
if(beat){
|
||||||
indexBeat++;
|
indexBeat++;
|
||||||
if(indexBeat >= 9)
|
if(indexBeat >= 9) {
|
||||||
{
|
|
||||||
indexBeat = 0;
|
indexBeat = 0;
|
||||||
beat = false;
|
beat = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
indexCursor++;
|
indexCursor++;
|
||||||
indexCursor%=32;
|
indexCursor%=32;
|
||||||
|
|
||||||
@@ -68,7 +63,6 @@ public class Player extends DrawObject {
|
|||||||
public void setBeat() {
|
public void setBeat() {
|
||||||
beat = true;
|
beat = true;
|
||||||
indexBeat = 0;
|
indexBeat = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package model.drawObjects;
|
||||||
|
|
||||||
|
import model.gameState.PlayState;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
public class PointAnimation extends DrawObject {
|
||||||
|
|
||||||
|
LinkedList<Point2D.Double> puntenPos = new LinkedList<>();
|
||||||
|
LinkedList<Integer> puntenGain = new LinkedList<>();
|
||||||
|
LinkedList<Integer> iterations = new LinkedList<>();
|
||||||
|
|
||||||
|
public PointAnimation() { }
|
||||||
|
|
||||||
|
public void enemyDied(Point2D.Double p) {
|
||||||
|
puntenPos.add(new Point2D.Double(p.getX(), p.getY()));
|
||||||
|
puntenGain.add(PlayState.lastScoreChange);
|
||||||
|
iterations.add(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics2D g2) {
|
||||||
|
for (int x = 0; x < puntenPos.size(); x++) {
|
||||||
|
g2.drawString("" + puntenGain.get(x), (int) puntenPos.get(x).getX(), (int) puntenPos.get(x).getY());
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,21 +9,15 @@ import java.awt.RenderingHints;
|
|||||||
import java.awt.Transparency;
|
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 java.awt.image.WritableRenderedImage;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
import com.google.zxing.WriterException;
|
|
||||||
|
|
||||||
import model.GameModel;
|
import model.GameModel;
|
||||||
import model.SongHandler;
|
import model.SongHandler;
|
||||||
import model.objects.InfoPanel;
|
import model.objects.InfoPanel;
|
||||||
import model.objects.highscore.HighscoreName;
|
import model.objects.highscore.HighscoreName;
|
||||||
import net.glxn.qrgen.QRCode;
|
|
||||||
import net.glxn.qrgen.image.ImageType;
|
import com.google.zxing.WriterException;
|
||||||
|
|
||||||
import control.GameStateManager;
|
import control.GameStateManager;
|
||||||
import control.GameStateManager.State;
|
import control.GameStateManager.State;
|
||||||
import control.button.ButtonEvent;
|
import control.button.ButtonEvent;
|
||||||
@@ -35,11 +29,11 @@ import data.io.WebcamUploader;
|
|||||||
|
|
||||||
public class GameOverState extends GameState {
|
public class GameOverState extends GameState {
|
||||||
|
|
||||||
BufferedImage gameOver = Images.getImage(Images.ImageType.gameover);
|
private BufferedImage gameOver = Images.getImage(Images.ImageType.gameover);
|
||||||
VolatileImage background;
|
private VolatileImage background;
|
||||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 70);
|
private Font textFont = new Font("OCR A Extended", Font.BOLD, 70);
|
||||||
HighscoreName hsn;
|
private HighscoreName hsn;
|
||||||
int image_x = 0;
|
private int image_x = 0;
|
||||||
private boolean uploaded;
|
private boolean uploaded;
|
||||||
private BufferedImage QRimage;
|
private BufferedImage QRimage;
|
||||||
|
|
||||||
@@ -54,6 +48,14 @@ public class GameOverState extends GameState {
|
|||||||
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]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
JoystickHandler.REPEAT = true;
|
JoystickHandler.REPEAT = true;
|
||||||
uploaded = false;
|
uploaded = false;
|
||||||
}
|
}
|
||||||
@@ -71,7 +73,8 @@ public class GameOverState extends GameState {
|
|||||||
if(!uploaded)
|
if(!uploaded)
|
||||||
hsn.drawName(g2);
|
hsn.drawName(g2);
|
||||||
else if(QRimage != null){
|
else if(QRimage != null){
|
||||||
g2.drawImage(QRimage, 400, 600, 400, 400, null);
|
g2.drawImage(QRimage, (1280/2)-(QRimage.getWidth()/2), 600,null);
|
||||||
|
//1280 is de breedte van de panel
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -80,6 +83,9 @@ public class GameOverState extends GameState {
|
|||||||
public void buttonPressed(ButtonEvent e) {
|
public void buttonPressed(ButtonEvent e) {
|
||||||
//System.out.println("Name: "+hsn.getName());
|
//System.out.println("Name: "+hsn.getName());
|
||||||
switch(e.getButton().getButtonID()){
|
switch(e.getButton().getButtonID()){
|
||||||
|
case 0:
|
||||||
|
gsm.setState(State.TITLE_STATE);
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if(hsn.getName().trim().length() >= 3)
|
if(hsn.getName().trim().length() >= 3)
|
||||||
{
|
{
|
||||||
@@ -98,7 +104,6 @@ public class GameOverState extends GameState {
|
|||||||
}
|
}
|
||||||
uploaded = true;
|
uploaded = true;
|
||||||
|
|
||||||
System.out.println(id);
|
|
||||||
}else{
|
}else{
|
||||||
gsm.setState(State.MENU_STATE);
|
gsm.setState(State.MENU_STATE);
|
||||||
}
|
}
|
||||||
@@ -106,6 +111,10 @@ public class GameOverState extends GameState {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
gsm.setState(State.MENU_STATE);
|
gsm.setState(State.MENU_STATE);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
gsm.setState(State.HELP_STATE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,4 +26,6 @@ public abstract class GameState {
|
|||||||
public abstract void buttonPressed(ButtonEvent e);
|
public abstract void buttonPressed(ButtonEvent e);
|
||||||
public abstract void buttonReleased(ButtonEvent e);
|
public abstract void buttonReleased(ButtonEvent e);
|
||||||
public abstract void onJoystickMoved(JoystickEvent e);
|
public abstract void onJoystickMoved(JoystickEvent e);
|
||||||
|
|
||||||
|
public void stopAudio() { sh.close(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,12 @@ import data.io.SQLConnector;
|
|||||||
|
|
||||||
public class HelpState extends GameState {
|
public class HelpState extends GameState {
|
||||||
|
|
||||||
BufferedImage help = Images.getImage(ImageType.help);
|
private BufferedImage help = Images.getImage(ImageType.help);
|
||||||
VolatileImage background;
|
private VolatileImage background;
|
||||||
Font textFontSmall = new Font("OCR A Extended", Font.BOLD, 15);
|
private Font textFontSmall = new Font("OCR A Extended", Font.BOLD, 15);
|
||||||
|
|
||||||
|
int index = 0,
|
||||||
int index = 0;
|
frame;
|
||||||
int frame;
|
|
||||||
|
|
||||||
|
|
||||||
public HelpState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
|
public HelpState(GameStateManager gsm, SongHandler sh, SQLConnector sql){
|
||||||
@@ -41,23 +40,18 @@ public class HelpState extends GameState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
|
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed(ButtonEvent e) {
|
public void buttonPressed(ButtonEvent e) {
|
||||||
|
if(e.getButton().getButtonID() == 2)
|
||||||
if(e.getButton().getButtonID() == 2) {
|
|
||||||
gsm.setState(State.MENU_STATE);
|
gsm.setState(State.MENU_STATE);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+58
-153
@@ -40,38 +40,35 @@ public class MenuState extends GameState {
|
|||||||
private ArrayList<DifficultyButton> buttons2;
|
private ArrayList<DifficultyButton> buttons2;
|
||||||
private int selected, oldselected;
|
private int selected, oldselected;
|
||||||
private List<Song> songs;
|
private List<Song> songs;
|
||||||
SQLConnector sql = new SQLConnector();
|
private SQLConnector sql;
|
||||||
|
|
||||||
private int animationcounter;
|
private int animationcounter;
|
||||||
private boolean subscreen, startanimation;
|
private boolean subscreen, startanimation;
|
||||||
private VolatileImage mainScreenBackground, subScreenBackground, subScreenForeground;
|
private VolatileImage mainScreenBackground, subScreenBackground, subScreenForeground;
|
||||||
|
|
||||||
int yPosDiffButton = 900;
|
|
||||||
private int difSelect=0, oldDifSelect = -1;
|
private int difSelect=0, oldDifSelect = -1;
|
||||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 50);
|
Font textFont = new Font("OCR A Extended", Font.BOLD, 50);
|
||||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 35);
|
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 35);
|
||||||
Font textFont3 = new Font("OCR A Extended", Font.BOLD, 20);
|
Font textFont3 = new Font("OCR A Extended", Font.BOLD, 20);
|
||||||
Font textFontSmall = new Font("OCR A Extended", Font.BOLD, 15);
|
Font textFontSmall = new Font("OCR A Extended", Font.BOLD, 15);
|
||||||
BufferedImage aanwijzers = Images.getImage(ImageType.aanwijzers);
|
BufferedImage aanwijzers = Images.getImage(ImageType.aanwijzers);
|
||||||
int index = 0;
|
|
||||||
|
private int index = 0,
|
||||||
|
yPosDiffButton = 900,
|
||||||
|
kleurButton1 = 0,
|
||||||
int kleurButton1 = 0;
|
kleurButton2 = 1,
|
||||||
int kleurButton2 = 1;
|
kleurButton3 = 2,
|
||||||
int kleurButton3 = 2;
|
kleurButton4 = 3,
|
||||||
int kleurButton4 = 3;
|
kleurButton5 = 4;
|
||||||
int kleurButton5 = 4;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MenuState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
public MenuState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||||
super(gsm, sh, sql);
|
super(gsm, sh, sql);
|
||||||
buttons = new ArrayList<MenuButton>();
|
buttons = new ArrayList<>();
|
||||||
buttons2 = new ArrayList<DifficultyButton>();
|
buttons2 = new ArrayList<>();
|
||||||
this.songs = sh.getSongs();
|
this.songs = sh.getSongs();
|
||||||
startanimation = true;
|
startanimation = true;
|
||||||
subscreen = false;
|
subscreen = false;
|
||||||
|
this.sql = sql;
|
||||||
|
|
||||||
selected = 0;
|
selected = 0;
|
||||||
oldselected = -1;
|
oldselected = -1;
|
||||||
@@ -92,23 +89,19 @@ public class MenuState extends GameState {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
if(subscreen)
|
if(subscreen) {
|
||||||
{
|
|
||||||
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]);
|
||||||
generateSubScreenForeground();
|
generateSubScreenForeground();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||||
|
|
||||||
ButtonHandler.getButton(5).setColor(GameModel.colors[1]);
|
ButtonHandler.getButton(5).setColor(GameModel.colors[1]);
|
||||||
ButtonHandler.getButton(6).setColor(GameModel.colors[4]);
|
ButtonHandler.getButton(6).setColor(GameModel.colors[4]);
|
||||||
JoystickHandler.REPEAT = true;
|
JoystickHandler.REPEAT = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -118,20 +111,18 @@ public class MenuState extends GameState {
|
|||||||
if(animationcounter == 5){
|
if(animationcounter == 5){
|
||||||
startanimation = false;
|
startanimation = false;
|
||||||
}
|
}
|
||||||
}else if(subscreen){
|
}/*else if(subscreen){
|
||||||
//nextScreen();
|
//nextScreen();
|
||||||
}else{
|
}else{
|
||||||
//previousScreen();
|
//previousScreen();
|
||||||
}
|
}*/
|
||||||
if(selected != oldselected){
|
if(selected != oldselected){
|
||||||
for(int i = 0; i < buttons.size(); i++){
|
for(int i = 0; i < buttons.size(); i++)
|
||||||
buttons.get(i).setSong(selectedToSong(selected+(i-2)));
|
buttons.get(i).setSong(selectedToSong(selected+(i-2)));
|
||||||
|
|
||||||
}
|
|
||||||
oldselected = selected;
|
oldselected = selected;
|
||||||
}
|
}
|
||||||
if(difSelect != oldDifSelect)
|
if(difSelect != oldDifSelect) {
|
||||||
{
|
|
||||||
oldDifSelect = difSelect;
|
oldDifSelect = difSelect;
|
||||||
generateSubScreenForeground();
|
generateSubScreenForeground();
|
||||||
}
|
}
|
||||||
@@ -216,26 +207,20 @@ public class MenuState extends GameState {
|
|||||||
if(subscreen){
|
if(subscreen){
|
||||||
if(e.getJoystick().getPos() == Joystick.Position.DOWN){
|
if(e.getJoystick().getPos() == Joystick.Position.DOWN){
|
||||||
difSelect--;
|
difSelect--;
|
||||||
if(difSelect < 0){
|
if(difSelect < 0)
|
||||||
difSelect += buttons2.size();
|
difSelect += buttons2.size();
|
||||||
}
|
else if(e.getJoystick().getPos() == Joystick.Position.UP)
|
||||||
}else if(e.getJoystick().getPos() == Joystick.Position.UP){
|
difSelect++;
|
||||||
difSelect++;
|
if(difSelect > buttons2.size()-1)
|
||||||
if(difSelect > buttons2.size()-1){
|
|
||||||
difSelect = 0;
|
difSelect = 0;
|
||||||
}
|
|
||||||
|
|
||||||
//System.out.println(difSelect);
|
|
||||||
}
|
}
|
||||||
else if(e.getJoystick().getPos() == Position.CENTER)
|
else if(e.getJoystick().getPos() == Joystick.Position.CENTER)
|
||||||
{
|
|
||||||
sh.set(selectedToSong(selected).getSongs().get(difSelect));
|
sh.set(selectedToSong(selected).getSongs().get(difSelect));
|
||||||
}
|
|
||||||
//generateSubScreenForeground();
|
//generateSubScreenForeground();
|
||||||
}else{ //Screen for selecting song
|
}else{ //Screen for selecting song
|
||||||
if(e.getJoystick().getPos() == Joystick.Position.DOWN){
|
if(e.getJoystick().getPos() == Joystick.Position.DOWN){
|
||||||
selected++;
|
selected++;
|
||||||
|
|
||||||
kleurButton1++;
|
kleurButton1++;
|
||||||
kleurButton1 %= 6;
|
kleurButton1 %= 6;
|
||||||
|
|
||||||
@@ -250,41 +235,27 @@ public class MenuState extends GameState {
|
|||||||
|
|
||||||
kleurButton5++;
|
kleurButton5++;
|
||||||
kleurButton5 %= 6;
|
kleurButton5 %= 6;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else if(e.getJoystick().getPos() == Joystick.Position.UP){
|
}else if(e.getJoystick().getPos() == Joystick.Position.UP){
|
||||||
selected--;
|
selected--;
|
||||||
kleurButton1--;
|
|
||||||
if(kleurButton1 < 0){
|
|
||||||
kleurButton1 = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
kleurButton2--;
|
|
||||||
if(kleurButton2 < 0){
|
|
||||||
kleurButton2 = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
kleurButton3--;
|
|
||||||
if(kleurButton3 < 0){
|
|
||||||
kleurButton3 = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
kleurButton4--;
|
|
||||||
if(kleurButton4 < 0){
|
|
||||||
kleurButton4 = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
kleurButton5--;
|
|
||||||
if(kleurButton5 < 0){
|
|
||||||
kleurButton5 = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
if(--kleurButton1 < 0)
|
||||||
|
kleurButton1 = 5;
|
||||||
|
|
||||||
|
if(--kleurButton2 < 0)
|
||||||
|
kleurButton2 = 5;
|
||||||
|
|
||||||
|
if(--kleurButton3 < 0)
|
||||||
|
kleurButton3 = 5;
|
||||||
|
|
||||||
|
if(--kleurButton4 < 0)
|
||||||
|
kleurButton4 = 5;
|
||||||
|
|
||||||
|
if(--kleurButton5 < 0)
|
||||||
|
kleurButton5 = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(e.getJoystick().getPos() == Position.CENTER)
|
else if(e.getJoystick().getPos() == Joystick.Position.CENTER)
|
||||||
{
|
{
|
||||||
buttons2.clear();
|
buttons2.clear();
|
||||||
int instanceNr = 0;
|
int instanceNr = 0;
|
||||||
@@ -312,9 +283,9 @@ public class MenuState extends GameState {
|
|||||||
g2.setPaint(new GradientPaint(0, 0, new Color(0,0,1, 0.6f),1280,1024 ,new Color(0,0,1, 0.2f)));
|
g2.setPaint(new GradientPaint(0, 0, new Color(0,0,1, 0.6f),1280,1024 ,new Color(0,0,1, 0.2f)));
|
||||||
g2.fillRect(0, 0, 1280, 1024);
|
g2.fillRect(0, 0, 1280, 1024);
|
||||||
g2.setPaint(new GradientPaint(0, 0, new Color(1,1,0, 0.6f),1280,1024 ,new Color(0,0,1, 0.2f)));
|
g2.setPaint(new GradientPaint(0, 0, new Color(1,1,0, 0.6f),1280,1024 ,new Color(0,0,1, 0.2f)));
|
||||||
|
|
||||||
|
Polygon triangle2 = new Polygon();
|
||||||
Polygon triangle2 = new Polygon();
|
|
||||||
triangle2.addPoint(0, 0);
|
triangle2.addPoint(0, 0);
|
||||||
triangle2.addPoint(0, 1024/4+50);
|
triangle2.addPoint(0, 1024/4+50);
|
||||||
triangle2.addPoint(1280/2+50, 0);
|
triangle2.addPoint(1280/2+50, 0);
|
||||||
@@ -331,7 +302,7 @@ public class MenuState extends GameState {
|
|||||||
g2.drawString("Main Menu", 32, 60);
|
g2.drawString("Main Menu", 32, 60);
|
||||||
|
|
||||||
g2.setFont(textFontSmall);
|
g2.setFont(textFontSmall);
|
||||||
|
|
||||||
//select
|
//select
|
||||||
g2.setColor(GameModel.colors[0]);
|
g2.setColor(GameModel.colors[0]);
|
||||||
g2.fillOval(20, 860, 30, 30);
|
g2.fillOval(20, 860, 30, 30);
|
||||||
@@ -401,17 +372,16 @@ public class MenuState extends GameState {
|
|||||||
if(highscores.isEmpty())
|
if(highscores.isEmpty())
|
||||||
{
|
{
|
||||||
highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||||
|
|
||||||
if(highscores.isEmpty())
|
if(highscores.isEmpty())
|
||||||
{
|
|
||||||
highscoresFound = false;
|
highscoresFound = false;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
g2.drawString("All Time Highscores", 30, 300);
|
g2.drawString("All Time Highscores", 30, 300);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g2.drawString("Daily Highscore", 30, 300);
|
g2.drawString("Daily Highscore", 30, 300);
|
||||||
g2.setFont(textFont2);
|
|
||||||
|
g2.setFont(textFont2);
|
||||||
if(highscoresFound)
|
if(highscoresFound)
|
||||||
{
|
{
|
||||||
HIGHSCORES_TO_DISPLAY = HIGHSCORES_TO_DISPLAY > highscores.size() ? highscores.size() : HIGHSCORES_TO_DISPLAY;
|
HIGHSCORES_TO_DISPLAY = HIGHSCORES_TO_DISPLAY > highscores.size() ? highscores.size() : HIGHSCORES_TO_DISPLAY;
|
||||||
@@ -424,59 +394,16 @@ public class MenuState extends GameState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
g2.drawString("No Highscores found", 30, 400);
|
g2.drawString("No Highscores found", 30, 400);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
List<Highscore> highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
List<Highscore> highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||||
List<Highscore> dailyHighs = new ArrayList<Highscore>();
|
List<Highscore> dailyHighs = new ArrayList<Highscore>();
|
||||||
int highest = 0;
|
int highest = 0;
|
||||||
int oldHighest = 0;
|
int oldHighest = 0;
|
||||||
|
|
||||||
Date date = new Date();
|
|
||||||
int time = date.getDay();
|
|
||||||
int dailyHighest = 0;
|
|
||||||
int oldDailyHighest = 0;
|
|
||||||
|
|
||||||
|
|
||||||
String name = "";
|
|
||||||
String dailyName = "";
|
|
||||||
|
|
||||||
for(Highscore h:highscores){
|
|
||||||
|
|
||||||
oldHighest = h.getScore();
|
|
||||||
if(oldHighest > highest){
|
|
||||||
highest = oldHighest;
|
|
||||||
name = h.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(time == h.getDate().getDay())
|
|
||||||
dailyHighs.add(h);
|
|
||||||
for(int i = 0; i < dailyHighs.size(); i ++){
|
|
||||||
oldDailyHighest = dailyHighs.get(i).getDate().getDay();
|
|
||||||
if(oldDailyHighest > dailyHighest){
|
|
||||||
dailyHighest = oldDailyHighest;
|
|
||||||
dailyName = h.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
g2.setColor(Color.WHITE);
|
|
||||||
g2.drawString("Author: " + selectedToSong(selected).getAuthor(), 30, 200);
|
|
||||||
g2.drawString("Overall Highscore: " + highest , 30, 300);
|
|
||||||
g2.drawString("Overall Highscore by: " + name, 30, 400);
|
|
||||||
g2.drawString("Daily Highscore: " + dailyHighest, 30, 500);
|
|
||||||
g2.drawString("Daily Highscore by: : " + dailyName, 30, 600);
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
for(DifficultyButton b : buttons2)
|
||||||
|
|
||||||
for(DifficultyButton b : buttons2){
|
|
||||||
b.draw(g2);
|
b.draw(g2);
|
||||||
}
|
|
||||||
|
|
||||||
g2.setFont(textFontSmall);
|
g2.setFont(textFontSmall);
|
||||||
|
|
||||||
@@ -507,50 +434,28 @@ public class MenuState extends GameState {
|
|||||||
g2.fillPolygon(p2);
|
g2.fillPolygon(p2);
|
||||||
|
|
||||||
g2.drawString("Down", 55, 1000);
|
g2.drawString("Down", 55, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
subScreenForeground.createGraphics();
|
subScreenForeground.createGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buttonInAnimation(int button){
|
public void buttonInAnimation(int button){
|
||||||
if(button >= 0 && button < buttons.size() ){
|
if(button >= 0 && button < buttons.size()){
|
||||||
buttons.get(button).setX(buttons.get(button).getX()+40);
|
buttons.get(button).setX(buttons.get(button).getX()+40);
|
||||||
if(buttons.get(button).getX() >= 320){
|
|
||||||
|
if(buttons.get(button).getX() >= 320)
|
||||||
animationcounter++;
|
animationcounter++;
|
||||||
}
|
if(buttons.get(button).getX() >= -200)
|
||||||
if(buttons.get(button).getX() >= -200){
|
|
||||||
buttonInAnimation(button+1);
|
buttonInAnimation(button+1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void nextScreen(){
|
|
||||||
if(buttons.get(0).getX() > -700){
|
|
||||||
for(MenuButton b:buttons){
|
|
||||||
b.setX(b.getX()-100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void previousScreen(){
|
|
||||||
if(buttons.get(0).getX() < 300){
|
|
||||||
for(MenuButton b:buttons){
|
|
||||||
b.setX(b.getX()+100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Song selectedToSong(int s){
|
public Song selectedToSong(int s){
|
||||||
s %= songs.size();
|
s %= songs.size();
|
||||||
if(s < 0){
|
if(s < 0)
|
||||||
return songs.get(songs.size()+s);
|
return songs.get(songs.size()+s);
|
||||||
}else{
|
else
|
||||||
return songs.get(s);
|
return songs.get(s);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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.Ellipse2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@@ -36,7 +37,9 @@ public class PlayState extends GameState {
|
|||||||
|
|
||||||
public static int sizeOfEnemy = 40;
|
public static int sizeOfEnemy = 40;
|
||||||
public static int currentScore = 0;
|
public static int currentScore = 0;
|
||||||
public static int comboScore = 0;
|
public static int comboMulitplier = 0;
|
||||||
|
public static int lastScoreChange = 0;
|
||||||
|
public static int sinceScoreChanged = 75;
|
||||||
public static double lifePoints = 100;
|
public static double lifePoints = 100;
|
||||||
|
|
||||||
private int enemies_hit = 0;
|
private int enemies_hit = 0;
|
||||||
@@ -46,6 +49,8 @@ public class PlayState extends GameState {
|
|||||||
|
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
|
private boolean prestateShown = false;
|
||||||
|
|
||||||
private long oldProgress = 0;
|
private long oldProgress = 0;
|
||||||
|
|
||||||
public PlayState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
public PlayState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||||
@@ -60,9 +65,7 @@ public class PlayState extends GameState {
|
|||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
init = true;
|
init = true;
|
||||||
lifePoints = 100;
|
|
||||||
currentScore = 0;
|
currentScore = 0;
|
||||||
comboScore = 0;
|
|
||||||
oldProgress = 0;
|
oldProgress = 0;
|
||||||
|
|
||||||
enemies_hit = 0;
|
enemies_hit = 0;
|
||||||
@@ -71,9 +74,7 @@ public class PlayState extends GameState {
|
|||||||
joystick_moved = 0;
|
joystick_moved = 0;
|
||||||
|
|
||||||
for(Path p : area.paths)
|
for(Path p : area.paths)
|
||||||
{
|
|
||||||
p.getEnemysInPath().clear();
|
p.getEnemysInPath().clear();
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||||
Button b = ButtonHandler.getButton(i);
|
Button b = ButtonHandler.getButton(i);
|
||||||
@@ -90,7 +91,12 @@ public class PlayState extends GameState {
|
|||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
if(init)
|
if(init)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!prestateShown) {
|
||||||
|
gsm.setState(control.GameStateManager.State.PRE_GAME_STATE);
|
||||||
|
prestateShown = true;
|
||||||
|
}
|
||||||
|
|
||||||
long progress = (long) ((sh.getProgress() / 1000) + (Enemy.secondsToEnd * 1000));
|
long progress = (long) ((sh.getProgress() / 1000) + (Enemy.secondsToEnd * 1000));
|
||||||
|
|
||||||
for (ButtonInstance bu : sh.getCurrentSongInstance().getButtonsBetween(oldProgress, progress)) {
|
for (ButtonInstance bu : sh.getCurrentSongInstance().getButtonsBetween(oldProgress, progress)) {
|
||||||
@@ -107,62 +113,66 @@ public class PlayState extends GameState {
|
|||||||
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*1000*2)
|
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*1000*2)
|
||||||
endGame();
|
endGame();
|
||||||
|
|
||||||
// System.out.println(progress - oldProgress + " / " + area.paths.get(player.getIndex()).getEnemysInPath().size());
|
|
||||||
|
|
||||||
oldProgress = progress;
|
oldProgress = progress;
|
||||||
|
|
||||||
Enemy closedEnemy = null;
|
Enemy closedEnemy = null;
|
||||||
player.update(factor);
|
player.update(factor);
|
||||||
for (Path path : area.paths) {
|
|
||||||
|
|
||||||
|
for (Path path : area.paths) {
|
||||||
Iterator<Enemy> enemyIterator = path.getEnemysInPath().iterator();
|
Iterator<Enemy> enemyIterator = path.getEnemysInPath().iterator();
|
||||||
|
|
||||||
while (enemyIterator.hasNext()) {
|
while (enemyIterator.hasNext()) {
|
||||||
|
|
||||||
Enemy e = enemyIterator.next();
|
Enemy e = enemyIterator.next();
|
||||||
// System.out.println("Path: "+e.getIndex()+"\tDistance: "+(Enemy.distanceToOctagon-e.getDistanceFromStart()));
|
|
||||||
if (e.getDistanceFromStart() > Enemy.distanceToOctagon + (sizeOfEnemy * 1.5)) {
|
if (e.getDistanceFromStart() > Enemy.distanceToOctagon + (sizeOfEnemy * 1.5)) {
|
||||||
enemyIterator.remove();
|
enemyIterator.remove();
|
||||||
lifePoints -= 5;
|
lastScoreChange = -5;
|
||||||
comboScore /= 2;
|
lifePoints -= lastScoreChange;
|
||||||
|
sinceScoreChanged = 1;
|
||||||
|
comboMulitplier = 0;
|
||||||
enemies_missed++;
|
enemies_missed++;
|
||||||
}
|
}
|
||||||
if(closedEnemy == null){
|
if(closedEnemy == null)
|
||||||
closedEnemy = e;
|
closedEnemy = e;
|
||||||
}
|
if((Enemy.distanceToOctagon-closedEnemy.getDistanceFromStart()) > (Enemy.distanceToOctagon-e.getDistanceFromStart()))
|
||||||
if((Enemy.distanceToOctagon-closedEnemy.getDistanceFromStart()) > (Enemy.distanceToOctagon-e.getDistanceFromStart())){
|
|
||||||
closedEnemy = e;
|
closedEnemy = e;
|
||||||
}
|
|
||||||
e.update(factor);
|
e.update(factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lifePoints -= 0.002 * factor;
|
lifePoints -= 0.002 * factor;
|
||||||
|
|
||||||
infoPanel.updateIPanel();
|
infoPanel.updateIPanel();
|
||||||
|
|
||||||
if(lifePoints <= 0)
|
if(lifePoints <= 0) // STERF!
|
||||||
{
|
|
||||||
endGame();
|
endGame();
|
||||||
}
|
|
||||||
if(comboScore >= 100)
|
if(comboMulitplier >= 20) { // '20' hit streak voor bonuspunten
|
||||||
{
|
comboMulitplier = 0;
|
||||||
comboScore = 0;
|
sinceScoreChanged = 1;
|
||||||
currentScore += 500;
|
lastScoreChange = 500;
|
||||||
|
currentScore += lastScoreChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
area.count();
|
area.count();
|
||||||
if(closedEnemy == null){
|
if(closedEnemy == null)
|
||||||
area.pathPainted(-1, null);
|
area.pathPainted(-1, null);
|
||||||
}else{
|
else
|
||||||
area.pathPainted(closedEnemy.getIndex(), closedEnemy.getColor());
|
area.pathPainted(closedEnemy.getIndex(), closedEnemy.getColor());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endGame() {
|
private void endGame() {
|
||||||
gsm.setState(State.GAMEOVER_STATE);
|
if(sh.getProgress()/1000 > 5000) {
|
||||||
sql.addPlaydata(sh.getCurrentSong(), sh.getCurrentSongInstance(), sh.getProgress()/1000, enemies_missed, enemies_hit, buttons_pressed, joystick_moved);
|
sql.addPlaydata(sh.getCurrentSong(), sh.getCurrentSongInstance(), sh.getProgress()/1000, enemies_missed, enemies_hit, buttons_pressed, joystick_moved);
|
||||||
|
sh.getCurrentSongInstance().played();
|
||||||
|
}
|
||||||
|
|
||||||
|
comboMulitplier = 0;
|
||||||
|
prestateShown = false;
|
||||||
|
|
||||||
|
if(currentScore == 0)
|
||||||
|
gsm.setState(State.MENU_STATE);
|
||||||
|
else
|
||||||
|
gsm.setState(State.GAMEOVER_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -171,6 +181,7 @@ public class PlayState extends GameState {
|
|||||||
infoPanel.draw(g2);
|
infoPanel.draw(g2);
|
||||||
g2.setClip(borderRect);
|
g2.setClip(borderRect);
|
||||||
area.draw(g2);
|
area.draw(g2);
|
||||||
|
sinceScoreChanged++;
|
||||||
|
|
||||||
for (Path p : area.paths) {
|
for (Path p : area.paths) {
|
||||||
if (p.getEnemysInPath() != null) {
|
if (p.getEnemysInPath() != null) {
|
||||||
@@ -182,14 +193,13 @@ public class PlayState extends GameState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
player.draw(g2);
|
player.draw(g2);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
if(!Window.ON_RASP){
|
if(!Window.ON_RASP){
|
||||||
int width,height;
|
int width,height;
|
||||||
width = g2.getFontMetrics().stringWidth("");
|
|
||||||
height = g2.getFontMetrics().getHeight();
|
height = g2.getFontMetrics().getHeight();
|
||||||
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||||
Ellipse2D oval = new Ellipse2D.Double(880+(50*i), 0, 50, 50);
|
Ellipse2D oval = new Ellipse2D.Double(880+(50*i), 0, 50, 50);
|
||||||
@@ -210,34 +220,32 @@ 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;
|
comboMulitplier++;
|
||||||
comboScore += 5;
|
lastScoreChange = 5 * comboMulitplier;
|
||||||
|
currentScore += lastScoreChange;
|
||||||
|
sinceScoreChanged = 1;
|
||||||
|
area.enemyDied((Point2D.Double) enemy.getEnemy().getP1());
|
||||||
lifePoints = Math.min(lifePoints+10, 100);
|
lifePoints = Math.min(lifePoints+10, 100);
|
||||||
area.setHitAreaColor(enemy.getColor());
|
area.setHitAreaColor(enemy.getColor());
|
||||||
area.hit();
|
area.hit();
|
||||||
enemies_hit++;
|
enemies_hit++;
|
||||||
enemysInPath.remove();
|
enemysInPath.remove();
|
||||||
notHit = false;
|
notHit = false;
|
||||||
|
infoPanel.throwACoin(); // Coin Animatie starten bij hit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
player.setBeat();
|
player.setBeat();
|
||||||
|
|
||||||
if(notHit)
|
if(notHit) {
|
||||||
{
|
|
||||||
if(area.paths.get(player.getIndex()).getEnemysInPath().size() > 0)
|
if(area.paths.get(player.getIndex()).getEnemysInPath().size() > 0)
|
||||||
{
|
|
||||||
lifePoints -= 1.5;
|
lifePoints -= 1.5;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.getButton().getButtonID() == 0)
|
if(e.getButton().getButtonID() == 0)
|
||||||
{
|
|
||||||
endGame();
|
endGame();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
buttons_pressed++;
|
buttons_pressed++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package model.gameState;
|
||||||
|
|
||||||
|
import data.io.SQLConnector;
|
||||||
|
import image.Images;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import model.SongHandler;
|
||||||
|
import control.GameStateManager;
|
||||||
|
import control.button.ButtonEvent;
|
||||||
|
import control.joystick.JoystickEvent;
|
||||||
|
|
||||||
|
public class PreGameState extends GameState {
|
||||||
|
|
||||||
|
private double index2 = 3,
|
||||||
|
index = 3;
|
||||||
|
|
||||||
|
private int grootte = 150;
|
||||||
|
|
||||||
|
private SQLConnector sql;
|
||||||
|
|
||||||
|
private BasicStroke s = new BasicStroke(20);
|
||||||
|
|
||||||
|
private BufferedImage screenshot;
|
||||||
|
|
||||||
|
public PreGameState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||||
|
super(gsm, sh, sql);
|
||||||
|
this.sql = sql;
|
||||||
|
screenshot = Images.getImage(Images.ImageType.screenshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float factor) {
|
||||||
|
|
||||||
|
index2 -= factor/1000;
|
||||||
|
index = (double) Math.round(index2*1000)/1000;
|
||||||
|
if(index <= 0){
|
||||||
|
grootte = 150;
|
||||||
|
index = 3;
|
||||||
|
index2 = 3;
|
||||||
|
gsm.setState(control.GameStateManager.State.PLAY_STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(grootte > 270)
|
||||||
|
grootte = 150;
|
||||||
|
grootte+=2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics2D g2) {
|
||||||
|
g2.drawImage(screenshot,0,0,1280,1024,null);
|
||||||
|
Font textFont = new Font("OCR A Extended", Font.BOLD,grootte);
|
||||||
|
g2.setFont(textFont);
|
||||||
|
g2.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!!!";
|
||||||
|
}
|
||||||
|
else if (index < 2){
|
||||||
|
text = "SET";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
text = "READY";
|
||||||
|
}
|
||||||
|
width = g2.getFontMetrics().stringWidth(text);
|
||||||
|
g2.drawString(text, (256+1024/2)-width/2, 600);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buttonPressed(ButtonEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buttonReleased(ButtonEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onJoystickMoved(JoystickEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,22 +21,22 @@ 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,
|
||||||
int frame;
|
indexKast = 0,
|
||||||
|
xKast = 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);
|
||||||
@@ -50,23 +50,25 @@ public class TitleState extends GameState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float factor) {
|
public void update(float factor) {
|
||||||
|
|
||||||
frame++;
|
frame++;
|
||||||
indexKast++;
|
indexKast++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
// Scherm beelt wat kleurrijke rectangles op het scherm.
|
||||||
int image_x = ((frame / 6) % 6) * 49;
|
if (frame > 0) {
|
||||||
g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640-122, 512, 245, 130, null);
|
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||||
|
createBackground();
|
||||||
|
}
|
||||||
|
if (frame > 160) {
|
||||||
xKast = indexKast/10;
|
// Code die de arcadekast en 'Press Start' toont.
|
||||||
xKast%=4;
|
int image_x = ((frame / 6) % 6) * 49;
|
||||||
//g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 640-122,650,300,400,null);
|
g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640 - 122, 512, 245, 130, null);
|
||||||
g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 100,300,300,400,null);
|
|
||||||
|
xKast = indexKast / 10;
|
||||||
|
xKast %= 4;
|
||||||
|
g2.drawImage(kast.getSubimage(xKast * 300, 0, 300, 400), 100, 300, 300, 400, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,7 +79,6 @@ public class TitleState extends GameState {
|
|||||||
gsm.setState(State.MENU_STATE);
|
gsm.setState(State.MENU_STATE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,35 +93,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.setFont(textFont);
|
|
||||||
g2.setColor(Color.WHITE);
|
|
||||||
g2.drawString("©2015 Team Hamtaro", 550, 1012);
|
|
||||||
|
|
||||||
g2.setColor(Color.RED);
|
|
||||||
g2.setFont(textFont2);
|
|
||||||
g2.drawString("Color", 385, 212);
|
|
||||||
g2.drawString("Strike", 390, 342);
|
|
||||||
g2.dispose();
|
|
||||||
background.createGraphics();
|
background.createGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,13 @@ package model.objects;
|
|||||||
|
|
||||||
import image.Images;
|
import image.Images;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.awt.Font;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.GradientPaint;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.Transparency;
|
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
|
|
||||||
import model.SongHandler;
|
import model.SongHandler;
|
||||||
|
import model.drawObjects.CoinAnimation;
|
||||||
|
import model.drawObjects.PointAnimation;
|
||||||
import model.gameState.PlayState;
|
import model.gameState.PlayState;
|
||||||
|
|
||||||
public class InfoPanel {
|
public class InfoPanel {
|
||||||
@@ -20,7 +18,12 @@ public class InfoPanel {
|
|||||||
private VolatileImage infoPanel;
|
private VolatileImage infoPanel;
|
||||||
private SongHandler sh;
|
private SongHandler sh;
|
||||||
private String time;
|
private String time;
|
||||||
|
|
||||||
|
private int tempComboMulitplier;
|
||||||
|
|
||||||
|
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
|
||||||
|
|
||||||
|
|
||||||
public InfoPanel(int x, int y, SongHandler sh){
|
public InfoPanel(int x, int y, SongHandler sh){
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -31,13 +34,6 @@ public class InfoPanel {
|
|||||||
|
|
||||||
public void updateIPanel() {
|
public void updateIPanel() {
|
||||||
totalHighscore = "" + PlayState.currentScore;
|
totalHighscore = "" + PlayState.currentScore;
|
||||||
// time = "";
|
|
||||||
// long progress = (sh.getProgress() / 1000);
|
|
||||||
// time = progress%1000 + time;
|
|
||||||
// progress /= 1000;
|
|
||||||
// time = progress%1000 + ":" + time;
|
|
||||||
// progress /= 1000;
|
|
||||||
// time = progress + ":" + time;
|
|
||||||
|
|
||||||
long progress = (sh.getProgress() / 1000);
|
long progress = (sh.getProgress() / 1000);
|
||||||
String millis = ((progress) % 1000) + "".length() > 3 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000);
|
String millis = ((progress) % 1000) + "".length() > 3 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000);
|
||||||
@@ -52,42 +48,66 @@ public class InfoPanel {
|
|||||||
Graphics2D g2 = infoPanel.createGraphics();
|
Graphics2D g2 = infoPanel.createGraphics();
|
||||||
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
g2.setRenderingHints(rh);
|
g2.setRenderingHints(rh);
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
|
||||||
// g2.setColor(Color.GRAY);
|
// g2.setColor(Color.GRAY);
|
||||||
GradientPaint gp = new GradientPaint(0, 0, new Color(245,245,245), 256, 1024, Color.WHITE);
|
GradientPaint gp = new GradientPaint(0, 0, new Color(245,245,245), 256, 1024, Color.WHITE);
|
||||||
g2.setPaint(gp);
|
g2.setPaint(gp);
|
||||||
g2.fillRect(x, y, 256, 1024);
|
g2.fillRect(x, y, 256, 1024);
|
||||||
|
|
||||||
|
// Score balk
|
||||||
g2.setColor(Color.BLACK);
|
g2.setColor(Color.BLACK);
|
||||||
g2.drawRect(x, y, 255, 1023);
|
g2.drawRect(x, y, 255, 1023);
|
||||||
|
|
||||||
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
|
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
|
||||||
g2.setFont(scoreFont);
|
g2.setFont(scoreFont);
|
||||||
g2.setColor(Color.GREEN);
|
g2.setColor(Color.GREEN);
|
||||||
g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30);
|
g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30);
|
||||||
|
|
||||||
g2.setColor(Color.BLACK);
|
// Laatste punten in-/decrease tonen.
|
||||||
|
if (PlayState.sinceScoreChanged < 60 && PlayState.sinceScoreChanged != 0) {
|
||||||
|
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(1 - (PlayState.sinceScoreChanged * 0.015))));
|
||||||
|
g2.setColor(Color.RED);
|
||||||
|
g2.drawString("+" + PlayState.lastScoreChange, 185, 40);
|
||||||
|
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
|
||||||
|
}
|
||||||
|
|
||||||
|
g2.setColor(Color.ORANGE);
|
||||||
g2.drawString("Score: " + totalHighscore, 25, 75);
|
g2.drawString("Score: " + totalHighscore, 25, 75);
|
||||||
|
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
// BALK
|
||||||
g2.drawRect(25, 100, 200, 30);
|
g2.drawRect(25, 100, 200, 30);
|
||||||
g2.drawRect(25, 300, 200, 700);
|
g2.drawRect(25, 300, 200, 700);
|
||||||
|
|
||||||
g2.drawString(sh.getCurrentSong().getTitle(), 25, 200);
|
g2.drawString(sh.getCurrentSong().getTitle(), 25, 200);
|
||||||
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230);
|
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230);
|
||||||
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
|
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
|
||||||
g2.drawString(time, 25, 290);
|
g2.drawString(time, 25, 290);
|
||||||
|
|
||||||
// GradientPaint gp = new GradientPaint(300, 0, new Color(200,200,255), 256, 1024, Color.WHITE);
|
// Controlen of coin animatie nodig is
|
||||||
// g2.setPaint(gp);
|
if (!coinAnimation.areWeDoneYet()) {
|
||||||
// g2.fillRect(x, y, 256, 1024);
|
coinAnimation.draw(g2);
|
||||||
|
// Score pas updaten wanneer coin in zijn laatste draw loop zit
|
||||||
|
if (coinAnimation.isLastLoop())
|
||||||
|
tempComboMulitplier = PlayState.comboMulitplier;
|
||||||
|
} else
|
||||||
|
tempComboMulitplier = PlayState.comboMulitplier;
|
||||||
|
|
||||||
|
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230);
|
||||||
|
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
|
||||||
|
g2.drawString(time, 25, 290);
|
||||||
|
|
||||||
|
g2.setColor(Color.YELLOW);
|
||||||
g2.setColor(Color.YELLOW);
|
g2.fillRect(25, 1000 - tempComboMulitplier * 35, 200, 35 * tempComboMulitplier);
|
||||||
g2.fillRect(25, 1000 - 7 * PlayState.comboScore, 200, 0 + 7 * PlayState.comboScore);
|
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
infoPanel.createGraphics();
|
infoPanel.createGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void throwACoin() {
|
||||||
|
coinAnimation.start(); // Teller weer op 1 zetten
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.awt.Font;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import main.Window;
|
||||||
import audio.Song;
|
import audio.Song;
|
||||||
|
|
||||||
public class MenuButton {
|
public class MenuButton {
|
||||||
@@ -50,9 +51,9 @@ public class MenuButton {
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
g2d.setColor(color.darker().darker());
|
g2d.setColor(color.darker().darker());
|
||||||
g2d.fillRect(x-5, y-5,890,80);
|
g2d.fillRect(x-5, y-5,990,80);
|
||||||
g2d.setColor(color);
|
g2d.setColor(color);
|
||||||
g2d.fillRect(x,y,880,70);
|
g2d.fillRect(x,y,980,70);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw text
|
//draw text
|
||||||
@@ -60,7 +61,14 @@ public class MenuButton {
|
|||||||
Font textFont = new Font("OCR A Extended", Font.BOLD,60);
|
Font textFont = new Font("OCR A Extended", Font.BOLD,60);
|
||||||
g2d.setFont(textFont);
|
g2d.setFont(textFont);
|
||||||
if(selected)
|
if(selected)
|
||||||
|
{
|
||||||
g2d.drawString(song.getTitle(), x+50, y+63);
|
g2d.drawString(song.getTitle(), x+50, y+63);
|
||||||
|
|
||||||
|
Font textFont2 = new Font("OCR A Extended", Font.PLAIN,30);
|
||||||
|
g2d.setFont(textFont2);
|
||||||
|
g2d.drawString("# Played: " + song.getTimesPlayed(), Window.WIDTH - 450 - Math.min(song.getAuthor().length()*16, 570), y+yy+45);
|
||||||
|
g2d.drawString("Author: " + song.getAuthor(), Window.WIDTH - 200 - Math.min(song.getAuthor().length()*16, 570) , y+yy+45);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
g2d.drawString(song.getTitle(), x+50, y+57);
|
g2d.drawString(song.getTitle(), x+50, y+57);
|
||||||
}
|
}
|
||||||
|
|||||||
+76
-60
@@ -2,41 +2,40 @@ package model.objects;
|
|||||||
|
|
||||||
import image.Images;
|
import image.Images;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.*;
|
||||||
import java.awt.BasicStroke;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Polygon;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.Stroke;
|
|
||||||
import java.awt.Transparency;
|
|
||||||
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 {
|
||||||
|
|
||||||
public List<Path> paths;
|
public List<Path> paths;
|
||||||
private Polygon innerHitAreaBorder,outsideHitAreaBorder;
|
private Polygon innerHitAreaBorder,outsideHitAreaBorder;
|
||||||
private GeneralPath hitArea;
|
private GeneralPath hitArea;
|
||||||
private Color hitAreaColor,pathColor = null;
|
private Color hitAreaColor,pathColor = null;
|
||||||
private VolatileImage background;
|
private VolatileImage background;
|
||||||
private boolean hit = false;
|
private boolean hit = false;
|
||||||
private int count = 0,maxCount = 100,pathID = -1;
|
private int count = 0,
|
||||||
|
maxCount = 100,
|
||||||
|
pathID = -1,
|
||||||
|
oldPathId = pathID;
|
||||||
|
|
||||||
|
private PointAnimation pointAnimation = new PointAnimation();
|
||||||
private Stroke stroke = new BasicStroke(5);
|
private Stroke stroke = new BasicStroke(5);
|
||||||
|
|
||||||
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
|
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
|
||||||
|
|
||||||
|
|
||||||
public PlayArea(double xToRight,double heightOfGameScreen,double widthOfGameScreen, int sizeOctagon) {
|
public PlayArea(double xToRight,double heightOfGameScreen,double widthOfGameScreen, int sizeOctagon) {
|
||||||
super();
|
super();
|
||||||
paths = new ArrayList<Path>();
|
paths = new ArrayList<>();
|
||||||
setHitAreaColor(Color.WHITE);
|
setHitAreaColor(Color.WHITE);
|
||||||
//make the polygons
|
//make the polygons
|
||||||
int amountOfAngles = 8;
|
int amountOfAngles = 8;
|
||||||
@@ -62,48 +61,36 @@ public class PlayArea {
|
|||||||
hitArea = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
|
hitArea = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
|
||||||
|
|
||||||
hitArea.moveTo(innerHitAreaBorder.xpoints[0], innerHitAreaBorder.ypoints[0]);
|
hitArea.moveTo(innerHitAreaBorder.xpoints[0], innerHitAreaBorder.ypoints[0]);
|
||||||
for(int i = 1; i < innerHitAreaBorder.npoints;i++){
|
for(int i = 1; i < innerHitAreaBorder.npoints;i++)
|
||||||
hitArea.lineTo(innerHitAreaBorder.xpoints[i], innerHitAreaBorder.ypoints[i]);
|
hitArea.lineTo(innerHitAreaBorder.xpoints[i], innerHitAreaBorder.ypoints[i]);
|
||||||
}
|
|
||||||
|
|
||||||
hitArea.moveTo(outsideHitAreaBorder.xpoints[0], outsideHitAreaBorder.ypoints[0]);
|
hitArea.moveTo(outsideHitAreaBorder.xpoints[0], outsideHitAreaBorder.ypoints[0]);
|
||||||
for(int i = 1; i < innerHitAreaBorder.npoints;i++){
|
for(int i = 1; i < innerHitAreaBorder.npoints;i++)
|
||||||
hitArea.lineTo(outsideHitAreaBorder.xpoints[i], outsideHitAreaBorder.ypoints[i]);
|
hitArea.lineTo(outsideHitAreaBorder.xpoints[i], outsideHitAreaBorder.ypoints[i]);
|
||||||
}
|
|
||||||
|
|
||||||
//make the paths
|
//make the paths
|
||||||
double angleX,angleY;
|
double angleX,angleY;
|
||||||
angleX = (Math.cos(Math.toRadians(45)))*Enemy.distanceToOctagon;
|
angleX = (Math.cos(Math.toRadians(45)))*Enemy.distanceToOctagon;
|
||||||
angleY = (Math.sin(Math.toRadians(45)))*Enemy.distanceToOctagon;
|
angleY = (Math.sin(Math.toRadians(45)))*Enemy.distanceToOctagon;
|
||||||
|
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]-Enemy.distanceToOctagon ,outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]));//top
|
paths.add(new Path(outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]-Enemy.distanceToOctagon,
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[7] + angleX,outsideHitAreaBorder.ypoints[7] - angleY ,outsideHitAreaBorder.xpoints[7],outsideHitAreaBorder.ypoints[7]));//right -top
|
outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]));//top
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[0]+Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[0] ,outsideHitAreaBorder.xpoints[0],outsideHitAreaBorder.ypoints[0]));//right
|
paths.add(new Path(outsideHitAreaBorder.xpoints[7] + angleX,outsideHitAreaBorder.ypoints[7] - angleY,
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[1]+angleX,outsideHitAreaBorder.ypoints[1]+angleY ,outsideHitAreaBorder.xpoints[1],outsideHitAreaBorder.ypoints[1]));//right -down
|
outsideHitAreaBorder.xpoints[7],outsideHitAreaBorder.ypoints[7]));//right -top
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]+Enemy.distanceToOctagon ,outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]));//down
|
paths.add(new Path(outsideHitAreaBorder.xpoints[0]+Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[0],
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[3] - angleX,outsideHitAreaBorder.ypoints[3] + angleY ,outsideHitAreaBorder.xpoints[3],outsideHitAreaBorder.ypoints[3]));//left -down
|
outsideHitAreaBorder.xpoints[0],outsideHitAreaBorder.ypoints[0]));//right
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[4] - Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[4] ,outsideHitAreaBorder.xpoints[4],outsideHitAreaBorder.ypoints[4]));//left
|
paths.add(new Path(outsideHitAreaBorder.xpoints[1]+angleX,outsideHitAreaBorder.ypoints[1]+angleY,
|
||||||
paths.add(new Path(outsideHitAreaBorder.xpoints[5] - angleX,outsideHitAreaBorder.ypoints[5] - angleY ,outsideHitAreaBorder.xpoints[5],outsideHitAreaBorder.ypoints[5]));//left -top
|
outsideHitAreaBorder.xpoints[1],outsideHitAreaBorder.ypoints[1]));//right -down
|
||||||
|
paths.add(new Path(outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]+Enemy.distanceToOctagon,
|
||||||
|
outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]));//down
|
||||||
//drawing into buffer
|
paths.add(new Path(outsideHitAreaBorder.xpoints[3] - angleX,outsideHitAreaBorder.ypoints[3] + angleY,
|
||||||
background = Images.initVolatileImage(1280,1024, Transparency.BITMASK);
|
outsideHitAreaBorder.xpoints[3],outsideHitAreaBorder.ypoints[3]));//left -down
|
||||||
Graphics2D g2 = background.createGraphics();
|
paths.add(new Path(outsideHitAreaBorder.xpoints[4] - Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[4],
|
||||||
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
outsideHitAreaBorder.xpoints[4],outsideHitAreaBorder.ypoints[4]));//left
|
||||||
g2.setRenderingHints(rh);
|
paths.add(new Path(outsideHitAreaBorder.xpoints[5] - angleX,outsideHitAreaBorder.ypoints[5] - angleY,
|
||||||
// g2.setColor(Color.WHITE);
|
outsideHitAreaBorder.xpoints[5],outsideHitAreaBorder.ypoints[5]));//left -top
|
||||||
// g2.fillRect(256, 0, 1024, 1024);
|
|
||||||
Line2D current;
|
generateBackground();
|
||||||
g2.setColor(Color.BLACK);
|
|
||||||
g2.setStroke(stroke);
|
|
||||||
for(int i = 0; i < paths.size(); i++){
|
|
||||||
current = paths.get(i);
|
|
||||||
g2.draw(current);
|
|
||||||
}
|
|
||||||
g2.draw(innerHitAreaBorder);
|
|
||||||
g2.draw(outsideHitAreaBorder);
|
|
||||||
g2.dispose();
|
|
||||||
background.createGraphics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2){
|
public void draw(Graphics2D g2){
|
||||||
@@ -111,29 +98,28 @@ public class PlayArea {
|
|||||||
if(hit){
|
if(hit){
|
||||||
g2.setColor(hitAreaColor);
|
g2.setColor(hitAreaColor);
|
||||||
g2.fill(hitArea);
|
g2.fill(hitArea);
|
||||||
if(count == maxCount){
|
|
||||||
|
if(count == maxCount)
|
||||||
hit = false;
|
hit = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(pathID >= 0 && pathColor != null){
|
if (oldPathId != pathID){
|
||||||
g2.setColor(new Color(pathColor.getRed(), pathColor.getGreen(), pathColor.getBlue(),50));
|
generateBackground();
|
||||||
g2.fill(backgroundPlay);
|
oldPathId = pathID;
|
||||||
g2.setStroke(stroke);
|
|
||||||
g2.setColor(pathColor);
|
|
||||||
g2.draw(paths.get(pathID));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 40);
|
||||||
|
g2.setFont(scoreFont);
|
||||||
|
pointAnimation.draw(g2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Line2D getLine(int index){
|
public Line2D getLine(int index){
|
||||||
if(index < 0){
|
if(index < 0)
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
else if(index >= 8)
|
||||||
if(index >= 8 ){
|
|
||||||
index = 7;
|
index = 7;
|
||||||
}
|
|
||||||
return paths.get(index);
|
return paths.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setHitAreaColor(Color color) {
|
public void setHitAreaColor(Color color) {
|
||||||
hitAreaColor = color;
|
hitAreaColor = color;
|
||||||
@@ -147,9 +133,8 @@ public class PlayArea {
|
|||||||
public void count(){
|
public void count(){
|
||||||
if(hit){
|
if(hit){
|
||||||
count += 3;
|
count += 3;
|
||||||
if(count > maxCount){
|
if(count > maxCount)
|
||||||
count = maxCount;
|
count = maxCount;
|
||||||
}
|
|
||||||
hitAreaColor = new Color(hitAreaColor.getRed(),hitAreaColor.getGreen(),hitAreaColor.getBlue(),255-(255*count)/maxCount);
|
hitAreaColor = new Color(hitAreaColor.getRed(),hitAreaColor.getGreen(),hitAreaColor.getBlue(),255-(255*count)/maxCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,4 +143,35 @@ public class PlayArea {
|
|||||||
this.pathID = pathID;
|
this.pathID = pathID;
|
||||||
this.pathColor = pathColor;
|
this.pathColor = pathColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void generateBackground(){
|
||||||
|
//drawing into buffer
|
||||||
|
background = Images.initVolatileImage(1280,1024, Transparency.BITMASK);
|
||||||
|
Graphics2D g2 = background.createGraphics();
|
||||||
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
g2.setRenderingHints(rh);
|
||||||
|
|
||||||
|
Line2D current;
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
g2.setStroke(stroke);
|
||||||
|
|
||||||
|
paths.forEach(path -> {
|
||||||
|
g2.draw(path);
|
||||||
|
});
|
||||||
|
g2.draw(innerHitAreaBorder);
|
||||||
|
g2.draw(outsideHitAreaBorder);
|
||||||
|
|
||||||
|
if(pathID >= 0 && pathColor != null ){
|
||||||
|
g2.setColor(new Color(pathColor.getRed(), pathColor.getGreen(), pathColor.getBlue(),50));
|
||||||
|
g2.fill(backgroundPlay);
|
||||||
|
g2.setStroke(stroke);
|
||||||
|
g2.setColor(pathColor);
|
||||||
|
g2.draw(paths.get(pathID));
|
||||||
|
}
|
||||||
|
|
||||||
|
g2.dispose();
|
||||||
|
background.createGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.awt.Graphics2D;
|
|||||||
|
|
||||||
public class HighscoreName {
|
public class HighscoreName {
|
||||||
|
|
||||||
private final char[] characters = " abcdefghijklmnopqrstuvwxyz0123456789†".toUpperCase().toCharArray();
|
private final char[] characters = " abcdefghijklmnopqrstuvwxyz0123456789+-?!".toUpperCase().toCharArray();
|
||||||
private int spacing = 10;
|
private int spacing = 10;
|
||||||
private HighscoreLetter[] letters;
|
private HighscoreLetter[] letters;
|
||||||
private Font font;
|
private Font font;
|
||||||
@@ -18,7 +18,6 @@ public class HighscoreName {
|
|||||||
int marge = (int) (Math.floor(nameLength/2)-1)*spacing;
|
int marge = (int) (Math.floor(nameLength/2)-1)*spacing;
|
||||||
x -= (double)HighscoreLetter.charLength*(nameLength/2.0) + marge;
|
x -= (double)HighscoreLetter.charLength*(nameLength/2.0) + marge;
|
||||||
|
|
||||||
System.out.println(x);
|
|
||||||
for(int i = 0; i < letters.length; i++){
|
for(int i = 0; i < letters.length; i++){
|
||||||
letters[i] = new HighscoreLetter(characters, x+(HighscoreLetter.charLength*i)+(spacing*i), y);
|
letters[i] = new HighscoreLetter(characters, x+(HighscoreLetter.charLength*i)+(spacing*i), y);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -12,12 +12,9 @@ import control.GameStateManager;
|
|||||||
|
|
||||||
public class GameView extends JPanel {
|
public class GameView extends JPanel {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1939480784205689618L;
|
private static final long serialVersionUID = 1939480784205689618L;
|
||||||
|
|
||||||
GameStateManager gsm;
|
private GameStateManager gsm;
|
||||||
|
|
||||||
// Font fpsfont = new Font("OCR A Extended", Font.BOLD, 60);
|
// Font fpsfont = new Font("OCR A Extended", Font.BOLD, 60);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user