| Functional Drawing Library: draw.jar | |||||||||||||||||
The The Javadocs for the draw library.
/**
* World for programming interactive games - with graphics, key events,
* and a timer.
*/
abstract public class World{
/** the canvas that displays the current world */
protected Canvas theCanvas;
/** The default constructor. */
public World(){ }
/** Start the world by creating a canvas of the given size
* and starting the timer at the given speed. */
public boolean bigBang(int w, int h, double speed);
/** End the world clock and key events:
* display the given message. */
public boolean endOfTime(String s);
/** End the world interactions: display the given message
* produce the final version of the World. */
public World endOfWorld(String s);
/** Produces a new World as it should look after a clock tick. */
abstract public World onTick();
/** Produces a new World as it should look
* in response to the given key input. */
abstract public World onKeyEvent(String s);
/** Draw this world in 'theCanvas'. */
abstract public boolean draw();
}
To run the game invoke its
public static void main(String[] argv){
// user defines the starting world
World w = new MyWorld(...);
// user supplies the world size and clock speed
boolean go = w.bigBang(...width..., ...height..., ...speed...);
}
Here is a complete code for a running program called BlobWorldFun.java | ||||||||||||||||||
| last updated on Fri Apr 1 14:26:43 EDT 2011 | generated with DrRacket |