org.newdawn.slick
Class BasicGame

java.lang.Object
  extended by org.newdawn.slick.BasicGame
All Implemented Interfaces:
ControlledInputReciever, ControllerListener, Game, InputListener, KeyListener, MouseListener
Direct Known Subclasses:
AlphaMapTest, AnimationTest, AntiAliasTest, BigImageTest, BigSpriteSheetTest, CachedRenderTest, CanvasContainerTest, CanvasSizeTest, ClipTest, CopyAreaAlphaTest, CurveTest, DeferredLoadingTest, DistanceFieldTest, DoubleClickTest, DuplicateEmitterTest, FlashTest, FontPerformanceTest, FontTest, GeomAccuracyTest, GeomTest, GeomUtilTest, GeomUtilTileTest, GradientImageTest, GradientTest, GraphicsTest, GUITest, ImageBufferEndianTest, ImageBufferTest, ImageCornerTest, ImageGraphicsTest, ImageMemTest, ImageOutTest, ImageReadTest, ImageTest, InkscapeTest, InputProviderTest, InputTest, IsoTiledTest, KeyRepeatTest, LameTest, LineRenderTest, MorphShapeTest, MorphSVGTest, MusicListenerTest, NavMeshTest, PackedSheetTest, ParticleTest, PedigreeTest, PolygonTest, PureFontTest, SavedStateTest, ScalableTest, ShapeTest, SlickCallableTest, SoundPositionTest, SoundTest, SoundURLTest, SpriteSheetFontTest, TestBox, TexturePaintTest, TileMapTest, TransformTest, TransformTest2, TransparentColorTest, TrueTypeFontPerformanceTest, UnicodeFontTest

public abstract class BasicGame
extends java.lang.Object
implements Game, InputListener

A basic implementation of a game to take out the boring bits

Author:
kevin

Field Summary
protected  boolean[][] controllerButton
          The state of the button controlls
protected  boolean[] controllerDown
          The state of the down control
protected  boolean[] controllerLeft
          The state of the left control
protected  boolean[] controllerRight
          The state of the right control
protected  boolean[] controllerUp
          The state of the up control
 
Constructor Summary
BasicGame(java.lang.String title)
          Create a new basic game
 
Method Summary
 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.
 java.lang.String getTitle()
          Get the title of this game
abstract  void init(GameContainer container)
          Initialise the 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 change)
          Notification that the mouse wheel position was updated
 void setInput(Input input)
          Set the input that events are being sent from
abstract  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
 
Methods inherited from interface org.newdawn.slick.Game
render
 

Field Detail

controllerLeft

protected boolean[] controllerLeft
The state of the left control


controllerRight

protected boolean[] controllerRight
The state of the right control


controllerUp

protected boolean[] controllerUp
The state of the up control


controllerDown

protected boolean[] controllerDown
The state of the down control


controllerButton

protected boolean[][] controllerButton
The state of the button controlls

Constructor Detail

BasicGame

public BasicGame(java.lang.String title)
Create a new basic game

Parameters:
title - The title for the game
Method Detail

setInput

public void setInput(Input input)
Description copied from interface: ControlledInputReciever
Set the input that events are being sent from

Specified by:
setInput in interface ControlledInputReciever
Parameters:
input - The input instance sending events
See Also:
ControlledInputReciever.setInput(org.newdawn.slick.Input)

closeRequested

public boolean closeRequested()
Description copied from interface: Game
Notification that a game close has been requested

Specified by:
closeRequested in interface Game
Returns:
True if the game should close
See Also:
Game.closeRequested()

getTitle

public java.lang.String getTitle()
Description copied from interface: Game
Get the title of this game

Specified by:
getTitle in interface Game
Returns:
The title of the game
See Also:
Game.getTitle()

init

public abstract void init(GameContainer container)
                   throws SlickException
Description copied from interface: Game
Initialise the game. This can be used to load static resources. It's called before the game loop starts

Specified by:
init in interface Game
Parameters:
container - The container holding the game
Throws:
SlickException - Throw to indicate an internal error
See Also:
Game.init(org.newdawn.slick.GameContainer)

keyPressed

public void keyPressed(int key,
                       char c)
Description copied from interface: KeyListener
Notification that a key was pressed

Specified by:
keyPressed in interface KeyListener
Parameters:
key - The key code that was pressed (@see org.newdawn.slick.Input)
c - The character of the key that was pressed
See Also:
KeyListener.keyPressed(int, char)

keyReleased

public void keyReleased(int key,
                        char c)
Description copied from interface: KeyListener
Notification that a key was released

Specified by:
keyReleased in interface KeyListener
Parameters:
key - The key code that was released (@see org.newdawn.slick.Input)
c - The character of the key that was released
See Also:
KeyListener.keyReleased(int, char)

mouseMoved

public void mouseMoved(int oldx,
                       int oldy,
                       int newx,
                       int newy)
Description copied from interface: MouseListener
Notification that mouse cursor was moved

Specified by:
mouseMoved in interface MouseListener
Parameters:
oldx - The old x position of the mouse
oldy - The old y position of the mouse
newx - The new x position of the mouse
newy - The new y position of the mouse
See Also:
MouseListener.mouseMoved(int, int, int, int)

mouseDragged

public void mouseDragged(int oldx,
                         int oldy,
                         int newx,
                         int newy)
Description copied from interface: MouseListener
Notification that mouse cursor was dragged

Specified by:
mouseDragged in interface MouseListener
Parameters:
oldx - The old x position of the mouse
oldy - The old y position of the mouse
newx - The new x position of the mouse
newy - The new y position of the mouse
See Also:
MouseListener.mouseDragged(int, int, int, int)

mouseClicked

public void mouseClicked(int button,
                         int x,
                         int y,
                         int clickCount)
Description copied from interface: MouseListener
Notification that a mouse button was clicked. Due to double click handling the single click may be delayed slightly. For absolute notification of single clicks use mousePressed(). To be absolute this method should only be used when considering double clicks

Specified by:
mouseClicked in interface MouseListener
Parameters:
button - The index of the button (starting at 0)
x - The x position of the mouse when the button was pressed
y - The y position of the mouse when the button was pressed
clickCount - The number of times the button was clicked
See Also:
MouseListener.mouseClicked(int, int, int, int)

mousePressed

public void mousePressed(int button,
                         int x,
                         int y)
Description copied from interface: MouseListener
Notification that a mouse button was pressed

Specified by:
mousePressed in interface MouseListener
Parameters:
button - The index of the button (starting at 0)
x - The x position of the mouse when the button was pressed
y - The y position of the mouse when the button was pressed
See Also:
MouseListener.mousePressed(int, int, int)

controllerButtonPressed

public void controllerButtonPressed(int controller,
                                    int button)
Description copied from interface: ControllerListener
Notification that a button control has been pressed on the controller.

Specified by:
controllerButtonPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
button - The index of the button pressed (starting at 1)
See Also:
ControllerListener.controllerButtonPressed(int, int)

controllerButtonReleased

public void controllerButtonReleased(int controller,
                                     int button)
Description copied from interface: ControllerListener
Notification that a button control has been released on the controller.

Specified by:
controllerButtonReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
button - The index of the button released (starting at 1)
See Also:
ControllerListener.controllerButtonReleased(int, int)

controllerDownPressed

public void controllerDownPressed(int controller)
Description copied from interface: ControllerListener
Notification that the down control has been pressed on the controller.

Specified by:
controllerDownPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerDownPressed(int)

controllerDownReleased

public void controllerDownReleased(int controller)
Description copied from interface: ControllerListener
Notification that the down control has been released on the controller.

Specified by:
controllerDownReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerDownReleased(int)

controllerLeftPressed

public void controllerLeftPressed(int controller)
Description copied from interface: ControllerListener
Notification that the left control has been pressed on the controller.

Specified by:
controllerLeftPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerLeftPressed(int)

controllerLeftReleased

public void controllerLeftReleased(int controller)
Description copied from interface: ControllerListener
Notification that the left control has been released on the controller.

Specified by:
controllerLeftReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerLeftReleased(int)

controllerRightPressed

public void controllerRightPressed(int controller)
Description copied from interface: ControllerListener
Notification that the right control has been pressed on the controller.

Specified by:
controllerRightPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerRightPressed(int)

controllerRightReleased

public void controllerRightReleased(int controller)
Description copied from interface: ControllerListener
Notification that the right control has been released on the controller.

Specified by:
controllerRightReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerRightReleased(int)

controllerUpPressed

public void controllerUpPressed(int controller)
Description copied from interface: ControllerListener
Notification that the up control has been pressed on the controller.

Specified by:
controllerUpPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerUpPressed(int)

controllerUpReleased

public void controllerUpReleased(int controller)
Description copied from interface: ControllerListener
Notification that the up control has been released on the controller.

Specified by:
controllerUpReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerUpReleased(int)

mouseReleased

public void mouseReleased(int button,
                          int x,
                          int y)
Description copied from interface: MouseListener
Notification that a mouse button was released

Specified by:
mouseReleased in interface MouseListener
Parameters:
button - The index of the button (starting at 0)
x - The x position of the mouse when the button was released
y - The y position of the mouse when the button was released
See Also:
MouseListener.mouseReleased(int, int, int)

update

public abstract void update(GameContainer container,
                            int delta)
                     throws SlickException
Description copied from interface: Game
Update the game logic here. No rendering should take place in this method though it won't do any harm.

Specified by:
update in interface Game
Parameters:
container - The container holing this game
delta - The amount of time thats passed since last update in milliseconds
Throws:
SlickException - Throw to indicate an internal error
See Also:
Game.update(org.newdawn.slick.GameContainer, int)

mouseWheelMoved

public void mouseWheelMoved(int change)
Description copied from interface: MouseListener
Notification that the mouse wheel position was updated

Specified by:
mouseWheelMoved in interface MouseListener
Parameters:
change - The amount of the wheel has moved
See Also:
MouseListener.mouseWheelMoved(int)

isAcceptingInput

public boolean isAcceptingInput()
Description copied from interface: ControlledInputReciever
Check if this input listener is accepting input

Specified by:
isAcceptingInput in interface ControlledInputReciever
Returns:
True if the input listener should recieve events
See Also:
ControlledInputReciever.isAcceptingInput()

inputEnded

public void inputEnded()
Description copied from interface: ControlledInputReciever
Notification that all input events have been sent for this frame

Specified by:
inputEnded in interface ControlledInputReciever
See Also:
ControlledInputReciever.inputEnded()

inputStarted

public void inputStarted()
Description copied from interface: ControlledInputReciever
Notification that input is about to be processed

Specified by:
inputStarted in interface ControlledInputReciever
See Also:
ControlledInputReciever.inputStarted()


Copyright © 2006 New Dawn Software. All Rights Reserved.