public class SpriteDemo extends Applet implements Runnable {
    Playfield playfield;
    AnimatedSprite sprite;
    <font color="Fuchsia">Image output;</font>
    Thread animate;
        // private stuff
        .
        .
        .

    public void init() {
                .
                .
                .
        <font color="Fuchsia">renderPlayfield( );</font>
    }
    
    public void start() {
        animate = new Thread(this);
        animate.start();
    }

    public void stop() {
        animate = null;
    }
    
    public void run() {
        while (true) {
            try {
                animate.sleep(100);
            } catch (InterruptedException e) {
            }
            <font color="Fuchsia">renderPlayfield( );</font>
        }
    }
    
    <font color="Fuchsia">public void renderPlayfield() {
                .
                .
                .
        playfield.Draw();
        output = playfield.toImage();
                .
                .
                .
                    sprite.nextState();
                .
                .
                .
        repaint();
    }
    
    public void paint(Graphics g) {
        g.drawImage(output, 0, 0, this);
    }</font>

    public void update(Graphics g) {
        paint(g);
    }

    public boolean mouseDown(Event e, int x, int y) {
                .
                .
                .
        <font color="Fuchsia">renderPlayfield( );</font>
        return true;
    }
