Add and apply editorconfig file.
parent
3f4eafbef8
commit
eaebc0a56c
@ -0,0 +1,11 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
@ -1,20 +1,20 @@
|
||||
package sovereignstudios.helhalla.input;
|
||||
|
||||
public interface InputSource {
|
||||
/**
|
||||
* Some inputs are continuous (like movement keys or joystick position),
|
||||
* but some are discrete (like attacking).
|
||||
* Since one press of the attack key/button should correspond with one attack rather than continuous auto-attacking,
|
||||
* the input should only be read as the attack button being pressed a single time.
|
||||
* Thus, this method will have the side effect of resetting all discrete input events.
|
||||
* For this reason, make sure you only read the input once per frame,
|
||||
* or you risk losing inputs like that.
|
||||
*
|
||||
* Furthermore, if you've been ignoring the input for a while for whatever reason,
|
||||
* make sure you read it once to clear discrete events so that the player
|
||||
* doesn't e.g. accidentally attack after coming back from a pause
|
||||
* because they accidentally pressed the attack button when they put down the controller two hours ago
|
||||
* (or whatever).
|
||||
*/
|
||||
InputState readInput();
|
||||
/**
|
||||
* Some inputs are continuous (like movement keys or joystick position),
|
||||
* but some are discrete (like attacking).
|
||||
* Since one press of the attack key/button should correspond with one attack rather than continuous auto-attacking,
|
||||
* the input should only be read as the attack button being pressed a single time.
|
||||
* Thus, this method will have the side effect of resetting all discrete input events.
|
||||
* For this reason, make sure you only read the input once per frame,
|
||||
* or you risk losing inputs like that.
|
||||
*
|
||||
* Furthermore, if you've been ignoring the input for a while for whatever reason,
|
||||
* make sure you read it once to clear discrete events so that the player
|
||||
* doesn't e.g. accidentally attack after coming back from a pause
|
||||
* because they accidentally pressed the attack button when they put down the controller two hours ago
|
||||
* (or whatever).
|
||||
*/
|
||||
InputState readInput();
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
package sovereignstudios.helhalla.input;
|
||||
|
||||
public interface InputState {
|
||||
/**
|
||||
* The orientation of the player relative to the world, in radians.
|
||||
*
|
||||
* With keyboard input, this will always be up, down, left, right, or a diagonal;
|
||||
* with a joystick, this can be any orientation.
|
||||
*/
|
||||
float getOrientation();
|
||||
|
||||
/**
|
||||
* What proportion (0.0-1.0) of the player's maximum acceleration are they trying to use.
|
||||
*
|
||||
* This essentially corresponds with how hard the player is pressing the 'move' input.
|
||||
* In the case of a keyboard, the button is either pressed or not, so this will always be 0.0 or 1.0.
|
||||
* With a joystick, this corresponds with how far they are pushing the joystick as a proportion of its maximum range.
|
||||
*/
|
||||
float getAcceleration();
|
||||
|
||||
/**
|
||||
* Has the player pressed the 'attack' button.
|
||||
*/
|
||||
boolean isAttacking();
|
||||
/**
|
||||
* The orientation of the player relative to the world, in radians.
|
||||
*
|
||||
* With keyboard input, this will always be up, down, left, right, or a diagonal;
|
||||
* with a joystick, this can be any orientation.
|
||||
*/
|
||||
float getOrientation();
|
||||
|
||||
/**
|
||||
* What proportion (0.0-1.0) of the player's maximum acceleration are they trying to use.
|
||||
*
|
||||
* This essentially corresponds with how hard the player is pressing the 'move' input.
|
||||
* In the case of a keyboard, the button is either pressed or not, so this will always be 0.0 or 1.0.
|
||||
* With a joystick, this corresponds with how far they are pushing the joystick as a proportion of its maximum range.
|
||||
*/
|
||||
float getAcceleration();
|
||||
|
||||
/**
|
||||
* Has the player pressed the 'attack' button.
|
||||
*/
|
||||
boolean isAttacking();
|
||||
}
|
||||
|
@ -1,36 +1,37 @@
|
||||
package sovereignstudios.helhalla.input;
|
||||
|
||||
public class MutableInputState implements InputState {
|
||||
private float orientation = 0.0f;
|
||||
private float acceleration = 0.0f;
|
||||
private boolean attacking = false;
|
||||
|
||||
@Override
|
||||
public float getOrientation() {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAttacking() {
|
||||
return attacking;
|
||||
}
|
||||
|
||||
public MutableInputState() {}
|
||||
|
||||
public void setOrientation(final float orientation) {
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
public void setAcceleration(final float acceleration) {
|
||||
this.acceleration = acceleration;
|
||||
}
|
||||
|
||||
public void setAttacking() {
|
||||
this.attacking = true;
|
||||
}
|
||||
private float orientation = 0.0f;
|
||||
private float acceleration = 0.0f;
|
||||
private boolean attacking = false;
|
||||
|
||||
@Override
|
||||
public float getOrientation() {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAttacking() {
|
||||
return attacking;
|
||||
}
|
||||
|
||||
public MutableInputState() {
|
||||
}
|
||||
|
||||
public void setOrientation(final float orientation) {
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
public void setAcceleration(final float acceleration) {
|
||||
this.acceleration = acceleration;
|
||||
}
|
||||
|
||||
public void setAttacking() {
|
||||
this.attacking = true;
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,34 @@
|
||||
package sovereignstudios.helhalla.input;
|
||||
|
||||
public final class Xbox360Controller {
|
||||
public static final String XBOX360_WIRELESS_RECEIVER = "Xbox 360 Wireless Receiver";
|
||||
|
||||
public static final int BUTTON_A = 0;
|
||||
public static final int BUTTON_B = 1;
|
||||
public static final int BUTTON_X = 2;
|
||||
public static final int BUTTON_Y = 3;
|
||||
public static final int BUTTON_LEFT_BUMPER = 4;
|
||||
public static final int BUTTON_RIGHT_BUMPER = 5;
|
||||
public static final int BUTTON_BACK = 6;
|
||||
public static final int BUTTON_START = 7;
|
||||
public static final int BUTTON_XBOX = 8;
|
||||
/** Triggered when you press down on the joystick, not when it's moved. */
|
||||
public static final int BUTTON_LEFT_JOYSTICK = 9;
|
||||
public static final int BUTTON_RIGHT_JOYSTICK = 10;
|
||||
public static final int BUTTON_DPAD_LEFT = 11;
|
||||
public static final int BUTTON_DPAD_RIGHT = 12;
|
||||
public static final int BUTTON_DPAD_UP = 13;
|
||||
public static final int BUTTON_DPAD_DOWN = 14;
|
||||
|
||||
public static final int AXIS_LEFT_JOYSTICK_X = 0;
|
||||
public static final int AXIS_LEFT_JOYSTICK_Y = 1;
|
||||
public static final int AXIS_LEFT_TRIGGER = 2;
|
||||
public static final int AXIS_RIGHT_JOYSTICK_X = 3;
|
||||
public static final int AXIS_RIGHT_JOYSTICK_Y = 4;
|
||||
public static final int AXIS_RIGHT_TRIGGER = 5;
|
||||
|
||||
public static final float AXIS_PRESS_THRESHOLD = 0.2f;
|
||||
|
||||
private Xbox360Controller() {}
|
||||
public static final String XBOX360_WIRELESS_RECEIVER = "Xbox 360 Wireless Receiver";
|
||||
|
||||
public static final int BUTTON_A = 0;
|
||||
public static final int BUTTON_B = 1;
|
||||
public static final int BUTTON_X = 2;
|
||||
public static final int BUTTON_Y = 3;
|
||||
public static final int BUTTON_LEFT_BUMPER = 4;
|
||||
public static final int BUTTON_RIGHT_BUMPER = 5;
|
||||
public static final int BUTTON_BACK = 6;
|
||||
public static final int BUTTON_START = 7;
|
||||
public static final int BUTTON_XBOX = 8;
|
||||
/** Triggered when you press down on the joystick, not when it's moved. */
|
||||
public static final int BUTTON_LEFT_JOYSTICK = 9;
|
||||
public static final int BUTTON_RIGHT_JOYSTICK = 10;
|
||||
public static final int BUTTON_DPAD_LEFT = 11;
|
||||
public static final int BUTTON_DPAD_RIGHT = 12;
|
||||
public static final int BUTTON_DPAD_UP = 13;
|
||||
public static final int BUTTON_DPAD_DOWN = 14;
|
||||
|
||||
public static final int AXIS_LEFT_JOYSTICK_X = 0;
|
||||
public static final int AXIS_LEFT_JOYSTICK_Y = 1;
|
||||
public static final int AXIS_LEFT_TRIGGER = 2;
|
||||
public static final int AXIS_RIGHT_JOYSTICK_X = 3;
|
||||
public static final int AXIS_RIGHT_JOYSTICK_Y = 4;
|
||||
public static final int AXIS_RIGHT_TRIGGER = 5;
|
||||
|
||||
public static final float AXIS_PRESS_THRESHOLD = 0.2f;
|
||||
|
||||
private Xbox360Controller() {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue