|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--world.World
The World class contains all the world management code.
It handles the events that occur when buttons are clicked or keys are pressed.
It governs the speed of the simulation and calls necessary methods of objects in the world.
Field Summary | |
private java.util.ArrayList |
background
|
private java.util.ArrayList |
characters
|
private WinEnv |
environment
|
static int |
FPS
|
static int |
KEY_A
|
static int |
KEY_D
|
static int |
KEY_DOWN
|
static int |
KEY_LEFT
|
static int |
KEY_RIGHT
|
static int |
KEY_S
|
static int |
KEY_SPACE
|
static int |
KEY_UP
|
static int |
KEY_W
|
private boolean[] |
keysPressed
|
static int |
NUM_KEYS
|
private javax.swing.Timer |
timer
|
Constructor Summary | |
World()
Creates our World, empty. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Called by timer when it's running. |
void |
addVehicle(AbstractVehicle av)
Registers a moving object with the controller Duplicates are allowed. |
void |
addWorldObject(Background o)
Registers a non-moving world object with the controller. |
void |
draw(java.awt.Graphics2D g)
Tells the graphics system what to draw on screen by going through all the objects in the world and telling them to draw themselves. |
boolean |
getKeyPressed(int key)
Tells whether a given button on the keyboard is pressed. |
java.awt.Dimension |
getSize()
Return the size of this world |
java.util.ArrayList |
getVehicles()
Return the list of moving objects currently registered with the controller |
void |
keyPressed(java.awt.event.KeyEvent e)
Handle the key pressed event |
void |
keyReleased(java.awt.event.KeyEvent e)
Handle the key released event |
void |
keyTyped(java.awt.event.KeyEvent e)
Handle the key typed event |
void |
start()
Handles start button |
void |
stop()
Handles stop button |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private WinEnv environment
private javax.swing.Timer timer
public static final int FPS
private java.util.ArrayList characters
private java.util.ArrayList background
private boolean[] keysPressed
public static final int KEY_LEFT
public static final int KEY_UP
public static final int KEY_RIGHT
public static final int KEY_DOWN
public static final int KEY_A
public static final int KEY_S
public static final int KEY_D
public static final int KEY_W
public static final int KEY_SPACE
public static final int NUM_KEYS
Constructor Detail |
public World()
Method Detail |
public void stop()
public void start()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- the timer action that we are handlingpublic void draw(java.awt.Graphics2D g)
g
- the graphics system we can use to draw things onpublic void addWorldObject(Background o)
o
- the object to be addedpublic void addVehicle(AbstractVehicle av)
av
- the object to be addedpublic java.util.ArrayList getVehicles()
public java.awt.Dimension getSize()
public boolean getKeyPressed(int key)
key
- the keycode of the button
true
if the button is currently down and
false
if the buttone is uppublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |