clean up 'n bugcrushing

This commit is contained in:
Bilel Bghiel
2015-06-19 14:36:40 +02:00
parent 864b6efa52
commit d92cd7333b
16 changed files with 116 additions and 183 deletions
+7 -8
View File
@@ -15,19 +15,18 @@ import control.joystick.JoystickListener;
public class GameControl implements JoystickListener, ButtonListener, ActionListener {
private long lastTime = System.currentTimeMillis();
GameModel model;
GameView view;
GameStateManager gsm;
Timer update;
private GameModel model;
private GameView view;
private GameStateManager gsm;
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.view = view;
this.gsm = gsm;
view.setIgnoreRepaint(true);
update = new Timer(1000/60,this);
update.start();
(update = new Timer(1000/60,this)).start();
}
@Override
+9 -8
View File
@@ -20,12 +20,15 @@ import data.io.SQLConnector;
public class GameStateManager {
private List<GameState> gamestates;
public GameState currentState;
private int index = 0;
public int fps;
private float timeOfNoAction = 0,maxTimeToHaveNoAction = 45000;
public GameState currentState;
private SongHandler sh;
private int index = 0;
public int fps;
private float timeOfNoAction = 0,
maxTimeToHaveNoAction = 45000;
public enum State {
TITLE_STATE,
MENU_STATE,
@@ -47,12 +50,10 @@ public class GameStateManager {
{
if (st.ordinal() > 0)
currentState.stopAudio();
currentState = gamestates.get(st.ordinal());
init();
// System.out.println("Current song: "+sh.getCurrentSongInstance());
// sh.set(sh.getCurrentSongInstance());
// sh.play();
}
public void next() {
+15 -18
View File
@@ -12,20 +12,20 @@ import control.joystick.Joystick.Position;
import control.joystick.JoystickHandler;
public class NetworkHandler implements Runnable{
DatagramSocket udp;
String host;
int port;
boolean running;
Thread t;
byte[] send;
byte[] receive;
ButtonHandler bth;
JoystickHandler jth;
private DatagramSocket udp;
private String host;
private int port;
private boolean running;
private Thread t;
private byte[] send,
receive;
private ButtonHandler bth;
private JoystickHandler jth;
public NetworkHandler(String host, int port, ButtonHandler bth, JoystickHandler jth)
{
@@ -62,10 +62,7 @@ public class NetworkHandler implements Runnable{
send(cmd);
}
private void send(String str)
{
}
private void send(String str) { }
public void close()
{
+4 -4
View File
@@ -7,10 +7,10 @@ import control.NetworkHandler;
public class Button {
Color color;
int ledID;
int buttonID;
NetworkHandler ntw;
private Color color;
private int ledID,
buttonID;
private NetworkHandler ntw;
public int pressed;
public Button(int buttonID, int ledID, NetworkHandler ntw)
+6 -14
View File
@@ -20,19 +20,15 @@ import control.NetworkHandler;
public class ButtonHandler implements KeyListener{
List<ButtonListener> listeners;
static List<Button> buttons;
NetworkHandler ntw;
private List<ButtonListener> listeners;
public static List<Button> buttons;
private NetworkHandler ntw;
public ButtonHandler()
{
this.ntw = null;
listeners = new ArrayList<ButtonListener>();
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_06, "0"));
for(GpioPinDigitalInput p:inputpins){
p.addListener(new GpioPinListenerDigital() {
@Override
@@ -82,12 +77,12 @@ public class ButtonHandler implements KeyListener{
}
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.show();
}
ButtonEvent e = new ButtonEvent(b, System.currentTimeMillis());
for (ButtonListener bt : listeners)
bt.buttonReleased(e);
}
@@ -161,12 +156,9 @@ public class ButtonHandler implements KeyListener{
public static Button getButton(int id)
{
for(Button b : buttons)
{
if(b.getButtonID() == id)
{
return b;
}
}
return null;
}