GameSprint1Done, little bug. When aiming right down not possible to hit with button 1 and 3 :S
This commit is contained in:
@@ -7,27 +7,33 @@ import control.button.ButtonListener;
|
||||
import control.joystick.JoystickEvent;
|
||||
import control.joystick.JoystickListener;
|
||||
|
||||
public class GameControl implements JoystickListener, ButtonListener{
|
||||
public class GameControl implements JoystickListener, ButtonListener {
|
||||
|
||||
GameModel model;
|
||||
GameView view;
|
||||
GameStateManager gsm;
|
||||
|
||||
public GameControl(GameModel model, GameView view)
|
||||
public GameControl(GameModel model, GameView view,GameStateManager gsm)
|
||||
{
|
||||
this.model = model;
|
||||
this.view = view;
|
||||
this.gsm = gsm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonPressed(ButtonEvent e) {
|
||||
|
||||
public void buttonPressed(ButtonEvent e) {
|
||||
// System.out.println("Game control, button pressed: "+e.getButton().getButtonID());
|
||||
gsm.currentState.buttonPressed(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonReleased(ButtonEvent e) {}
|
||||
public void buttonReleased(ButtonEvent e) {
|
||||
// System.out.println("Game control, button released: "+e.getButton().getButtonID());
|
||||
gsm.currentState.buttonReleased(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoystickMoved(JoystickEvent e) {
|
||||
|
||||
gsm.currentState.onJoystickMoved(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public class GameStateManager {
|
||||
public void next() {
|
||||
index++;
|
||||
index %= gamestates.size();
|
||||
currentState = gamestates.get(index);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
currentState = gamestates.get(index);
|
||||
public void update(){
|
||||
currentState.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,12 @@ public class JoystickHandler implements KeyListener{
|
||||
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent e) {
|
||||
if(e.getState() == PinState.HIGH){
|
||||
keyReleased(new KeyEvent(
|
||||
new java.awt.Component(){},
|
||||
new java.awt.Component(){
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;},
|
||||
KeyEvent.KEY_RELEASED,
|
||||
System.nanoTime(),
|
||||
0,
|
||||
@@ -60,7 +65,12 @@ public class JoystickHandler implements KeyListener{
|
||||
System.out.println(e.getPin().getName() + " Released");
|
||||
}else{
|
||||
keyPressed(new KeyEvent(
|
||||
new java.awt.Component(){},
|
||||
new java.awt.Component(){
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;},
|
||||
KeyEvent.KEY_PRESSED,
|
||||
System.nanoTime(),
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user