de.unifreiburg.twodeedoo.world.demo
Class DemoWorld

java.lang.Object
  extended by de.unifreiburg.twodeedoo.world.demo.DemoWorld
All Implemented Interfaces:
IWorld

public class DemoWorld
extends java.lang.Object
implements IWorld

Demonstration world for the world package.

The user controls a red ball in a blue sky above a green ground. Gravity pulls the ball downward. As long as the user presses UP, An upward wind blows the ball upward. Pressing ESC quits the game.

The world demands a 640x480 simulation window and a simulation with a timeslice of 20ms.

Author:
anton

Constructor Summary
DemoWorld()
           
 
Method Summary
 int getCycleTimeMs()
          Desired cycle time of the simulation, i.e.
 int getHeight()
          Desired height in pixels of the inside of the simulation window (call during setup).
 java.lang.String getTitle()
          Title of the game.
 int getWidth()
          Desired width in pixels of the inside of the simulation window (call during setup).
 void onKeyPressed(int keyCode, ISimulationController controller)
          A key has been pressed.
 void onKeyReleased(int keyCode, ISimulationController controller)
          A key has been released
 void onTick(ISimulationController controller)
          Time has passed.
 void paint(ICanvas canvas)
          Paint the current state of the world onto the canvas.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DemoWorld

public DemoWorld()
Method Detail

getWidth

public int getWidth()
Description copied from interface: IWorld
Desired width in pixels of the inside of the simulation window (call during setup).

Specified by:
getWidth in interface IWorld
Returns:
width in pixels

getHeight

public int getHeight()
Description copied from interface: IWorld
Desired height in pixels of the inside of the simulation window (call during setup).

Specified by:
getHeight in interface IWorld
Returns:
height in pixels

getCycleTimeMs

public int getCycleTimeMs()
Description copied from interface: IWorld
Desired cycle time of the simulation, i.e. the time between two calls to IWorld.onTick(ISimulationController). The simulator should not call IWorld.onTick(ISimulationController) more frequently than that.

To be called during setup.

Specified by:
getCycleTimeMs in interface IWorld
Returns:
milliseconds.

getTitle

public java.lang.String getTitle()
Description copied from interface: IWorld
Title of the game. To be called once at setup.

Specified by:
getTitle in interface IWorld
Returns:
a title.

onTick

public void onTick(ISimulationController controller)
Description copied from interface: IWorld
Time has passed. Simulate something.

Specified by:
onTick in interface IWorld
Parameters:
controller - to stop the simulation

onKeyPressed

public void onKeyPressed(int keyCode,
                         ISimulationController controller)
Description copied from interface: IWorld
A key has been pressed.

Specified by:
onKeyPressed in interface IWorld
Parameters:
keyCode - key code from KeyEvent, e.g. KeyEvent.VK_LEFT.
controller - to stop the simulation

onKeyReleased

public void onKeyReleased(int keyCode,
                          ISimulationController controller)
Description copied from interface: IWorld
A key has been released

Specified by:
onKeyReleased in interface IWorld
Parameters:
keyCode - key code from KeyEvent, e.g. KeyEvent.VK_LEFT.
controller - to stop the simulation

paint

public void paint(ICanvas canvas)
Description copied from interface: IWorld
Paint the current state of the world onto the canvas.

Specified by:
paint in interface IWorld
Parameters:
canvas - a canvas with simple drawing methods.