|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.piratis.j2me.core.game.Engine
Default Engine class. All game engines based on J2MEGL must
override this one because of the tight binding between this class
and the Canvas.
Once started, the engine enters and endlessly loop which won't
stop until nextRunLoop return false (good candidate to be
overwritten, isn't it?).
A game might contain more than one engine, depending on the status
of the game and if it has playable sections/levels which
differ among them in great measure, etc.. It is reponsibility of the
programmer to stop one and start the other.
Field Summary | |
protected Canvas |
canvas
Engine and canvas are tightly bound |
static int |
DEFAULT_FPS
Default FPS setting |
static int |
IS_DOWN
|
static int |
IS_FIRE
|
static int |
IS_GAME_A
|
static int |
IS_GAME_B
|
static int |
IS_GAME_C
|
static int |
IS_GAME_D
|
static int |
IS_LEFT
|
static int |
IS_RIGHT
|
static int |
IS_UP
Key status constants |
protected LayerManager |
layers
Where to store all the layers/sprites/tiles |
Constructor Summary | |
Engine(Canvas canvas)
Creates a new Engine. |
|
Engine(Canvas canvas,
int fps)
Creates a new Engine. |
Method Summary | |
int |
getKeyStates()
Gets the states of the game keys. |
protected void |
initialize(Canvas canvas,
int newFps)
Initialize method.. |
protected abstract void |
input()
Engine's key management method. |
protected void |
keyPressed(int keyCode)
Canvas calls this method upon a key is pressed. |
protected void |
keyReleased(int keyCode)
Canvas call this method upon a key is released. |
protected boolean |
nextRunLoop()
Checks if the run loop needs to continue running (based on engine status) |
protected void |
paint()
Default paint method. |
void |
run()
|
protected void |
setInitialStatus()
Sets the status variables to an initial status |
protected void |
setRunningStatus()
Engine Status to a running status |
void |
stop()
Performs a stop |
protected void |
waitSomething(long loopStartTime,
long interval)
Wait method to synchronize work & repainting. |
protected abstract void |
work()
Real engine method that should be implemented in subclasses |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int IS_UP
public static final int IS_DOWN
public static final int IS_LEFT
public static final int IS_RIGHT
public static final int IS_FIRE
public static final int IS_GAME_A
public static final int IS_GAME_B
public static final int IS_GAME_C
public static final int IS_GAME_D
public static int DEFAULT_FPS
protected Canvas canvas
protected LayerManager layers
Constructor Detail |
public Engine(Canvas canvas)
canvas
- the canvas of this enginepublic Engine(Canvas canvas, int fps)
canvas
- the canvas of this enginefps
- desired frames per second refresh rateMethod Detail |
public void run()
run
in interface java.lang.Runnable
Runnable.run()
public void stop()
protected void waitSomething(long loopStartTime, long interval)
loopStartTime
- the start time of the engine loopinterval
- adjusted to the engine/canvas FPSprotected abstract void work()
protected abstract void input()
protected void paint()
protected void initialize(Canvas canvas, int newFps)
protected void setInitialStatus()
protected boolean nextRunLoop()
protected void setRunningStatus()
protected void keyPressed(int keyCode)
keyCode
- which key has been pressedprotected void keyReleased(int keyCode)
keyCode
- which key has been releasedpublic int getKeyStates()
|
Copyright(c) 2003-2004 Jordi Martin | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |