clean up 'n bugcrushing
This commit is contained in:
@@ -31,8 +31,7 @@ public class GameModel {
|
||||
|
||||
if (Window.ON_RASP) {
|
||||
count++;
|
||||
if(count>15)
|
||||
{
|
||||
if(count>15) {
|
||||
for (int i = 7; i < 54; i++) {
|
||||
ntw.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SongHandler {
|
||||
private Song currentSong;
|
||||
private SongInstance currentSongInstance;
|
||||
private int currentIndex;
|
||||
SQLConnector sql;
|
||||
private SQLConnector sql;
|
||||
|
||||
private File dir;
|
||||
|
||||
@@ -33,7 +33,6 @@ public class SongHandler {
|
||||
this.sql = sql;
|
||||
|
||||
songs = new ArrayList<Song>();
|
||||
|
||||
currentSong = null;
|
||||
currentSongInstance = null;
|
||||
currentIndex = 0;
|
||||
|
||||
@@ -5,10 +5,13 @@ import java.awt.geom.AffineTransform;
|
||||
|
||||
public abstract class DrawObject {
|
||||
|
||||
|
||||
protected AffineTransform transform;
|
||||
protected double width,height;
|
||||
|
||||
protected double width,
|
||||
height;
|
||||
|
||||
protected int index = 0;
|
||||
|
||||
public DrawObject() {
|
||||
transform = new AffineTransform();
|
||||
}
|
||||
@@ -20,8 +23,7 @@ public abstract class DrawObject {
|
||||
public void setIndex(int index){
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public abstract void draw(Graphics2D g2);
|
||||
public abstract void update(float factor);
|
||||
}
|
||||
|
||||
@@ -29,31 +29,26 @@ public class Player extends DrawObject {
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2){//
|
||||
subImgX = (indexCursor % 8)*100;
|
||||
subImgY = (indexCursor / 8)*100;
|
||||
|
||||
subImgXBeat = (indexBeat % 9)*100;
|
||||
|
||||
|
||||
subImgX = (indexCursor % 8) * 100;
|
||||
subImgY = (indexCursor / 8) * 100;
|
||||
subImgXBeat = (indexBeat % 9 ) * 100;
|
||||
|
||||
BufferedImage subImg2 = pulse.getSubimage(subImgXBeat,0,100,100);
|
||||
g2.drawImage(subImg2, transform, null);
|
||||
|
||||
|
||||
|
||||
BufferedImage subImg = img.getSubimage(subImgX,subImgY,100,100);
|
||||
g2.drawImage(subImg, transform, null);
|
||||
|
||||
g2.drawImage(subImg, transform, null);
|
||||
}
|
||||
|
||||
public void update(float update){
|
||||
if(beat){
|
||||
indexBeat++;
|
||||
if(indexBeat >= 9)
|
||||
{
|
||||
if(indexBeat >= 9) {
|
||||
indexBeat = 0;
|
||||
beat = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
indexCursor++;
|
||||
indexCursor%=32;
|
||||
|
||||
@@ -68,7 +63,6 @@ public class Player extends DrawObject {
|
||||
public void setBeat() {
|
||||
beat = true;
|
||||
indexBeat = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ import data.io.WebcamUploader;
|
||||
|
||||
public class GameOverState extends GameState {
|
||||
|
||||
BufferedImage gameOver = Images.getImage(Images.ImageType.gameover);
|
||||
VolatileImage background;
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 70);
|
||||
HighscoreName hsn;
|
||||
int image_x = 0;
|
||||
private BufferedImage gameOver = Images.getImage(Images.ImageType.gameover);
|
||||
private VolatileImage background;
|
||||
private Font textFont = new Font("OCR A Extended", Font.BOLD, 70);
|
||||
private HighscoreName hsn;
|
||||
private int image_x = 0;
|
||||
private boolean uploaded;
|
||||
private BufferedImage QRimage;
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ public abstract class GameState {
|
||||
this.gsm = gsm;
|
||||
this.sh = sh;
|
||||
this.sql = sql;
|
||||
|
||||
int kleurButton1 = 0;
|
||||
}
|
||||
|
||||
public abstract void init();
|
||||
|
||||
@@ -49,6 +49,7 @@ public class MenuState extends GameState {
|
||||
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 50);
|
||||
Font textFontSmall = new Font("OCR A Extended", Font.BOLD, 15);
|
||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 50);
|
||||
|
||||
BufferedImage aanwijzers = Images.getImage(ImageType.aanwijzers);
|
||||
|
||||
@@ -90,13 +91,11 @@ public class MenuState extends GameState {
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
if(subscreen)
|
||||
{
|
||||
if(subscreen) {
|
||||
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||
ButtonHandler.getButton(2).setColor(GameModel.colors[2]);
|
||||
generateSubScreenForeground();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ButtonHandler.getButton(1).setColor(GameModel.colors[0]);
|
||||
|
||||
ButtonHandler.getButton(5).setColor(GameModel.colors[1]);
|
||||
@@ -112,20 +111,14 @@ public class MenuState extends GameState {
|
||||
if(animationcounter == 5){
|
||||
startanimation = false;
|
||||
}
|
||||
}else if(subscreen){
|
||||
//nextScreen();
|
||||
}else{
|
||||
//previousScreen();
|
||||
}
|
||||
|
||||
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)));
|
||||
|
||||
}
|
||||
oldselected = selected;
|
||||
}
|
||||
if(difSelect != oldDifSelect)
|
||||
{
|
||||
if(difSelect != oldDifSelect) {
|
||||
oldDifSelect = difSelect;
|
||||
generateSubScreenForeground();
|
||||
}
|
||||
@@ -143,10 +136,9 @@ public class MenuState extends GameState {
|
||||
buttons.add(new MenuButton(300,680,GameModel.colors[kleurButton4],selectedToSong(selected+1)));
|
||||
buttons.add(new MenuButton(300,800,GameModel.colors[kleurButton5],selectedToSong(selected+2)));
|
||||
buttons.get(2).setSelected(true);
|
||||
|
||||
|
||||
|
||||
g2.setColor(Color.BLACK);
|
||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 50);
|
||||
|
||||
g2.setFont(textFont2);
|
||||
if(!subscreen) {
|
||||
g2.drawImage(mainScreenBackground, 0, 0, 1280,1024,null);
|
||||
@@ -244,33 +236,21 @@ public class MenuState extends GameState {
|
||||
|
||||
}else if(e.getJoystick().getPos() == Joystick.Position.UP){
|
||||
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() == Joystick.Position.CENTER)
|
||||
@@ -301,9 +281,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.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)));
|
||||
|
||||
|
||||
Polygon triangle2 = new Polygon();
|
||||
|
||||
Polygon triangle2 = new Polygon();
|
||||
|
||||
triangle2.addPoint(0, 0);
|
||||
triangle2.addPoint(0, 1024/4+50);
|
||||
triangle2.addPoint(1280/2+50, 0);
|
||||
@@ -338,8 +318,6 @@ public class MenuState extends GameState {
|
||||
g2.dispose();
|
||||
|
||||
mainScreenBackground.createGraphics();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void generateSubScreenBackground(){
|
||||
@@ -384,23 +362,18 @@ public class MenuState extends GameState {
|
||||
{
|
||||
highscores = sql.getHighscores(selectedToSong(selected), sh.getCurrentSong().getSongs().get(difSelect));
|
||||
if(highscores.isEmpty())
|
||||
{
|
||||
highscoresFound = false;
|
||||
}
|
||||
else
|
||||
g2.drawString("All Time Highscores", 30, 300);
|
||||
}
|
||||
else
|
||||
g2.drawString("Daily Highscore", 30, 300);
|
||||
|
||||
if(highscoresFound)
|
||||
{
|
||||
if(highscoresFound) {
|
||||
HIGHSCORES_TO_DISPLAY = HIGHSCORES_TO_DISPLAY > highscores.size() ? highscores.size() : HIGHSCORES_TO_DISPLAY;
|
||||
|
||||
for(int i = 0; i<HIGHSCORES_TO_DISPLAY; i++)
|
||||
{
|
||||
for(int i = 0; i<HIGHSCORES_TO_DISPLAY; i++) {
|
||||
Highscore hi = highscores.get(i);
|
||||
|
||||
g2.drawString(hi.getName() + " - " + hi.getScore(), 30, 400 + i*100);
|
||||
}
|
||||
}
|
||||
@@ -443,50 +416,29 @@ public class MenuState extends GameState {
|
||||
g2.fillPolygon(p2);
|
||||
|
||||
g2.drawString("Down", 55, 1000);
|
||||
|
||||
|
||||
|
||||
|
||||
g2.dispose();
|
||||
subScreenForeground.createGraphics();
|
||||
}
|
||||
|
||||
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);
|
||||
if(buttons.get(button).getX() >= 320){
|
||||
|
||||
if(buttons.get(button).getX() >= 320)
|
||||
animationcounter++;
|
||||
}
|
||||
if(buttons.get(button).getX() >= -200){
|
||||
if(buttons.get(button).getX() >= -200)
|
||||
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){
|
||||
s %= songs.size();
|
||||
if(s < 0){
|
||||
if(s < 0)
|
||||
return songs.get(songs.size()+s);
|
||||
}else{
|
||||
else
|
||||
return songs.get(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,13 +21,15 @@ import data.io.SQLConnector;
|
||||
|
||||
public class TitleState extends GameState {
|
||||
|
||||
BufferedImage pressStart = Images.getImage(ImageType.pressstart);
|
||||
BufferedImage colorStrike = Images.getImage(ImageType.colorstrike);
|
||||
BufferedImage kast = Images.getImage(ImageType.kast);
|
||||
VolatileImage background;
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
|
||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
|
||||
GradientPaint gp = new GradientPaint(300, 0, new Color(0, 0, 1, 0.6f), 980, 1024, new Color(0, 0, 1, 0.2f));
|
||||
private BufferedImage pressStart = Images.getImage(ImageType.pressstart),
|
||||
colorStrike = Images.getImage(ImageType.colorstrike),
|
||||
kast = Images.getImage(ImageType.kast);
|
||||
private VolatileImage background;
|
||||
|
||||
private Font textFont = new Font("OCR A Extended", Font.BOLD, 15),
|
||||
textFont2 = new Font("OCR A Extended", Font.BOLD, 130);
|
||||
|
||||
private GradientPaint gp = new GradientPaint(300, 0, new Color(0, 0, 1, 0.6f), 980, 1024, new Color(0, 0, 1, 0.2f));
|
||||
|
||||
|
||||
private int index = 0,
|
||||
@@ -48,7 +50,6 @@ public class TitleState extends GameState {
|
||||
|
||||
@Override
|
||||
public void update(float factor) {
|
||||
|
||||
frame++;
|
||||
indexKast++;
|
||||
}
|
||||
@@ -78,7 +79,6 @@ public class TitleState extends GameState {
|
||||
gsm.setState(State.MENU_STATE);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user