- Due to a lifetime of chasing brace-matches through C code, I cannot seem to take to the Java habit of failing to line up braces vertically;
- Further, because I've been programming in many languages since 1964 (yes, 1964), I have a habit of calling methods "functions".
Now, let's start to work through the Applet. First, the introductory bit, which specifies the standard packages we will use, and defines the Applet:
// Bridge Applet (c)Amazon Systems
import java.awt.*;
import java.applet.*;
import java.net.URL;
import java.util.Vector;
import java.awt.event.*;
import java.net.MalformedURLException;
public class Bridge extends Applet
implements MouseMotionListener, MouseListener
{
Next, a pile of variables are defined. Many of these are class variables.
Ticktimer is a Thread class handling the timing of the main loop.
BridgeData is where all the Scene data are defined.
DisplayManager and DirtRectSet handle the Graphics.
The variables for communication with Javascript (data and flags) are also defined here.
// Timers
private boolean timerRunning;
public Ticktimer timer = null;
private long timewas, timenow;
public long ticks;
// 1000/n where ticks are 1/n seconds
private static int FRACTION = 1000/12;
// Scene control
public BridgeData bridgedata;
public String currscene;
public String popscene;
public Scene thisscene;
public Image backcloth;
public DirtyRectSet dirtyrectset;
public DisplayManager displaymanager;
public int mousex, mousey;
private Sprite isHolding;
public String codebasestr;
// Communication Area
private boolean invFlag;
private boolean songFlag;
private String songName;
private boolean saveFlag;
private String saveString;
private boolean restoreFlag;
private String restoreData;
private int currCursor;