|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfunworld.World
public abstract class World
World for programming interactive games - with graphics, key events, mouse events and a timer. Designed to implement the same interface as DrScheme/ProfessorJ world teachpack library.
| Field Summary | |
|---|---|
WorldEnd |
lastWorld
the last world - if needed |
Canvas |
theCanvas
the canvas that displays the current world |
| Constructor Summary | |
|---|---|
World()
The default constructor. |
|
| Method Summary | |
|---|---|
boolean |
bigBang(int w,
int h)
Start the world by creating a canvas of the given size, creating and adding the key and mouse adapters, without running the the timer. |
boolean |
bigBang(int w,
int h,
double speed)
Start the world by creating a canvas of the given size, creating and adding the key and mouse adapters, and starting the timer at the given speed. |
World |
endOfWorld(java.lang.String s)
End the world interactions - leave the canvas open, show the image of the last world with the given message |
WorldImage |
lastImage(java.lang.String s)
User defined method to draw the . |
abstract WorldImage |
makeImage()
User defined method to draw the . |
World |
onKeyEvent(java.lang.String s)
User defined method to be invoked by the key adapter on selected key events. |
World |
onMouseClicked(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter when a mouse is clicked. |
World |
onMouseEntered(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter when a mouse is entered. |
World |
onMouseExited(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter when a mouse is exited. |
World |
onMousePressed(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter when a mouse is pressed. |
World |
onMouseReleased(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter when a mouse is released. |
World |
onTick()
User defined method to be invoked by the timer on each tick. |
WorldEnd |
worldEnds()
This method is invoked at each tick. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Canvas theCanvas
public WorldEnd lastWorld
| Constructor Detail |
|---|
public World()
bigBang method.
| Method Detail |
|---|
public boolean bigBang(int w,
int h,
double speed)
w - the width of the Canvash - the height of the Canvasspeed - the speed at which the clock runs
true
public boolean bigBang(int w,
int h)
w - the width of the Canvash - the height of the Canvas
truepublic WorldEnd worldEnds()
This method is invoked at each tick. It checks if the world should end now.
The saved image will be shown when the world ends, otherwise it is ignored.
public World endOfWorld(java.lang.String s)
s - the message to display
this worldpublic World onTick()
User defined method to be invoked by the timer on each tick.
Produces a new .World
Override this method in the game world class
World that needs to have
the canvas and the event handlers initializedpublic World onKeyEvent(java.lang.String s)
User defined method to be invoked by the key adapter
on selected key events.
Produces a new .World
Override this method in the game world class
World that needs to have
the canvas and the event handlers initializedpublic World onMouseClicked(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter
when a mouse is clicked.
Update the .World
Override this method in the game world class
mouse - the location of the mouse when clicked
World after the mouse eventpublic World onMouseEntered(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter
when a mouse is entered.
Update the .World
Override this method in the game world class
mouse - the location of the mouse when entered
World after the mouse eventpublic World onMouseExited(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter
when a mouse is exited.
Update the .World
Override this method in the game world class
mouse - the location of the mouse when exited
World after the mouse eventpublic World onMousePressed(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter
when a mouse is pressed.
Update the .World
Override this method in the game world class
mouse - the location of the mouse when pressed
World after the mouse eventpublic World onMouseReleased(geometry.Posn mouse)
User defined method to be invoked by the mouse adapter
when a mouse is released.
Update the .World
Override this method in the game world class
mouse - the location of the mouse when released
World after the mouse eventpublic abstract WorldImage makeImage()
User defined method to draw the .World
Override this method in the game world class
public WorldImage lastImage(java.lang.String s)
User defined method to draw the .World
Override this method in the game world class
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||