| Asdraw Library | ||||||||||||||||
The architecture of the asdraw package The asdraw package extends the functionality of the adraw package
by providing an interface to the tunes package and allowing the programmer
to turn the programs designed for the isdraw library into applets. There is no need to change
anything in the original program other than to import asdraw package instead of isdraw
package and replace the call to WorldApplet class This class informs the applet about the specifics of your world and its parameters. The programmer must implement
the method Additionally, the programmer can override the method
Here is a sample of our TunesDemoApplet class:
public class TunesDemoApplet extends WorldApplet{
/**
* Produce a new TunesWorld
*/
public World getNewWorld(){
return new TunesWorld();
}
/**
* Set the size of this world
*/
public void setWorldSize(){
this.WIDTH = 600;
this.HEIGHT = 400;
}
/**
* Set the shortest and the longest interval between ticks
* for this game in miliseconds
*/
public void setTickInterval(){
this.MIN_TICK = 0.1;
this.MAX_TICK = 0.4;
}
}
This is sufficient to launch the applet from the command line or as a Java Applet application. The following html code can be used to upload the applet on a web page. Detailed instructions for creating applets is given in the web pages for the adraw library. Sample complete html file:
<html>
<head>
<title>
Web page title: My applet
</title>
</head>
<body>
<h2> My Applet Header</h2>
<p>This is how you play my game.
Please, use the slider to set the clock speed
before starting the game.</p>
<applet
code="MyWorldApplet.class"
archive="myworld.jar,
./asdraw/asdraw.jar,
./tunes/tunes.jar,
./geometry/geometry.jar,
./colors/colors.jar"
width="400"
height="400">
</applet>
<hr></hr>
... additional webpage contents ...
</body>
</html>
Directory structure The directory structure for this applet looks as follows:
MyAppletFolder ... the main applet folder
MyApplet.html ... the html file defined above
myApplet.jar ... a jar file that contains
MyWorldApplet.java,
MyWorld.java,
and all other files my world uses
asdraw ... a subdirectory
asdraw.jar ... the Applet world library
tunes ... a subdirectory
tunes.jar ... the Applet world library
geometry ... a subdirectory
geometry.jar ... the geometry library
colors ... a subdirectory
colors.jar ... the colors library
| |||||||||||||||||
| last updated on Wed Oct 27 17:27:07 EDT 2010 | generated with DrRacket |