Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epoxy
GitHub Repository: epoxy/proj11
Path: blob/master/SLICK_HOME/src/org/newdawn/slick/BasicGame.java
1456 views
1
package org.newdawn.slick;
2
3
4
/**
5
* A basic implementation of a game to take out the boring bits
6
*
7
* @author kevin
8
*/
9
public abstract class BasicGame implements Game, InputListener {
10
/** The maximum number of controllers supported by the basic game */
11
private static final int MAX_CONTROLLERS = 20;
12
/** The maximum number of controller buttons supported by the basic game */
13
private static final int MAX_CONTROLLER_BUTTONS = 100;
14
/** The title of the game */
15
private String title;
16
/** The state of the left control */
17
protected boolean[] controllerLeft = new boolean[MAX_CONTROLLERS];
18
/** The state of the right control */
19
protected boolean[] controllerRight = new boolean[MAX_CONTROLLERS];
20
/** The state of the up control */
21
protected boolean[] controllerUp = new boolean[MAX_CONTROLLERS];
22
/** The state of the down control */
23
protected boolean[] controllerDown = new boolean[MAX_CONTROLLERS];
24
/** The state of the button controlls */
25
protected boolean[][] controllerButton = new boolean[MAX_CONTROLLERS][MAX_CONTROLLER_BUTTONS];
26
27
/**
28
* Create a new basic game
29
*
30
* @param title The title for the game
31
*/
32
public BasicGame(String title) {
33
this.title = title;
34
}
35
36
/**
37
* @see org.newdawn.slick.InputListener#setInput(org.newdawn.slick.Input)
38
*/
39
public void setInput(Input input) {
40
}
41
42
/**
43
* @see org.newdawn.slick.Game#closeRequested()
44
*/
45
public boolean closeRequested() {
46
return true;
47
}
48
49
/**
50
* @see org.newdawn.slick.Game#getTitle()
51
*/
52
public String getTitle() {
53
return title;
54
}
55
56
/**
57
* @see org.newdawn.slick.Game#init(org.newdawn.slick.GameContainer)
58
*/
59
public abstract void init(GameContainer container) throws SlickException;
60
61
/**
62
* @see org.newdawn.slick.InputListener#keyPressed(int, char)
63
*/
64
public void keyPressed(int key, char c) {
65
}
66
67
/**
68
* @see org.newdawn.slick.InputListener#keyReleased(int, char)
69
*/
70
public void keyReleased(int key, char c) {
71
}
72
73
/**
74
* @see org.newdawn.slick.InputListener#mouseMoved(int, int, int, int)
75
*/
76
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
77
}
78
79
/**
80
* @see org.newdawn.slick.InputListener#mouseDragged(int, int, int, int)
81
*/
82
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
83
}
84
85
/**
86
* @see org.newdawn.slick.InputListener#mouseClicked(int, int, int, int)
87
*/
88
public void mouseClicked(int button, int x, int y, int clickCount) {
89
}
90
91
/**
92
* @see org.newdawn.slick.InputListener#mousePressed(int, int, int)
93
*/
94
public void mousePressed(int button, int x, int y) {
95
96
}
97
98
/**
99
* @see org.newdawn.slick.InputListener#controllerButtonPressed(int, int)
100
*/
101
public void controllerButtonPressed(int controller, int button) {
102
controllerButton[controller][button] = true;
103
}
104
105
/**
106
* @see org.newdawn.slick.InputListener#controllerButtonReleased(int, int)
107
*/
108
public void controllerButtonReleased(int controller, int button) {
109
controllerButton[controller][button] = false;
110
}
111
112
/**
113
* @see org.newdawn.slick.InputListener#controllerDownPressed(int)
114
*/
115
public void controllerDownPressed(int controller) {
116
controllerDown[controller] = true;
117
}
118
119
/**
120
* @see org.newdawn.slick.InputListener#controllerDownReleased(int)
121
*/
122
public void controllerDownReleased(int controller) {
123
controllerDown[controller] = false;
124
}
125
126
/**
127
* @see org.newdawn.slick.InputListener#controllerLeftPressed(int)
128
*/
129
public void controllerLeftPressed(int controller) {
130
controllerLeft[controller] = true;
131
}
132
133
/**
134
* @see org.newdawn.slick.InputListener#controllerLeftReleased(int)
135
*/
136
public void controllerLeftReleased(int controller) {
137
controllerLeft[controller] = false;
138
}
139
140
/**
141
* @see org.newdawn.slick.InputListener#controllerRightPressed(int)
142
*/
143
public void controllerRightPressed(int controller) {
144
controllerRight[controller] = true;
145
}
146
147
/**
148
* @see org.newdawn.slick.InputListener#controllerRightReleased(int)
149
*/
150
public void controllerRightReleased(int controller) {
151
controllerRight[controller] = false;
152
}
153
154
/**
155
* @see org.newdawn.slick.InputListener#controllerUpPressed(int)
156
*/
157
public void controllerUpPressed(int controller) {
158
controllerUp[controller] = true;
159
}
160
161
/**
162
* @see org.newdawn.slick.InputListener#controllerUpReleased(int)
163
*/
164
public void controllerUpReleased(int controller) {
165
controllerUp[controller] = false;
166
}
167
168
/**
169
* @see org.newdawn.slick.InputListener#mouseReleased(int, int, int)
170
*/
171
public void mouseReleased(int button, int x, int y) {
172
}
173
174
/**
175
* @see org.newdawn.slick.Game#update(org.newdawn.slick.GameContainer, int)
176
*/
177
public abstract void update(GameContainer container, int delta) throws SlickException;
178
179
/**
180
* @see org.newdawn.slick.InputListener#mouseWheelMoved(int)
181
*/
182
public void mouseWheelMoved(int change) {
183
}
184
185
/**
186
* @see org.newdawn.slick.InputListener#isAcceptingInput()
187
*/
188
public boolean isAcceptingInput() {
189
return true;
190
}
191
192
/**
193
* @see org.newdawn.slick.InputListener#inputEnded()
194
*/
195
public void inputEnded() {
196
197
}
198
199
/**
200
* @see org.newdawn.slick.ControlledInputReciever#inputStarted()
201
*/
202
public void inputStarted() {
203
204
}
205
}
206
207