Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f48c07a55 | ||
|
|
f3f1a11a75 | ||
|
|
a282f2186c | ||
|
|
1edab2daac | ||
|
|
e739255d23 | ||
|
|
201fa6d0b1 | ||
|
|
cc69ad63c3 | ||
|
|
749c80c748 | ||
|
|
bac38b5aa5 | ||
|
|
effbcc3670 | ||
|
|
8c858e93e1 | ||
|
|
a6f7177084 | ||
|
|
2c3cdd4d15 | ||
|
|
764fc33836 | ||
|
|
713cfaf836 | ||
|
|
61fdeb27c5 | ||
|
|
458ccb99d0 | ||
|
|
7a6d2e9d5d | ||
|
|
74b6cafc40 | ||
|
|
79cc140d2f | ||
|
|
5679b20616 | ||
|
|
172454e13f | ||
|
|
34f6d10532 | ||
|
|
bad1f459aa | ||
|
|
b4c0995ce8 | ||
|
|
5480476837 | ||
|
|
e349ec9fa6 | ||
|
|
4cc41ea2c8 | ||
|
|
06cc34a8fe | ||
|
|
b4cd80807f | ||
|
|
18d6a9dcbd | ||
|
|
c111a52f52 | ||
|
|
e64fc291fe | ||
|
|
803c0e1707 | ||
|
|
fc86051f04 | ||
|
|
2fa9c3afe8 | ||
|
|
54d9a91f6a | ||
|
|
bedd6899db | ||
|
|
0516027069 |
@@ -165,4 +165,15 @@ public class Song implements Comparable<Song>{
|
||||
}
|
||||
return timesPlayed;
|
||||
}
|
||||
|
||||
public int getHighestScore()
|
||||
{
|
||||
int highest = 0;
|
||||
for(SongInstance s : songs)
|
||||
{
|
||||
if(s.getHighestScore() > highest)
|
||||
highest = s.getHighestScore();
|
||||
}
|
||||
return highest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ public class SongInstance {
|
||||
|
||||
private String difficulty;
|
||||
private int timesPlayed;
|
||||
private int highestScore;
|
||||
|
||||
private List<ObjectInstance> objects;
|
||||
private List<ButtonInstance> buttons;
|
||||
@@ -15,6 +16,7 @@ public class SongInstance {
|
||||
{
|
||||
this.difficulty = difficulty;
|
||||
this.timesPlayed = 0;
|
||||
this.highestScore = 0;
|
||||
|
||||
objects = new ArrayList<ObjectInstance>();
|
||||
buttons = new ArrayList<ButtonInstance>();
|
||||
@@ -94,6 +96,14 @@ public class SongInstance {
|
||||
this.timesPlayed = timesPlayed;
|
||||
}
|
||||
|
||||
public int getHighestScore() {
|
||||
return highestScore;
|
||||
}
|
||||
|
||||
public void setHighestScore(int highestScore) {
|
||||
this.highestScore = highestScore;
|
||||
}
|
||||
|
||||
public void played()
|
||||
{
|
||||
timesPlayed++;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package audio.sorting;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import audio.Song;
|
||||
|
||||
public class SortAUTHOR implements Comparator<Song> {
|
||||
|
||||
@Override
|
||||
public int compare(Song s1, Song s2) {
|
||||
return s1.getAuthor().compareTo(s2.getAuthor());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package audio.sorting;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import audio.Song;
|
||||
|
||||
public class SortSCORE implements Comparator<Song> {
|
||||
|
||||
public int compare(Song s1, Song s2) {
|
||||
if(s1.getHighestScore() < s2.getHighestScore())
|
||||
return 1;
|
||||
else if(s1.getHighestScore() > s2.getHighestScore())
|
||||
return -1;
|
||||
else
|
||||
return s1.getTitle().compareTo(s2.getTitle());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import model.SongHandler;
|
||||
import model.gameState.GameOverState;
|
||||
import model.gameState.EndState;
|
||||
import model.gameState.GameState;
|
||||
import model.gameState.HelpState;
|
||||
import model.gameState.MenuState;
|
||||
@@ -32,7 +32,7 @@ public class GameStateManager {
|
||||
MENU_STATE,
|
||||
HELP_STATE,
|
||||
PLAY_STATE,
|
||||
GAMEOVER_STATE,
|
||||
END_STATE,
|
||||
PRE_GAME_STATE
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GameStateManager {
|
||||
gamestates.add(new MenuState(this, sh, sql));
|
||||
gamestates.add(new HelpState(this, sh, sql));
|
||||
gamestates.add(new PlayState(this, sh, sql));
|
||||
gamestates.add(new GameOverState(this, sh, sql));
|
||||
gamestates.add(new EndState(this, sh, sql));
|
||||
gamestates.add(new PreGameState(this,sh, sql));
|
||||
setState(State.TITLE_STATE);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class NetworkHandler implements Runnable{
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
private long fistpressed;
|
||||
|
||||
private boolean running;
|
||||
private Thread t;
|
||||
@@ -111,7 +112,7 @@ public class NetworkHandler implements Runnable{
|
||||
}
|
||||
|
||||
if(control[7] == 0 && control[8] == 0){
|
||||
if(JoystickHandler.j.getPos() != Position.UP_LEFT)
|
||||
if(JoystickHandler.j.getPos() != Position.UP_LEFT )
|
||||
{
|
||||
JoystickHandler.j.setPosition(Position.UP_LEFT);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
@@ -140,10 +141,18 @@ public class NetworkHandler implements Runnable{
|
||||
}
|
||||
|
||||
else if(control[7] == 0){
|
||||
if(JoystickHandler.j.getPos() != Position.UP)
|
||||
if(JoystickHandler.j.getPos() != Position.UP || JoystickHandler.REPEAT)
|
||||
{
|
||||
JoystickHandler.j.setPosition(Position.UP);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
if(JoystickHandler.j.getPos() != Position.UP)
|
||||
{
|
||||
fistpressed = System.currentTimeMillis();
|
||||
JoystickHandler.j.setPosition(Position.UP);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
if((fistpressed + 500) < System.currentTimeMillis()){
|
||||
JoystickHandler.j.setPosition(Position.UP);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(control[8] == 0){
|
||||
@@ -161,13 +170,21 @@ public class NetworkHandler implements Runnable{
|
||||
}
|
||||
}
|
||||
else if(control[10] == 0){
|
||||
if(JoystickHandler.j.getPos() != Position.DOWN)
|
||||
if(JoystickHandler.j.getPos() != Position.DOWN || JoystickHandler.REPEAT)
|
||||
{
|
||||
JoystickHandler.j.setPosition(Position.DOWN);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
if(JoystickHandler.j.getPos() != Position.DOWN){
|
||||
fistpressed = System.currentTimeMillis();
|
||||
JoystickHandler.j.setPosition(Position.DOWN);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
if((fistpressed + 500) < System.currentTimeMillis()){
|
||||
JoystickHandler.j.setPosition(Position.DOWN);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(JoystickHandler.j.getPos() != Position.CENTER){
|
||||
fistpressed = 0;
|
||||
JoystickHandler.j.setPosition(Position.CENTER);
|
||||
jth.onJoystickMoved(JoystickHandler.j);
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ public class ButtonHandler implements KeyListener{
|
||||
buttons.add(new Button(1, 2, ntw));
|
||||
buttons.add(new Button(2, 1, ntw));
|
||||
buttons.add(new Button(3, 0, ntw));
|
||||
buttons.add(new Button(4, 3, ntw));
|
||||
buttons.add(new Button(5, 4, ntw));
|
||||
buttons.add(new Button(6, 5, ntw));
|
||||
buttons.add(new Button(4, -1, ntw));
|
||||
buttons.add(new Button(5, 3, ntw));
|
||||
buttons.add(new Button(6, 4, ntw));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.crypto.provider.RSACipher;
|
||||
|
||||
import model.objects.highscore.Highscore;
|
||||
import audio.Song;
|
||||
import audio.SongInstance;
|
||||
@@ -48,6 +46,32 @@ public class SQLConnector
|
||||
}
|
||||
}
|
||||
|
||||
public Highscore getHighscore(Song s, SongInstance si)
|
||||
{
|
||||
String query = "SELECT * FROM highscore WHERE songinstance = (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')) ORDER BY score DESC LIMIT 1";
|
||||
//System.out.println(query);
|
||||
Statement st = executeResultQuery(query);
|
||||
ResultSet result = null;
|
||||
try {
|
||||
result = st.getResultSet();
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
Highscore hsc = null;
|
||||
|
||||
try {
|
||||
result.next();
|
||||
if(result != null)
|
||||
hsc = new Highscore(si, result.getString("username"), result.getInt("score"), result.getDate("date").getTime());
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return hsc;
|
||||
}
|
||||
|
||||
public List<Highscore> getHighscores(Song s, SongInstance si)
|
||||
{
|
||||
String query = "SELECT * FROM highscore WHERE songinstance = (SELECT id FROM songinstance WHERE difficulty='" + si.getDifficulty() + "' AND song=(SELECT id FROM song WHERE folder='" + s.getFolder() + "')) ORDER BY score DESC";
|
||||
@@ -169,6 +193,18 @@ public class SQLConnector
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Statement st4 = executeResultQuery("SELECT MAX(`score`) as score FROM `highscore` WHERE `songinstance`=(SELECT id FROM songinstance WHERE song=" + id + " AND difficulty='" + si.getDifficulty() + "')");
|
||||
try {
|
||||
ResultSet rs4 = st4.getResultSet();
|
||||
if(rs4.next())
|
||||
{
|
||||
int i = rs4.getInt(1);
|
||||
si.setHighestScore(i);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -35,6 +35,7 @@ public class Images {
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/gameover.png"))));
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/screenshot.png"))));
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/help.png"))));
|
||||
images.add(toCompatibleImage(ImageIO.read(Main.class.getResource("/image/youwon.png"))));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -45,7 +46,7 @@ public class Images {
|
||||
}
|
||||
|
||||
public enum ImageType {
|
||||
pulse,cursor,pressstart,colorstrike,background,aanwijzers,kast,gameover, screenshot, help
|
||||
pulse,cursor,pressstart,colorstrike,background,aanwijzers,kast,gameover, screenshot, help,youwon
|
||||
}
|
||||
|
||||
public static BufferedImage readImage(File f) {
|
||||
|
||||
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 102 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
@@ -36,8 +36,8 @@ public class Window extends JFrame {
|
||||
setSize(WIDTH, HEIGHT);
|
||||
|
||||
//Create Events
|
||||
// Window.ON_RASP = ON_RASP;
|
||||
// if(ON_RASP){ //Only on the raspberry pi
|
||||
Window.ON_RASP = ON_RASP;
|
||||
if(ON_RASP){ //Only on the raspberry pi
|
||||
// GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||
//
|
||||
@@ -47,15 +47,15 @@ public class Window extends JFrame {
|
||||
// devices[0].setFullScreenWindow(this);
|
||||
// }
|
||||
// //Remove cursor
|
||||
// BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
// Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||
// this.setCursor(blankCursor);
|
||||
// }
|
||||
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
|
||||
this.setCursor(blankCursor);
|
||||
}
|
||||
|
||||
ButtonHandler bth = new ButtonHandler();
|
||||
JoystickHandler jsh = new JoystickHandler();
|
||||
|
||||
|
||||
|
||||
final SQLConnector sql = new SQLConnector();
|
||||
|
||||
NetworkHandler ntw = new NetworkHandler("10.42.0.5", 1113, bth, jsh);
|
||||
@@ -85,8 +85,8 @@ public class Window extends JFrame {
|
||||
});
|
||||
|
||||
//Create EventListeners
|
||||
addKeyListener(bth);
|
||||
addKeyListener(jsh);
|
||||
addKeyListener(bth);
|
||||
addKeyListener(jsh);
|
||||
bth.addButtonListener(control);
|
||||
jsh.addJoystickListener(control);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import control.button.ButtonHandler;
|
||||
|
||||
public class GameModel {
|
||||
|
||||
public static Color[] colors = { Color.GREEN, Color.YELLOW, Color.RED, Color.MAGENTA, Color.CYAN, Color.ORANGE };
|
||||
public static Color[] colors = { Color.GREEN, Color.YELLOW, Color.RED, Color.MAGENTA, Color.CYAN, Color.BLUE };
|
||||
private GameStateManager gsm;
|
||||
private NetworkHandler ntw;
|
||||
private int count = 0;
|
||||
|
||||
@@ -23,22 +23,26 @@ public class CoinAnimation extends DrawObject {
|
||||
private Point2D.Double coinSetPoint;
|
||||
|
||||
// Hoevaak de timer gelopen heeft
|
||||
private static int timerLoops = 0;
|
||||
private static int timerLoops = 0;
|
||||
private double reach = 0;
|
||||
private Color color;
|
||||
|
||||
public CoinAnimation(int startX, int startY) {
|
||||
coinSetPoint = new Point2D.Double(startX, startY);
|
||||
coinShape = new Ellipse2D.Double(startX, startY, 20, 20);
|
||||
coinSetPoint = new Point2D.Double(startX + 180, startY - 10);
|
||||
coinShape = new Ellipse2D.Double(startX + 180, startY - 10, 20, 20);
|
||||
}
|
||||
|
||||
// Start
|
||||
public void start() {
|
||||
public void start(Color c) {
|
||||
timerLoops = 1;
|
||||
reach = (180 - PlayState.comboScore * 2) / 14; // 'Eindbestemming' van het muntje
|
||||
color = c;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2) {
|
||||
Color oldColor = g2.getColor();
|
||||
update(timerLoops); // UPDATE
|
||||
g2.setColor(new Color(255, 255, 0)); // GEEL
|
||||
g2.setColor(color); // GEEL
|
||||
g2.draw(coinShape); // MUNTJE TEKENEN
|
||||
g2.fill(coinShape);
|
||||
g2.setColor(oldColor);
|
||||
@@ -46,14 +50,11 @@ public class CoinAnimation extends DrawObject {
|
||||
|
||||
// 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() * timerLoops * 10, coinSetPoint.getY() * timerLoops,
|
||||
coinShape.setFrame(coinSetPoint.getX() - reach * timerLoops, coinSetPoint.getY(),
|
||||
coinShape.getWidth(), coinShape.getHeight());
|
||||
/* coinShape.setFrame(coinSetPoint.getX(), coinSetPoint.getY() + (1000 - 35 * PlayState.comboScore) / 25 * timerLoops,
|
||||
coinShape.getWidth(), coinShape.getHeight());*/
|
||||
} catch (ArithmeticException a) { a.printStackTrace(); }
|
||||
|
||||
timerLoops++;
|
||||
@@ -61,7 +62,7 @@ public class CoinAnimation extends DrawObject {
|
||||
|
||||
// Zijn we al begonnen/klaar?
|
||||
public boolean areWeDoneYet() {
|
||||
if (timerLoops > 24 || timerLoops == 0) {
|
||||
if ((timerLoops > 14 || timerLoops == 0) || (reach * timerLoops > 180)) {
|
||||
timerLoops = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -69,6 +70,6 @@ public class CoinAnimation extends DrawObject {
|
||||
}
|
||||
|
||||
// Zitten we in de laatste loop?
|
||||
public boolean isLastLoop() { return (timerLoops == 24) ? true : false; }
|
||||
public boolean isLastLoop() { return (timerLoops == 13) ? true : false; }
|
||||
|
||||
}
|
||||
@@ -4,29 +4,34 @@ import model.gameState.PlayState;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class PointAnimation extends DrawObject {
|
||||
|
||||
LinkedList<Point2D.Double> puntenPos = new LinkedList<>();
|
||||
LinkedList<Integer> puntenGain = new LinkedList<>();
|
||||
LinkedList<Integer> iterations = new LinkedList<>();
|
||||
ArrayList<Point2D.Double> puntenPos = new ArrayList<>();
|
||||
ArrayList<Integer> puntenGain = new ArrayList<>();
|
||||
ArrayList<Integer> iterations = new ArrayList<>();
|
||||
ArrayList<Color> colors = new ArrayList<>();
|
||||
|
||||
public static double LastPointIncrement = 0;
|
||||
|
||||
public PointAnimation() { }
|
||||
|
||||
public void enemyDied(Point2D.Double p) {
|
||||
public void enemyDied(Point2D.Double p, Color c) {
|
||||
puntenPos.add(new Point2D.Double(p.getX(), p.getY()));
|
||||
puntenGain.add((int)LastPointIncrement);
|
||||
iterations.add(0);
|
||||
colors.add(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2) {
|
||||
for (int x = 0; x < puntenPos.size(); x++) {
|
||||
Color oldColor = g2.getColor();
|
||||
g2.setColor(colors.get(x));
|
||||
g2.drawString("" + puntenGain.get(x), (int) puntenPos.get(x).getX(), (int) puntenPos.get(x).getY());
|
||||
|
||||
g2.setColor(oldColor);
|
||||
update(0);
|
||||
}
|
||||
}
|
||||
@@ -42,6 +47,7 @@ public class PointAnimation extends DrawObject {
|
||||
puntenPos.remove(x);
|
||||
iterations.remove(x);
|
||||
puntenGain.remove(x);
|
||||
colors.remove(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package model.gameState;
|
||||
|
||||
import image.Images;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.io.IOException;
|
||||
|
||||
import model.GameModel;
|
||||
import model.SongHandler;
|
||||
import model.objects.InfoPanel;
|
||||
import model.objects.highscore.HighscoreName;
|
||||
|
||||
import com.google.zxing.WriterException;
|
||||
|
||||
import control.GameStateManager;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.button.ButtonHandler;
|
||||
import control.joystick.JoystickEvent;
|
||||
import control.joystick.JoystickHandler;
|
||||
import data.io.SQLConnector;
|
||||
import data.io.WebcamUploader;
|
||||
|
||||
public class EndState extends GameState {
|
||||
|
||||
BufferedImage end = null;
|
||||
VolatileImage background;
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 70);
|
||||
HighscoreName hsn;
|
||||
int image_x = 0;
|
||||
private boolean uploaded;
|
||||
private BufferedImage QRimage;
|
||||
|
||||
int frame;
|
||||
|
||||
public EndState(GameStateManager gsm, SongHandler sh, SQLConnector sql) {
|
||||
super(gsm, sh, sql);
|
||||
hsn = new HighscoreName(640,717,5,textFont);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
createBackground();
|
||||
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||
ButtonHandler.getButton(2).setColor(GameModel.colors[2]);
|
||||
JoystickHandler.REPEAT = true;
|
||||
uploaded = false;
|
||||
// System.out.println("Endgame: "+PlayState.won());
|
||||
if(PlayState.won()){
|
||||
end = Images.getImage(Images.ImageType.youwon);
|
||||
}else{
|
||||
end = Images.getImage(Images.ImageType.gameover);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float factor) {
|
||||
image_x = ((frame / 5) % 5) * 40;
|
||||
frame++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2) {
|
||||
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||
|
||||
if(end != null){
|
||||
g2.drawImage(end.getSubimage(image_x, 0, 40, 26), 640-122, 400, 245, 130, null);
|
||||
}
|
||||
|
||||
if(!uploaded)
|
||||
hsn.drawName(g2);
|
||||
else if(QRimage != null){
|
||||
g2.drawImage(QRimage, (1280/2)-(QRimage.getWidth()/2), 600,null);
|
||||
//1280 is de breedte van de panel
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonPressed(ButtonEvent e) {
|
||||
//System.out.println("Name: "+hsn.getName());
|
||||
switch(e.getButton().getButtonID()){
|
||||
case 0:
|
||||
gsm.setState(State.TITLE_STATE);
|
||||
break;
|
||||
case 1:
|
||||
if(hsn.getName().trim().length() >= 3)
|
||||
{
|
||||
if(!uploaded){
|
||||
int id = sql.addHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance(), hsn.getName(), PlayState.currentScore);
|
||||
try {
|
||||
WebcamUploader.takePictureAndUpload(id);
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
QRimage = WebcamUploader.createQRImage("http://portfolio.jancokock.me/colorstrike/message.php?id="+id, 400);
|
||||
} catch (WriterException | IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
uploaded = true;
|
||||
|
||||
}else{
|
||||
gsm.setState(State.MENU_STATE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
gsm.setState(State.MENU_STATE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void buttonReleased(ButtonEvent e) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onJoystickMoved(JoystickEvent e) {
|
||||
switch(e.getJoystick().getPos()){
|
||||
case DOWN:
|
||||
hsn.down();
|
||||
break;
|
||||
case LEFT:
|
||||
hsn.left();
|
||||
break;
|
||||
case RIGHT:
|
||||
hsn.right();
|
||||
break;
|
||||
case UP:
|
||||
hsn.up();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void createBackground(){
|
||||
background = Images.initVolatileImage(1280, 1024, Transparency.OPAQUE);
|
||||
Graphics2D g2 = background.createGraphics();
|
||||
|
||||
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHints(rh);
|
||||
g2.setColor(new Color(1,1,1, 0.3f));
|
||||
g2.fillRect(0,0,1280,1024);
|
||||
|
||||
g2.setColor(new Color(0,1,0, 0.7f));
|
||||
g2.fillRect(0,0,100,1024);
|
||||
g2.fillRect(1180,0,100,1024);
|
||||
|
||||
g2.setColor(new Color(1,1,0, 0.7f));
|
||||
g2.fillRect(100,0,100,1024);
|
||||
g2.fillRect(1080,0,100,1024);
|
||||
|
||||
g2.setColor(new Color(1,0,0, 0.7f));
|
||||
g2.fillRect(200,0,100,1024);
|
||||
g2.fillRect(980,0,100,1024);
|
||||
|
||||
g2.setColor(Color.BLACK);
|
||||
g2.setFont(textFont);
|
||||
|
||||
g2.drawString("High Score", 385, 212);
|
||||
g2.drawString(InfoPanel.getTotalHighscore() + "", 390, 342);
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import model.SongHandler;
|
||||
import control.GameStateManager;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
import control.button.ButtonHandler;
|
||||
import control.joystick.JoystickEvent;
|
||||
import data.io.SQLConnector;
|
||||
|
||||
@@ -36,6 +37,7 @@ public class HelpState extends GameState {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
ButtonHandler.getButton(2).setColor(GameModel.colors[2]);
|
||||
sh.play();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ import model.objects.highscore.Highscore;
|
||||
import audio.Song;
|
||||
import audio.SongInstance;
|
||||
import audio.sorting.SortALPHA;
|
||||
import audio.sorting.SortAUTHOR;
|
||||
import audio.sorting.SortPLAYED;
|
||||
import audio.sorting.SortSCORE;
|
||||
import control.GameStateManager;
|
||||
import control.GameStateManager.State;
|
||||
import control.button.ButtonEvent;
|
||||
@@ -102,9 +104,12 @@ public class MenuState extends GameState {
|
||||
else
|
||||
{
|
||||
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||
ButtonHandler.getButton(2).setColor(GameModel.colors[3]);
|
||||
|
||||
ButtonHandler.getButton(5).setColor(GameModel.colors[1]);
|
||||
ButtonHandler.getButton(6).setColor(GameModel.colors[4]);
|
||||
ButtonHandler.getButton(3).setColor(GameModel.colors[1]);
|
||||
ButtonHandler.getButton(4).setColor(GameModel.colors[2]);
|
||||
ButtonHandler.getButton(5).setColor(GameModel.colors[4]);
|
||||
ButtonHandler.getButton(6).setColor(GameModel.colors[5]);
|
||||
JoystickHandler.REPEAT = true;
|
||||
}
|
||||
|
||||
@@ -187,19 +192,25 @@ public class MenuState extends GameState {
|
||||
subscreen = true;
|
||||
gsm.init();
|
||||
generateSubScreenForeground();
|
||||
}else if(e.getButton().getButtonID() == 5){
|
||||
sh.sort(new SortALPHA());
|
||||
selected = 0;
|
||||
sh.set(songs.indexOf(selectedToSong(selected)));
|
||||
sh.play();
|
||||
}else if(e.getButton().getButtonID() == 6){
|
||||
sh.sort(new SortPLAYED());
|
||||
selected = 0;
|
||||
sh.set(songs.indexOf(selectedToSong(selected)));
|
||||
sh.play();
|
||||
}else if(e.getButton().getButtonID() == 3){
|
||||
}else if(e.getButton().getButtonID() == 2){
|
||||
gsm.setState(control.GameStateManager.State.HELP_STATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(e.getButton().getButtonID() == 3){
|
||||
sh.sort(new SortALPHA());
|
||||
}else if(e.getButton().getButtonID() == 4){
|
||||
sh.sort(new SortAUTHOR());
|
||||
}else if(e.getButton().getButtonID() == 5){
|
||||
sh.sort(new SortPLAYED());
|
||||
}else if(e.getButton().getButtonID() == 6){
|
||||
sh.sort(new SortSCORE());
|
||||
}
|
||||
|
||||
selected = 0;
|
||||
sh.set(songs.indexOf(selectedToSong(selected)));
|
||||
sh.play();
|
||||
}
|
||||
}
|
||||
|
||||
if(e.getButton().getButtonID() == 0)
|
||||
@@ -334,23 +345,34 @@ public class MenuState extends GameState {
|
||||
|
||||
//select
|
||||
g2.setColor(GameModel.colors[0]);
|
||||
g2.fillOval(20, 860, 30, 30);
|
||||
g2.drawString("Play", 55, 880);
|
||||
g2.fillOval(20, 780, 30, 30);
|
||||
g2.drawString("Play", 55, 800);
|
||||
|
||||
//help
|
||||
g2.setColor(GameModel.colors[3]);
|
||||
g2.fillOval(20, 900, 30, 30);
|
||||
g2.drawString("Help", 55, 920);
|
||||
g2.fillOval(20, 820, 30, 30);
|
||||
g2.drawString("Help", 55, 840);
|
||||
|
||||
//letters
|
||||
g2.setColor(GameModel.colors[1]);
|
||||
g2.fillOval(20, 940, 30, 30);
|
||||
g2.drawString("A-Z", 55, 960);
|
||||
g2.fillOval(20, 860, 30, 30);
|
||||
g2.drawString("A-Z", 55, 880);
|
||||
|
||||
//most played
|
||||
g2.setColor(GameModel.colors[2]);
|
||||
g2.fillOval(20, 900, 30, 30);
|
||||
g2.drawString("Author", 55, 920);
|
||||
|
||||
//most played
|
||||
g2.setColor(GameModel.colors[4]);
|
||||
g2.fillOval(20, 940, 30, 30);
|
||||
g2.drawString("Most Played", 55, 960);
|
||||
|
||||
//most played
|
||||
g2.setColor(GameModel.colors[5]);
|
||||
g2.fillOval(20, 980, 30, 30);
|
||||
g2.drawString("Most Played", 55, 1000);
|
||||
g2.drawString("Highest Score", 55, 1000);
|
||||
|
||||
g2.dispose();
|
||||
|
||||
mainScreenBackground.createGraphics();
|
||||
@@ -395,7 +417,7 @@ public class MenuState extends GameState {
|
||||
g2.setFont(textFont);
|
||||
|
||||
boolean highscoresFound = true;
|
||||
int HIGHSCORES_TO_DISPLAY = 5;
|
||||
int HIGHSCORES_TO_DISPLAY = 7;
|
||||
|
||||
List<Highscore> highscores = sql.getHighscoresToday(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||
if(highscores.isEmpty())
|
||||
@@ -406,10 +428,10 @@ public class MenuState extends GameState {
|
||||
highscoresFound = false;
|
||||
}
|
||||
else
|
||||
g2.drawString("All Time Highscores", 30, 300);
|
||||
g2.drawString("All Time Highscores", 30, 235);
|
||||
}
|
||||
else
|
||||
g2.drawString("Daily Highscore", 30, 300);
|
||||
g2.drawString("Daily Highscore", 30, 235);
|
||||
g2.setFont(textFont2);
|
||||
|
||||
if(highscoresFound)
|
||||
@@ -420,7 +442,7 @@ public class MenuState extends GameState {
|
||||
{
|
||||
Highscore hi = highscores.get(i);
|
||||
|
||||
g2.drawString(hi.getName() + " - " + hi.getScore(), 30, 350 + i*100);
|
||||
g2.drawString(" " + (i+1) + "# " + hi.getName() + " - " + hi.getScore(), 30, 290 + i*80);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -508,4 +530,4 @@ public class MenuState extends GameState {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Iterator;
|
||||
|
||||
import main.Window;
|
||||
import model.SongHandler;
|
||||
import model.drawObjects.Enemy;
|
||||
import model.drawObjects.Player;
|
||||
@@ -17,6 +16,7 @@ import model.drawObjects.PointAnimation;
|
||||
import model.objects.InfoPanel;
|
||||
import model.objects.Path;
|
||||
import model.objects.PlayArea;
|
||||
import model.objects.highscore.Highscore;
|
||||
import audio.ButtonInstance;
|
||||
import audio.ObjectInstance;
|
||||
import control.GameStateManager;
|
||||
@@ -47,6 +47,7 @@ public class PlayState extends GameState {
|
||||
private int joystick_moved = 0;
|
||||
|
||||
private boolean init = false;
|
||||
private static boolean won = false;
|
||||
|
||||
private long oldProgress = 0;
|
||||
|
||||
@@ -62,6 +63,7 @@ public class PlayState extends GameState {
|
||||
@Override
|
||||
public void init() {
|
||||
init = true;
|
||||
won = false;
|
||||
lifePoints = 100;
|
||||
currentScore = 0;
|
||||
comboScore = 0;
|
||||
@@ -71,16 +73,16 @@ public class PlayState extends GameState {
|
||||
enemies_missed = 0;
|
||||
buttons_pressed = 0;
|
||||
joystick_moved = 0;
|
||||
Highscore h = sql.getHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance());
|
||||
if(h != null)
|
||||
infoPanel.init(h.getScore());
|
||||
|
||||
infoPanel.init(sql.getHighscore(sh.getCurrentSong(), sh.getCurrentSongInstance()).getScore());
|
||||
|
||||
for(Path p : area.paths)
|
||||
{
|
||||
p.getEnemysInPath().clear();
|
||||
}
|
||||
|
||||
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||
Button b = ButtonHandler.getButton(i);
|
||||
b.setColor(Color.BLACK);
|
||||
}
|
||||
|
||||
ButtonHandler.getButton(1).setColor(sh.getCurrentSongInstance().getButtons().get(0).getColor());
|
||||
|
||||
@@ -106,8 +108,11 @@ public class PlayState extends GameState {
|
||||
}
|
||||
|
||||
|
||||
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*1000*2)
|
||||
endGame();
|
||||
if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*1000*2){
|
||||
won = true;
|
||||
endGame();
|
||||
}
|
||||
|
||||
|
||||
oldProgress = progress;
|
||||
|
||||
@@ -160,7 +165,7 @@ public class PlayState extends GameState {
|
||||
}
|
||||
|
||||
private void endGame() {
|
||||
if(sh.getProgress()/1000 < 5000)
|
||||
if(sh.getProgress()/1000 > 5000)
|
||||
{
|
||||
sql.addPlaydata(sh.getCurrentSong(), sh.getCurrentSongInstance(), sh.getProgress()/1000, enemies_missed, enemies_hit, buttons_pressed, joystick_moved);
|
||||
sh.getCurrentSongInstance().played();
|
||||
@@ -169,7 +174,7 @@ public class PlayState extends GameState {
|
||||
if(currentScore == 0)
|
||||
gsm.setState(State.MENU_STATE);
|
||||
else
|
||||
gsm.setState(State.GAMEOVER_STATE);
|
||||
gsm.setState(State.END_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,19 +199,19 @@ public class PlayState extends GameState {
|
||||
player.draw(g2);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if(!Window.ON_RASP){
|
||||
int width,height;
|
||||
width = g2.getFontMetrics().stringWidth("");
|
||||
height = g2.getFontMetrics().getHeight();
|
||||
for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||
Ellipse2D oval = new Ellipse2D.Double(880+(50*i), 0, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(i).getColor());
|
||||
g2.fill(oval);
|
||||
g2.setColor(Color.BLACK);
|
||||
width = g2.getFontMetrics().stringWidth(""+i);
|
||||
g2.drawString(""+i, (int)oval.getCenterX()-width/2,(int)oval.getMaxY()+height);
|
||||
}
|
||||
}
|
||||
// if(!Window.ON_RASP){
|
||||
// int width,height;
|
||||
// width = g2.getFontMetrics().stringWidth("");
|
||||
// height = g2.getFontMetrics().getHeight();
|
||||
// for (int i = 1; i < ButtonHandler.getButtons().size(); i++) {
|
||||
// Ellipse2D oval = new Ellipse2D.Double(880+(50*i), 0, 50, 50);
|
||||
// g2.setColor(ButtonHandler.getButton(i).getColor());
|
||||
// g2.fill(oval);
|
||||
// g2.setColor(Color.BLACK);
|
||||
// width = g2.getFontMetrics().stringWidth(""+i);
|
||||
// g2.drawString(""+i, (int)oval.getCenterX()-width/2,(int)oval.getMaxY()+height);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -225,13 +230,14 @@ public class PlayState extends GameState {
|
||||
area.enemyDied((Point2D.Double) enemy.getEnemy().getP1());
|
||||
area.hit();
|
||||
enemies_hit++;
|
||||
infoPanel.throwACoin(); // Coin Animatie starten bij hit
|
||||
infoPanel.throwACoin(enemy.getColor()); // Coin Animatie starten bij hit
|
||||
enemysInPath.remove();
|
||||
notHit = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.setBeat();
|
||||
|
||||
@@ -294,5 +300,9 @@ public class PlayState extends GameState {
|
||||
Path path = area.paths.get(pathID);
|
||||
Enemy e = new Enemy(pathID, 1, color, path);
|
||||
path.getEnemysInPath().addLast(e);
|
||||
}
|
||||
|
||||
public static boolean won(){
|
||||
return won;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,10 @@ public class PreGameState extends GameState {
|
||||
@Override
|
||||
public void draw(Graphics2D g2) {
|
||||
g2.drawImage(screenshot,0,0,1280,1024,null);
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD,grootte);
|
||||
g2.setFont(textFont);
|
||||
g2.setFont(new Font("OCR A Extended", Font.BOLD,grootte));
|
||||
g2.setStroke(s);
|
||||
g2.setColor(Color.RED);
|
||||
String text = "" + index;
|
||||
int width = g2.getFontMetrics().stringWidth(text);
|
||||
g2.drawString(text, 325, 400);
|
||||
if(index < 1){
|
||||
text = "GO!!!";
|
||||
@@ -66,7 +64,7 @@ public class PreGameState extends GameState {
|
||||
else{
|
||||
text = "READY";
|
||||
}
|
||||
width = g2.getFontMetrics().stringWidth(text);
|
||||
int width = g2.getFontMetrics().stringWidth(text);
|
||||
g2.drawString(text, (256+1024/2)-width/2, 600);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,14 @@ public class TitleState extends GameState {
|
||||
xKast %= 4;
|
||||
g2.drawImage(kast.getSubimage(xKast * 300, 0, 300, 400), 100, 300, 300, 400, null);
|
||||
}
|
||||
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||
int image_x = ((frame / 6) % 6) * 49;
|
||||
g2.drawImage(pressStart.getSubimage(image_x, 0, 49, 26), 640-122, 512, 245, 130, null);
|
||||
|
||||
xKast = indexKast/10;
|
||||
xKast%=4;
|
||||
//g2.drawImage(kast.getSubimage(xKast*300,0,300,400), 640-122,650,300,400,null);
|
||||
g2.drawImage(kast.getSubimage(xKast*600,0,600,800), 490,624,300,400,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,9 +29,11 @@ public class DifficultyButton {
|
||||
g2.setColor(Color.WHITE);
|
||||
g2.fillRect(0, 0, 300, 75);
|
||||
g2.setColor(Color.ORANGE);
|
||||
g2.drawRect(0, 0, 300, 75);
|
||||
//g2.drawRect(0-2, 0-2, 304, 79);
|
||||
|
||||
// g2.drawRect(0, 0, 300, 75);
|
||||
// g2.drawRect(0-2, 0-2, 304, 79);
|
||||
g2.drawRect(0, 0, 304, 79);
|
||||
g2.drawRect(2, 2, 300, 75);
|
||||
g2.setColor(color);
|
||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 50);
|
||||
g2.setFont(textFont2);
|
||||
|
||||
@@ -8,8 +8,12 @@ import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
import control.button.ButtonHandler;
|
||||
import main.Window;
|
||||
import model.SongHandler;
|
||||
import model.drawObjects.CoinAnimation;
|
||||
import model.gameState.PlayState;
|
||||
@@ -21,10 +25,10 @@ public class InfoPanel {
|
||||
private VolatileImage infoPanel;
|
||||
private SongHandler sh;
|
||||
private String time;
|
||||
private int highscore = 0,
|
||||
tempComboScore = 0;
|
||||
|
||||
private int tempComboMulitplier;
|
||||
|
||||
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
|
||||
private CoinAnimation coinAnimation = new CoinAnimation(27, 820);
|
||||
|
||||
public InfoPanel(int x, int y, SongHandler sh){
|
||||
this.x = x;
|
||||
@@ -33,16 +37,15 @@ public class InfoPanel {
|
||||
updateIPanel();
|
||||
generateInfoPanel();
|
||||
}
|
||||
|
||||
|
||||
public void init(int highscore)
|
||||
{
|
||||
this.highscore = highscore;
|
||||
updateIPanel();
|
||||
generateInfoPanel();
|
||||
}
|
||||
public void updateIPanel() {
|
||||
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);
|
||||
String millis = (((progress) % 1000) + "").length() > 3 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000);
|
||||
@@ -58,60 +61,109 @@ public class InfoPanel {
|
||||
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHints(rh);
|
||||
|
||||
|
||||
// g2.setColor(Color.GRAY);
|
||||
GradientPaint gp = new GradientPaint(0, 0, new Color(245,245,245), 256, 1024, Color.WHITE);
|
||||
g2.setPaint(gp);
|
||||
g2.fillRect(x, y, 256, 1024);
|
||||
|
||||
g2.setColor(Color.BLACK);
|
||||
g2.drawRect(x, y, 255, 1023);
|
||||
|
||||
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
|
||||
g2.setFont(scoreFont);
|
||||
g2.setColor(Color.GREEN);
|
||||
g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30);
|
||||
g2.fillRect(25, 900, (int) (2 * PlayState.lifePoints), 30);
|
||||
|
||||
g2.setColor(Color.YELLOW);
|
||||
g2.fillRect(25, 950, (2 * PlayState.comboScore), 30);
|
||||
|
||||
g2.setColor(Color.BLACK);
|
||||
g2.drawString("Score: " + totalHighscore, 25, 75);
|
||||
g2.drawRect(25, 100, 200, 30);
|
||||
g2.drawRect(25, 300, 200, 700);
|
||||
|
||||
g2.drawString(sh.getCurrentSong().getTitle(), 25, 200);
|
||||
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230);
|
||||
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
|
||||
g2.drawString(time, 25, 290);
|
||||
g2.drawRect(25, 900, 200, 30);
|
||||
g2.drawRect(25, 950, 200, 30);
|
||||
|
||||
// GradientPaint gp = new GradientPaint(300, 0, new Color(200,200,255), 256, 1024, Color.WHITE);
|
||||
// g2.setPaint(gp);
|
||||
// g2.fillRect(x, y, 256, 1024);
|
||||
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 35);
|
||||
g2.setFont(scoreFont);
|
||||
g2.drawString("Score: ", 25, 75);
|
||||
|
||||
Font scoreFont2 = new Font("OCR A Extended", Font.BOLD, 25);
|
||||
g2.setFont(scoreFont2);
|
||||
int charsPerLine = 10;
|
||||
int linesNeeded = sh.getCurrentSong().getTitle().length() / charsPerLine + 1; // 9 chars per regel
|
||||
g2.drawString("Title: ", 25, 225 - (linesNeeded) * 30);
|
||||
g2.drawString("Time: ", 25, 265);
|
||||
g2.drawString("Best: ", 25, 345);
|
||||
|
||||
Font scoreFont3 = new Font("OCR A Extended", Font.BOLD, 35);
|
||||
g2.setFont(scoreFont3);
|
||||
|
||||
g2.drawString("" + totalHighscore, 25, 105);
|
||||
|
||||
// Aanpassen zodat hele titel zichtbaar is in infoP
|
||||
for (int count = 0; count < linesNeeded; count++)
|
||||
if (sh.getCurrentSong().getTitle().length() == count * charsPerLine + charsPerLine - 1)
|
||||
g2.drawString( sh.getCurrentSong().getTitle().substring(count * charsPerLine,
|
||||
count * charsPerLine + charsPerLine - 1),
|
||||
25,
|
||||
235 - (linesNeeded - count) * 30);
|
||||
else
|
||||
g2.drawString( sh.getCurrentSong().getTitle().substring(count * charsPerLine,
|
||||
sh.getCurrentSong().getTitle().length()),
|
||||
25,
|
||||
235 - (linesNeeded - 1 - count) * 30);
|
||||
|
||||
/* g2.drawString(sh.getCurrentSong().getTitle(), 25, 215);*/
|
||||
g2.drawString(time, 25, 295);
|
||||
g2.drawString("" + highscore, 25, 375);
|
||||
|
||||
|
||||
if(!Window.ON_RASP){
|
||||
Ellipse2D oval1 = new Ellipse2D.Double(25, 650, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(1).getColor());
|
||||
g2.fill(oval1);
|
||||
|
||||
Ellipse2D oval2 = new Ellipse2D.Double(85, 650, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(2).getColor());
|
||||
g2.fill(oval2);
|
||||
|
||||
Ellipse2D oval3 = new Ellipse2D.Double(145, 650, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(3).getColor());
|
||||
g2.fill(oval3);
|
||||
|
||||
Ellipse2D oval4 = new Ellipse2D.Double(50, 710, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(4).getColor());
|
||||
g2.fill(oval4);
|
||||
|
||||
Ellipse2D oval5 = new Ellipse2D.Double(110, 710, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(5).getColor());
|
||||
g2.fill(oval5);
|
||||
|
||||
Ellipse2D oval6 = new Ellipse2D.Double(170, 710, 50, 50);
|
||||
g2.setColor(ButtonHandler.getButton(6).getColor());
|
||||
g2.fill(oval6);
|
||||
}
|
||||
|
||||
g2.setColor(Color.YELLOW);
|
||||
// Controlen of coin animatie nodig is
|
||||
if (!coinAnimation.areWeDoneYet()) {
|
||||
coinAnimation.draw(g2);
|
||||
// Score pas updaten wanneer coin in zijn laatste draw loop zit
|
||||
if (coinAnimation.isLastLoop())
|
||||
tempComboMulitplier = PlayState.comboScore;
|
||||
tempComboScore = PlayState.comboScore;
|
||||
} else
|
||||
tempComboMulitplier = PlayState.comboScore;
|
||||
tempComboScore = PlayState.comboScore;
|
||||
|
||||
//* Score/Coin animation bar
|
||||
g2.setColor(Color.BLACK);
|
||||
g2.fillRect(25, 800, 2 * tempComboScore, 40);
|
||||
g2.drawRect(25, 800, 200, 40);
|
||||
|
||||
g2.fillRect(25, 1000 - 7 * PlayState.comboScore, 200, 0 + 7 * PlayState.comboScore);
|
||||
g2.dispose();
|
||||
infoPanel.createGraphics();
|
||||
}
|
||||
|
||||
public void throwACoin() {
|
||||
coinAnimation.start(); // Teller weer op 1 zetten
|
||||
}
|
||||
|
||||
|
||||
public void draw(Graphics2D g2){
|
||||
g2.drawImage(infoPanel, 0, 0, 256,1024,null);
|
||||
g2.drawImage(infoPanel, 0, 0, 256, 1024,null);
|
||||
}
|
||||
|
||||
public static String getTotalHighscore()
|
||||
{
|
||||
return totalHighscore;
|
||||
}
|
||||
|
||||
|
||||
public void throwACoin(Color c) {
|
||||
coinAnimation.start(c); // Teller weer op 1 zetten
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,13 @@ package model.objects;
|
||||
|
||||
import image.Images;
|
||||
|
||||
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.*;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Line2D;
|
||||
@@ -24,7 +31,7 @@ public class PlayArea {
|
||||
private VolatileImage background;
|
||||
private boolean hit = false;
|
||||
private int count = 0,maxCount = 100,pathID = -1;
|
||||
private Stroke stroke = new BasicStroke(5);
|
||||
private Stroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
|
||||
private PointAnimation pointAnimation = new PointAnimation();
|
||||
|
||||
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
|
||||
@@ -125,7 +132,7 @@ public class PlayArea {
|
||||
pointAnimation.draw(g2);
|
||||
g2.setFont(tempFont);
|
||||
}
|
||||
|
||||
|
||||
public Line2D getLine(int index){
|
||||
if(index < 0){
|
||||
index = 0;
|
||||
@@ -161,5 +168,5 @@ public class PlayArea {
|
||||
this.pathColor = pathColor;
|
||||
}
|
||||
|
||||
public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p); }
|
||||
public void enemyDied(Point2D.Double p) { pointAnimation.enemyDied(p, hitAreaColor); }
|
||||
}
|
||||
|
||||