|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.state.StateBasedGame
public abstract class StateBasedGame
A state based game isolated different stages of the game (menu, ingame, hiscores, etc) into different states so they can be easily managed and maintained.
Constructor Summary | |
---|---|
StateBasedGame(java.lang.String name)
Create a new state based game |
Method Summary | |
---|---|
void |
addState(GameState state)
Add a state to the game. |
boolean |
closeRequested()
Notification that a game close has been requested |
void |
controllerButtonPressed(int controller,
int button)
Notification that a button control has been pressed on the controller. |
void |
controllerButtonReleased(int controller,
int button)
Notification that a button control has been released on the controller. |
void |
controllerDownPressed(int controller)
Notification that the down control has been pressed on the controller. |
void |
controllerDownReleased(int controller)
Notification that the down control has been released on the controller. |
void |
controllerLeftPressed(int controller)
Notification that the left control has been pressed on the controller. |
void |
controllerLeftReleased(int controller)
Notification that the left control has been released on the controller. |
void |
controllerRightPressed(int controller)
Notification that the right control has been pressed on the controller. |
void |
controllerRightReleased(int controller)
Notification that the right control has been released on the controller. |
void |
controllerUpPressed(int controller)
Notification that the up control has been pressed on the controller. |
void |
controllerUpReleased(int controller)
Notification that the up control has been released on the controller. |
void |
enterState(int id)
Enter a particular game state with no transition |
void |
enterState(int id,
Transition leave,
Transition enter)
Enter a particular game state with the transitions provided |
GameContainer |
getContainer()
Get the container holding this game |
GameState |
getCurrentState()
Get the state the game is currently in |
int |
getCurrentStateID()
Get the ID of the state the game is currently in |
GameState |
getState(int id)
Get a state based on it's identifier |
int |
getStateCount()
Get the number of states that have been added to this game |
java.lang.String |
getTitle()
Get the title of this game |
void |
init(GameContainer container)
Initialise the game. |
abstract void |
initStatesList(GameContainer container)
Initialise the list of states making up this game |
void |
inputEnded()
Notification that all input events have been sent for this frame |
void |
inputStarted()
Notification that input is about to be processed |
boolean |
isAcceptingInput()
Check if this input listener is accepting input |
void |
keyPressed(int key,
char c)
Notification that a key was pressed |
void |
keyReleased(int key,
char c)
Notification that a key was released |
void |
mouseClicked(int button,
int x,
int y,
int clickCount)
Notification that a mouse button was clicked. |
void |
mouseDragged(int oldx,
int oldy,
int newx,
int newy)
Notification that mouse cursor was dragged |
void |
mouseMoved(int oldx,
int oldy,
int newx,
int newy)
Notification that mouse cursor was moved |
void |
mousePressed(int button,
int x,
int y)
Notification that a mouse button was pressed |
void |
mouseReleased(int button,
int x,
int y)
Notification that a mouse button was released |
void |
mouseWheelMoved(int newValue)
Notification that the mouse wheel position was updated |
protected void |
postRenderState(GameContainer container,
Graphics g)
User hook for rendering at the game level after the current state and/or transition have been rendered |
protected void |
postUpdateState(GameContainer container,
int delta)
User hook for rendering at the game level after the current state and/or transition have been updated |
protected void |
preRenderState(GameContainer container,
Graphics g)
User hook for rendering at the before the current state and/or transition have been rendered |
protected void |
preUpdateState(GameContainer container,
int delta)
User hook for updating at the game before the current state and/or transition have been updated |
void |
render(GameContainer container,
Graphics g)
Render the game's screen here. |
void |
setInput(Input input)
Set the input that events are being sent from |
void |
update(GameContainer container,
int delta)
Update the game logic here. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StateBasedGame(java.lang.String name)
name
- The name of the gameMethod Detail |
---|
public void inputStarted()
ControlledInputReciever
inputStarted
in interface ControlledInputReciever
ControlledInputReciever.inputStarted()
public int getStateCount()
public int getCurrentStateID()
public GameState getCurrentState()
public void setInput(Input input)
ControlledInputReciever
setInput
in interface ControlledInputReciever
input
- The input instance sending eventsControlledInputReciever.setInput(org.newdawn.slick.Input)
public void addState(GameState state)
state
- The state to be addedpublic GameState getState(int id)
id
- The ID of the state to retrieve
public void enterState(int id)
id
- The ID of the state to enterpublic void enterState(int id, Transition leave, Transition enter)
id
- The ID of the state to enterleave
- The transition to use when leaving the current stateenter
- The transition to use when entering the new statepublic final void init(GameContainer container) throws SlickException
Game
init
in interface Game
container
- The container holding the game
SlickException
- Throw to indicate an internal errorBasicGame.init(org.newdawn.slick.GameContainer)
public abstract void initStatesList(GameContainer container) throws SlickException
container
- The container holding the game
SlickException
- Indicates a failure to initialise the state based game resourcespublic final void render(GameContainer container, Graphics g) throws SlickException
Game
render
in interface Game
container
- The container holing this gameg
- The graphics context that can be used to render. However, normal rendering
routines can also be used.
SlickException
- Throw to indicate a internal errorGame.render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
protected void preRenderState(GameContainer container, Graphics g) throws SlickException
container
- The container in which the game is hostedg
- The graphics context on which to draw
SlickException
- Indicates a failure within renderprotected void postRenderState(GameContainer container, Graphics g) throws SlickException
container
- The container in which the game is hostedg
- The graphics context on which to draw
SlickException
- Indicates a failure within renderpublic final void update(GameContainer container, int delta) throws SlickException
Game
update
in interface Game
container
- The container holing this gamedelta
- The amount of time thats passed since last update in milliseconds
SlickException
- Throw to indicate an internal errorBasicGame.update(org.newdawn.slick.GameContainer, int)
protected void preUpdateState(GameContainer container, int delta) throws SlickException
container
- The container in which the game is hosteddelta
- The amount of time in milliseconds since last update
SlickException
- Indicates a failure within renderprotected void postUpdateState(GameContainer container, int delta) throws SlickException
container
- The container in which the game is hosteddelta
- The amount of time in milliseconds since last update
SlickException
- Indicates a failure within renderpublic boolean closeRequested()
Game
closeRequested
in interface Game
Game.closeRequested()
public java.lang.String getTitle()
Game
getTitle
in interface Game
Game.getTitle()
public GameContainer getContainer()
public void controllerButtonPressed(int controller, int button)
ControllerListener
controllerButtonPressed
in interface ControllerListener
controller
- The index of the controller on which the control
was pressed.button
- The index of the button pressed (starting at 1)ControllerListener.controllerButtonPressed(int, int)
public void controllerButtonReleased(int controller, int button)
ControllerListener
controllerButtonReleased
in interface ControllerListener
controller
- The index of the controller on which the control
was released.button
- The index of the button released (starting at 1)ControllerListener.controllerButtonReleased(int, int)
public void controllerDownPressed(int controller)
ControllerListener
controllerDownPressed
in interface ControllerListener
controller
- The index of the controller on which the control
was pressed.ControllerListener.controllerDownPressed(int)
public void controllerDownReleased(int controller)
ControllerListener
controllerDownReleased
in interface ControllerListener
controller
- The index of the controller on which the control
was released.ControllerListener.controllerDownReleased(int)
public void controllerLeftPressed(int controller)
ControllerListener
controllerLeftPressed
in interface ControllerListener
controller
- The index of the controller on which the control
was pressed.ControllerListener.controllerLeftPressed(int)
public void controllerLeftReleased(int controller)
ControllerListener
controllerLeftReleased
in interface ControllerListener
controller
- The index of the controller on which the control
was released.ControllerListener.controllerLeftReleased(int)
public void controllerRightPressed(int controller)
ControllerListener
controllerRightPressed
in interface ControllerListener
controller
- The index of the controller on which the control
was pressed.ControllerListener.controllerRightPressed(int)
public void controllerRightReleased(int controller)
ControllerListener
controllerRightReleased
in interface ControllerListener
controller
- The index of the controller on which the control
was released.ControllerListener.controllerRightReleased(int)
public void controllerUpPressed(int controller)
ControllerListener
controllerUpPressed
in interface ControllerListener
controller
- The index of the controller on which the control
was pressed.ControllerListener.controllerUpPressed(int)
public void controllerUpReleased(int controller)
ControllerListener
controllerUpReleased
in interface ControllerListener
controller
- The index of the controller on which the control
was released.ControllerListener.controllerUpReleased(int)
public void keyPressed(int key, char c)
KeyListener
keyPressed
in interface KeyListener
key
- The key code that was pressed (@see org.newdawn.slick.Input)c
- The character of the key that was pressedKeyListener.keyPressed(int, char)
public void keyReleased(int key, char c)
KeyListener
keyReleased
in interface KeyListener
key
- The key code that was released (@see org.newdawn.slick.Input)c
- The character of the key that was releasedKeyListener.keyReleased(int, char)
public void mouseMoved(int oldx, int oldy, int newx, int newy)
MouseListener
mouseMoved
in interface MouseListener
oldx
- The old x position of the mouseoldy
- The old y position of the mousenewx
- The new x position of the mousenewy
- The new y position of the mouseMouseListener.mouseMoved(int, int, int, int)
public void mouseDragged(int oldx, int oldy, int newx, int newy)
MouseListener
mouseDragged
in interface MouseListener
oldx
- The old x position of the mouseoldy
- The old y position of the mousenewx
- The new x position of the mousenewy
- The new y position of the mouseMouseListener.mouseDragged(int, int, int, int)
public void mouseClicked(int button, int x, int y, int clickCount)
MouseListener
mouseClicked
in interface MouseListener
button
- The index of the button (starting at 0)x
- The x position of the mouse when the button was pressedy
- The y position of the mouse when the button was pressedclickCount
- The number of times the button was clickedMouseListener.mouseClicked(int, int, int, int)
public void mousePressed(int button, int x, int y)
MouseListener
mousePressed
in interface MouseListener
button
- The index of the button (starting at 0)x
- The x position of the mouse when the button was pressedy
- The y position of the mouse when the button was pressedMouseListener.mousePressed(int, int, int)
public void mouseReleased(int button, int x, int y)
MouseListener
mouseReleased
in interface MouseListener
button
- The index of the button (starting at 0)x
- The x position of the mouse when the button was releasedy
- The y position of the mouse when the button was releasedMouseListener.mouseReleased(int, int, int)
public boolean isAcceptingInput()
ControlledInputReciever
isAcceptingInput
in interface ControlledInputReciever
ControlledInputReciever.isAcceptingInput()
public void inputEnded()
ControlledInputReciever
inputEnded
in interface ControlledInputReciever
ControlledInputReciever.inputEnded()
public void mouseWheelMoved(int newValue)
MouseListener
mouseWheelMoved
in interface MouseListener
newValue
- The amount of the wheel has movedMouseListener.mouseWheelMoved(int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |