de.unifreiburg.twodeedoo.world
Interface IWorld

All Known Implementing Classes:
DemoWorld

public interface IWorld

A world contains state which updates over time and on keypress, and it displays its state on a canvas.

Simpler than full twodeedoo.

Author:
anton

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.
 

Method Detail

getTitle

java.lang.String getTitle()
Title of the game. To be called once at setup.

Returns:
a title.

getWidth

int getWidth()
Desired width in pixels of the inside of the simulation window (call during setup).

Returns:
width in pixels

getHeight

int getHeight()
Desired height in pixels of the inside of the simulation window (call during setup).

Returns:
height in pixels

getCycleTimeMs

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

To be called during setup.

Returns:
milliseconds.

onTick

void onTick(ISimulationController controller)
Time has passed. Simulate something.

Parameters:
controller - to stop the simulation

onKeyPressed

void onKeyPressed(int keyCode,
                  ISimulationController controller)
A key has been pressed.

Parameters:
keyCode - key code from KeyEvent, e.g. KeyEvent.VK_LEFT.
controller - to stop the simulation

onKeyReleased

void onKeyReleased(int keyCode,
                   ISimulationController controller)
A key has been released

Parameters:
keyCode - key code from KeyEvent, e.g. KeyEvent.VK_LEFT.
controller - to stop the simulation

paint

void paint(ICanvas canvas)
Paint the current state of the world onto the canvas.

Parameters:
canvas - a canvas with simple drawing methods.