Path: blob/master/SLICK_HOME/src/org/newdawn/slick/BasicGame.java
1456 views
package org.newdawn.slick;123/**4* A basic implementation of a game to take out the boring bits5*6* @author kevin7*/8public abstract class BasicGame implements Game, InputListener {9/** The maximum number of controllers supported by the basic game */10private static final int MAX_CONTROLLERS = 20;11/** The maximum number of controller buttons supported by the basic game */12private static final int MAX_CONTROLLER_BUTTONS = 100;13/** The title of the game */14private String title;15/** The state of the left control */16protected boolean[] controllerLeft = new boolean[MAX_CONTROLLERS];17/** The state of the right control */18protected boolean[] controllerRight = new boolean[MAX_CONTROLLERS];19/** The state of the up control */20protected boolean[] controllerUp = new boolean[MAX_CONTROLLERS];21/** The state of the down control */22protected boolean[] controllerDown = new boolean[MAX_CONTROLLERS];23/** The state of the button controlls */24protected boolean[][] controllerButton = new boolean[MAX_CONTROLLERS][MAX_CONTROLLER_BUTTONS];2526/**27* Create a new basic game28*29* @param title The title for the game30*/31public BasicGame(String title) {32this.title = title;33}3435/**36* @see org.newdawn.slick.InputListener#setInput(org.newdawn.slick.Input)37*/38public void setInput(Input input) {39}4041/**42* @see org.newdawn.slick.Game#closeRequested()43*/44public boolean closeRequested() {45return true;46}4748/**49* @see org.newdawn.slick.Game#getTitle()50*/51public String getTitle() {52return title;53}5455/**56* @see org.newdawn.slick.Game#init(org.newdawn.slick.GameContainer)57*/58public abstract void init(GameContainer container) throws SlickException;5960/**61* @see org.newdawn.slick.InputListener#keyPressed(int, char)62*/63public void keyPressed(int key, char c) {64}6566/**67* @see org.newdawn.slick.InputListener#keyReleased(int, char)68*/69public void keyReleased(int key, char c) {70}7172/**73* @see org.newdawn.slick.InputListener#mouseMoved(int, int, int, int)74*/75public void mouseMoved(int oldx, int oldy, int newx, int newy) {76}7778/**79* @see org.newdawn.slick.InputListener#mouseDragged(int, int, int, int)80*/81public void mouseDragged(int oldx, int oldy, int newx, int newy) {82}8384/**85* @see org.newdawn.slick.InputListener#mouseClicked(int, int, int, int)86*/87public void mouseClicked(int button, int x, int y, int clickCount) {88}8990/**91* @see org.newdawn.slick.InputListener#mousePressed(int, int, int)92*/93public void mousePressed(int button, int x, int y) {9495}9697/**98* @see org.newdawn.slick.InputListener#controllerButtonPressed(int, int)99*/100public void controllerButtonPressed(int controller, int button) {101controllerButton[controller][button] = true;102}103104/**105* @see org.newdawn.slick.InputListener#controllerButtonReleased(int, int)106*/107public void controllerButtonReleased(int controller, int button) {108controllerButton[controller][button] = false;109}110111/**112* @see org.newdawn.slick.InputListener#controllerDownPressed(int)113*/114public void controllerDownPressed(int controller) {115controllerDown[controller] = true;116}117118/**119* @see org.newdawn.slick.InputListener#controllerDownReleased(int)120*/121public void controllerDownReleased(int controller) {122controllerDown[controller] = false;123}124125/**126* @see org.newdawn.slick.InputListener#controllerLeftPressed(int)127*/128public void controllerLeftPressed(int controller) {129controllerLeft[controller] = true;130}131132/**133* @see org.newdawn.slick.InputListener#controllerLeftReleased(int)134*/135public void controllerLeftReleased(int controller) {136controllerLeft[controller] = false;137}138139/**140* @see org.newdawn.slick.InputListener#controllerRightPressed(int)141*/142public void controllerRightPressed(int controller) {143controllerRight[controller] = true;144}145146/**147* @see org.newdawn.slick.InputListener#controllerRightReleased(int)148*/149public void controllerRightReleased(int controller) {150controllerRight[controller] = false;151}152153/**154* @see org.newdawn.slick.InputListener#controllerUpPressed(int)155*/156public void controllerUpPressed(int controller) {157controllerUp[controller] = true;158}159160/**161* @see org.newdawn.slick.InputListener#controllerUpReleased(int)162*/163public void controllerUpReleased(int controller) {164controllerUp[controller] = false;165}166167/**168* @see org.newdawn.slick.InputListener#mouseReleased(int, int, int)169*/170public void mouseReleased(int button, int x, int y) {171}172173/**174* @see org.newdawn.slick.Game#update(org.newdawn.slick.GameContainer, int)175*/176public abstract void update(GameContainer container, int delta) throws SlickException;177178/**179* @see org.newdawn.slick.InputListener#mouseWheelMoved(int)180*/181public void mouseWheelMoved(int change) {182}183184/**185* @see org.newdawn.slick.InputListener#isAcceptingInput()186*/187public boolean isAcceptingInput() {188return true;189}190191/**192* @see org.newdawn.slick.InputListener#inputEnded()193*/194public void inputEnded() {195196}197198/**199* @see org.newdawn.slick.ControlledInputReciever#inputStarted()200*/201public void inputStarted() {202203}204}205206207