Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epoxy
GitHub Repository: epoxy/proj11
Path: blob/master/SLICK_HOME/src/org/newdawn/slick/command/ControllerDirectionControl.java
1456 views
1
package org.newdawn.slick.command;
2
3
/**
4
* A control indicating that a particular direction must be pressed or released
5
* on a controller to cause the command to fire
6
*
7
* @author kevin
8
*/
9
public class ControllerDirectionControl extends ControllerControl {
10
/** The direction indicating we're waiting for the user to press left */
11
public static final Direction LEFT = new Direction(LEFT_EVENT);
12
/** The direction indicating we're waiting for the user to press up */
13
public static final Direction UP = new Direction(UP_EVENT);
14
/** The direction indicating we're waiting for the user to press down */
15
public static final Direction DOWN = new Direction(DOWN_EVENT);
16
/** The direction indicating we're waiting for the user to press right */
17
public static final Direction RIGHT = new Direction(RIGHT_EVENT);
18
19
/**
20
* Create a new input that indicates a direcitonal control must be pressed
21
*
22
* @param controllerIndex The index of the controller to listen to
23
* @param dir The direction to wait for
24
*/
25
public ControllerDirectionControl(int controllerIndex, Direction dir) {
26
super(controllerIndex, dir.event, 0);
27
}
28
29
/**
30
* Enum pretender
31
*
32
* @author kevin
33
*/
34
private static class Direction {
35
/** The event to be fired for this direction */
36
private int event;
37
38
/**
39
* Create a new direction indicator/enum value
40
*
41
* @param event The event to fire when this direction is used
42
*/
43
public Direction(int event) {
44
this.event = event;
45
}
46
}
47
}
48
49