Figure 3-1 shows the
WormChase game as an applet and as an application. It has the same GUI interface as the windowed version: a large canvas with two text fields at the bottom used to report the number of boxes added to the scene, and the time.
Class diagrams showing the public methods are given in Figure 3-10. A comparison with the diagrams for the windowed version in Figure 3-2 show the classes stay mainly the same. The only substantial change is to replace
JApplet at the top level.
Figure 3-10. Class diagrams for the WormChase applet
The code for this version of
WormChase is in the directory Worm/WormApplet/.
Worm class is unchanged from the windowed version. The
Obstacles class now calls
WormChaseApplet rather than
WormPanel reports its termination statistics in a different way, but the animation loop and statistics gathering are unchanged.
WormChaseApplet handles pausing, resumption, and termination by tying them to events in the applet life cycle. By comparison,
The applet's web page passes the requested frame rate to it as a parameter:
<applet code="WormChaseApplet.class" width="500" height="415"> <param name="fps" value="80"> </applet>
Figure 3-11 shows the class diagram for
WormChaseApplet with all its variables and methods.
Figure 3-11. WormChaseApplet ...