de.unifreiburg.twodeedoo.world
Class WorldAdapter

java.lang.Object
  extended by de.unifreiburg.twodeedoo.world.WorldAdapter
All Implemented Interfaces:
IActivity, IKeyHandler, IPainter, ISchedulable

public class WorldAdapter
extends java.lang.Object
implements IActivity, IPainter

Adapter from the world package's IWorld to twodeedoo's Activity+Painter.

This wraps a IWorld and translates twodeedoo method calls to twodeedoo-world method calls.

Author:
anton

Field Summary
 
Fields inherited from interface de.unifreiburg.twodeedoo.view.ISchedulable
NULL_OBJECT
 
Fields inherited from interface de.unifreiburg.twodeedoo.view.IKeyHandler
NULL_OBJECT
 
Fields inherited from interface de.unifreiburg.twodeedoo.view.IPainter
NULL_OBJECT
 
Constructor Summary
WorldAdapter(IWorld world)
          Create an adapter
 
Method Summary
 void keyPressed(int keyCode, IGameController controller)
          a key has been pressed.
 void keyReleased(int keyCode, IGameController controller)
          a key has been released.
 int minimalTimeSlice()
          Do not call me more often than with this many ms between two runs.
 void paint(java.awt.Graphics g)
          Paint something on my coordinates on the given graphics context.
 boolean run(int elapsedTimeMillis, IGameController gameController)
          Perform some work.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorldAdapter

public WorldAdapter(IWorld world)
Create an adapter

Parameters:
world - wrappee
Method Detail

run

public boolean run(int elapsedTimeMillis,
                   IGameController gameController)
Description copied from interface: ISchedulable
Perform some work.

Specified by:
run in interface ISchedulable
Parameters:
elapsedTimeMillis - time in ms since last call.
gameController - to stop the game or switch activities
Returns:
true: this should be run again, false: finished, don't call again.

keyPressed

public void keyPressed(int keyCode,
                       IGameController controller)
Description copied from interface: IKeyHandler
a key has been pressed.

Specified by:
keyPressed in interface IKeyHandler
Parameters:
keyCode - a code from KeyEvent, e.g. KeyEvent.VK_LEFT
controller - TODO

keyReleased

public void keyReleased(int keyCode,
                        IGameController controller)
Description copied from interface: IKeyHandler
a key has been released.

Specified by:
keyReleased in interface IKeyHandler
Parameters:
keyCode - a code from KeyEvent, e.g. KeyEvent.VK_LEFT
controller - TODO

paint

public void paint(java.awt.Graphics g)
Description copied from interface: IPainter
Paint something on my coordinates on the given graphics context.

Specified by:
paint in interface IPainter
Parameters:
g - some graphics context.

minimalTimeSlice

public int minimalTimeSlice()
Description copied from interface: IActivity
Do not call me more often than with this many ms between two runs.

Specified by:
minimalTimeSlice in interface IActivity
Returns:
millisecond delay