|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread CarGameController
public class CarGameController
This class represents a thread which runs the car game.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
static int |
KEY_DOWN
Position of the DOWN key press indicator in the array of keystrokes |
static int |
KEY_LEFT
Position of the LEFT key press indicator in the array of keystrokes |
static int |
KEY_RIGHT
Position of the RIGHT key press indicator in the array of keystrokes |
static int |
KEY_UP
Position of the UP key press indicator in the array of keystrokes |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
CarGameController(CarGame game)
Creates a controller for the specified CarGame object. |
Method Summary | |
---|---|
CarGame |
getGame()
Returns a reference to the CarGame object this instance is controlling. |
boolean |
getPaused()
Indicates whether the game is paused |
boolean |
getQuit()
Indicates whether the player wants to quit. |
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
|
void |
keyTyped(java.awt.event.KeyEvent e)
|
void |
run()
Runs the game until the player chooses to quit. |
void |
setPaused(boolean paused)
Sets whether the game should be paused |
void |
setViewer(CarGameGUI v)
Sets the reference to the CarGameGUI object that will display the game's state. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int KEY_UP
public static int KEY_RIGHT
public static int KEY_DOWN
public static int KEY_LEFT
Constructor Detail |
---|
public CarGameController(CarGame game)
game
- The game to control.Method Detail |
---|
public void setViewer(CarGameGUI v)
v
- The viewer that will display the game's state.public boolean getPaused()
public void setPaused(boolean paused)
paused
- true if the game should be paused, false
if the game should be running.public CarGame getGame()
public boolean getQuit()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |