Feature/json
# Conflicts: # control/GameStateManager.java # image/Images.java # main/Window.java # model/gameState/MenuState.java
This commit is contained in:
@@ -3,9 +3,11 @@ package control;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import model.SongHandler;
|
||||
import model.gameState.GameState;
|
||||
import model.gameState.MenuState;
|
||||
import model.gameState.TitleState;
|
||||
import model.gameState.PickSongState;
|
||||
import model.gameState.PlayState;
|
||||
|
||||
public class GameStateManager {
|
||||
@@ -14,18 +16,33 @@ public class GameStateManager {
|
||||
public GameState currentState;
|
||||
private int index = 0;
|
||||
|
||||
public GameStateManager(){
|
||||
public enum State {
|
||||
TITLE_STATE,
|
||||
MENU_STATE,
|
||||
PLAY_STATE,
|
||||
PICKSONG_STATE
|
||||
}
|
||||
|
||||
public GameStateManager(SongHandler sh){
|
||||
gamestates = new ArrayList<GameState>();
|
||||
gamestates.add(new TitleState(this));
|
||||
gamestates.add(new MenuState(this));
|
||||
gamestates.add(new PlayState(this));
|
||||
gamestates.add(new TitleState(this, sh));
|
||||
gamestates.add(new MenuState(this, sh));
|
||||
gamestates.add(new PlayState(this, sh));
|
||||
gamestates.add(new PickSongState(this, sh));
|
||||
currentState = gamestates.get(0);
|
||||
}
|
||||
|
||||
public void setState(State st)
|
||||
{
|
||||
currentState = gamestates.get(st.ordinal());
|
||||
currentState.init();
|
||||
}
|
||||
|
||||
public void next() {
|
||||
index++;
|
||||
index %= gamestates.size();
|
||||
currentState = gamestates.get(index);
|
||||
currentState.init();
|
||||
}
|
||||
|
||||
public void update(){
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.awt.event.KeyListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import main.Window;
|
||||
|
||||
import com.pi4j.io.gpio.GpioController;
|
||||
import com.pi4j.io.gpio.GpioFactory;
|
||||
import com.pi4j.io.gpio.GpioPinDigitalInput;
|
||||
@@ -14,7 +16,6 @@ import com.pi4j.io.gpio.RaspiPin;
|
||||
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
|
||||
import com.pi4j.io.gpio.event.GpioPinListenerDigital;
|
||||
|
||||
import main.Window;
|
||||
import control.LedHandler;
|
||||
|
||||
public class ButtonHandler implements KeyListener{
|
||||
@@ -37,12 +38,7 @@ public class ButtonHandler implements KeyListener{
|
||||
buttons.add(new Button(4, 3, led));
|
||||
buttons.add(new Button(5, 4, led));
|
||||
buttons.add(new Button(6, 5, led));
|
||||
|
||||
for(Button b : buttons)
|
||||
{
|
||||
b.setColor(new Color((int)(Math.random()*254+1),(int)(Math.random()*254+1),(int)(Math.random()*254+1)));
|
||||
}
|
||||
System.out.println(Window.ON_RASP);
|
||||
|
||||
if (Window.ON_RASP)
|
||||
addGpioListeners();
|
||||
|
||||
@@ -158,4 +154,16 @@ public class ButtonHandler implements KeyListener{
|
||||
{
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public static Button getButton(int id)
|
||||
{
|
||||
for(Button b : buttons)
|
||||
{
|
||||
if(b.getButtonID() == id)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user