hidden
Class SnakeGame

java.lang.Object
  extended by world.World
      extended by hidden.SnakeGame

public class SnakeGame
extends World

Snake Game demo


Field Summary
 
Fields inherited from class world.World
DEFAULT_TICK_RATE, KEY_ARROW_DOWN, KEY_ARROW_LEFT, KEY_ARROW_RIGHT, KEY_ARROW_UP, MOUSE_DOWN, MOUSE_DRAG, MOUSE_ENTER, MOUSE_LEAVE, MOUSE_MOVE, MOUSE_UP
 
Method Summary
 Scene lastScene()
          Returns the Scene that should be displayed when the interaction/animation completes (World.stopWhen() returns true).
static void main(java.lang.String[] s)
           
 Scene onDraw()
          Return a visualization of this World as a Scene.
 SnakeGame onKey(java.lang.String ke)
          Produce a (possibly) new World when a key is pressed.
 SnakeGame onTick()
          Produce a (possibly) new World based on the Tick of the clock.
 boolean stopWhen()
          Determine if the World/interaction/animation should be stopped.
 double tickRate()
          Return the tick rate for this World in seconds.
 
Methods inherited from class world.World
bigBang, display, onMouse, onRelease
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] s)

onDraw

public Scene onDraw()
Description copied from class: World
Return a visualization of this World as a Scene. See EmptyScene, Scene.placeImage(Image, int, int), and Scene.addLine(int, int, int, int, String) for documentation on constructing Scenes

Specified by:
onDraw in class World

tickRate

public double tickRate()
Description copied from class: World
Return the tick rate for this World in seconds. For example, 0.5 means two ticks per second. The rate is only accessed when bigBang() is initially called and the window is created.

Overrides:
tickRate in class World

onTick

public SnakeGame onTick()
Description copied from class: World
Produce a (possibly) new World based on the Tick of the clock. This method is called to get the next world on each clock tick.

Overrides:
onTick in class World

onKey

public SnakeGame onKey(java.lang.String ke)
Description copied from class: World
Produce a (possibly) new World when a key is pressed. The given event is a String that describes what key was pressed.

Special Keys

"up" : The user presses the up-arrow key
"down" : The user presses the down-arrow key
"left" : The user presses the left-arrow key
"right" : The user presses the right-arrow key
Other keys generate a single character String that represents the key pressed. For example, Pressing the B key on the keyboard generates "b" as an event. If the shift key is held while pressing B then "B" is generated.

Overrides:
onKey in class World

stopWhen

public boolean stopWhen()
Description copied from class: World
Determine if the World/interaction/animation should be stopped. Returning a value of true discontinues all events (mouse, key, ticks) and causes World.lastScene() to be used to draw the final Scene.

Overrides:
stopWhen in class World

lastScene

public Scene lastScene()
Description copied from class: World
Returns the Scene that should be displayed when the interaction/animation completes (World.stopWhen() returns true).

Overrides:
lastScene in class World