About three years ago, when the financial picture at Apple Computer was at its bleakest, a series of austerity measures resulted in the elimination of many cool employees and the long-term projects on which they were engaged. Such advanced but still nascent technologies as the Dylan programming language, OpenDoc, and ScriptX were aborted before seeing the full light of day. Among the victims was Cocoa, a wonderful program - aimed particularly at children - for constructing simple animated games. Cocoa was cool both for what it did and for how it was written: originally prototyped as KidSim in Apple's own Sk8 authoring environment (another sad loss), Cocoa was rewritten in Prograph, a visual programming language that matched Cocoa's own visual approach.
Apple proudly featured Cocoa in a Macworld Expo keynote speech, and several enterprising youngsters even went into business with Cocoa-based Web sites. Then it faded from sight. But Cocoa wasn't dead, or even dormant: it was metamorphosing, at the hands of its inventors - Allen Cypher, longtime advocate of programming by demonstration, and David Smith, inventor of (among other things) icons and dialog boxes - within a new private company headed by Apple's former Chief Scientist, Larry Tesler. Now, like a butterfly, Cocoa has emerged as the cross-platform, Java-based Stagecast Creator.
Setting the Stage -- Imagine you have a rectangular grid of invisible squares; they can be any size and number, but let's say a square is 36 by 36 pixels, and let's say the total grid is ten squares high and fifteen squares wide. The grid holds a background picture, which you import from a GIF or JPEG image. This is the stage on which your animation takes place.
A character in your animation is a rectangle of pixels, which you can edit in a paint window. This rectangle's dimensions are multiples of the stage's unit squares, with a typical character being exactly one unit square; so, in our example, a character could be 36 by 36 pixels. You paint a character, and place it in a square of the stage's grid, where it is automatically drawn with masking in front of the background (so that even within the character's square, the background appears around the character's outline).
Now we're going to construct our animation, like the successive frames of a cartoon. At regular intervals, a clock will tick, and the next frame will be generated by asking each character on the stage whether it wants to change anything about how it is drawn. For example, a character might wish to be redrawn in the square to the right of its current square; if this happens over the course of several frames, the character will appear to move in a straight line to the right. Or, since each character can own many images (or "appearances"), a character might want to change its image. So, for example, if a character has an appearance where it is facing right with its right leg forward, and another where it is facing right with its left leg forward, then by alternating those appearances while also being redrawn in successive rightward squares, the character will appear to walk to the right.
Animation Rules -- So far, I could be describing any sprite-based animation system. What characterizes Stagecast's approach, though, is the way you tell a character what to do when the animation runs: you show it, by physical demonstration, the rule you want it to obey. You choose the "rule tool," click a character on the stage, and a special border appears around this character; you stretch the border to show the character the relevant area, and move the character within that area to show it what to do. For example, to tell a character to move to its right, you stretch its rule border, so that the border embraces the character and the empty square to its right, and slide the character into the square on the right. When the animation runs, the character makes that movement of its own accord.
What makes the animation tell an interesting story is that every rule has an implicit conditional component. Even in the simple example of moving the character one square to the right, the character remembers its own appearance, and the fact that the square to the right was empty, and performs the action only if both conditions are met. If you want character A to move rightwards into a square occupied by character B, you need a different rule: you must place the characters next to each other and make the rule border embrace them both, so that character A sees character B as involved in the rule. To build your animation, then, you give each character several rules, corresponding to the situations in which the character finds itself. The character tests each rule's conditions in turn and obeys the first rule whose conditions match its situation. The art of making an animation is the art of giving each character the right rules, in the right order, so that all the characters behave correctly.
There is much more to making rules, and there are many more effects you can achieve. Characters can make other characters appear and disappear. They can make sounds. They can substitute a different background picture. They can react to key presses, or to mouse clicks, for a degree of user interactivity. Characters can have variables; they can change the value of a variable, or test a variable's value as part of a rule's conditions.
Clearly, then, what you're doing as you teach a character its rules and arrange them is programming. You're programming in a visual language, within the circumscribed environment of a little cartoon world; but you are programming. And since each character has its own rules, while multiple copies of a character share the same rules, you're doing object-oriented programming. Thus, Stagecast is a way for children of all ages to absorb the principles of programming while enjoying the instant creative satisfaction of bringing a cartoon world to life.
Exploring the Character -- It really does work. I've shown StageCast to some children, and they've caught the basics right away. They enjoy creating even the simplest character and making it move, and the notion of teaching a character its rules by demonstration presents no difficulties. Stagecast comes superbly documented with a brilliant interactive online tutorial full of wonderfully amusing animations (who can resist Bungee the jungle boy, beset by camera-clicking tourists who descend from a helicopter?), plus a printed manual in large type and simple language, and a construction kit that guides you through building an entire animation from scratch. Between the tutorial examples and the extra clip art that's included, you can easily assemble an original animation without doing any drawing of your own. Thus, it's easy to get started, easy to delve deeper as the mood takes you, and fun the whole time.
Delving deeper means exploring the Stagecast programming language's higher levels. In particular, the basic algorithm which says that a character performs its first rule whose conditions are met on every frame is too limiting, so Stagecast lets you combine rules within "boxes" that obey other algorithms. A box can shuffle its rules before executing (so you won't know the order in which they'll be tested), perform all its rules in succession, or attempt to perform its next rule cyclically on each successive frame. By combining boxes within boxes, you can generate sophisticated algorithms. It's easy to debug a character's behavior, because Stagecast has a test mode where it shows you, with red and green lights and squares, which rule it will obey in the current situation, and why.
Although I can't say enough in praise of how ingeniously Stagecast's programming language is implemented, you're still limited to the constructs that the language supplies, and you must learn to think within them. To give just one example, such an elementary notion as "or" cannot be expressed at all; you must make separate rules covering each case, which is painful to do and even more painful to maintain if the "or" is part of a larger set of "ands." As a result, you must be ingenious yourself, resorting often to tricks and workarounds to achieve the effect you're after. I worry that young users will become either frustrated or imbued with undesirable programming habits. Plus, the physical nature of Stagecast's programming environment has its drawbacks; as rules become more complicated, with boxes or multiple conditions, it becomes harder to manipulate the images on screen to see what you're doing.
Rough Venue -- This physical clumsiness, which often obtrudes itself, stems from Stagecast's one great drawback: it's a Java application. Although this lets Stagecast run identically on Windows and Mac, and over the Internet, you might as well not be using a Mac at all. Everything happens within a single large window - that is, it had better be large; an 800 by 600 monitor is not large enough to use Stagecast with any comfort. Stagecast's menus appear inside this window, which is particularly hard to get used to (and on my machine, accidentally choosing a normal menu from the Mac's menu bar causes a crash). Within this window Stagecast also draws its pseudo- or "child" windows. The whole thing feels like Virtual PC: you're essentially simulating an alien machine within a single window.
The simulation is not particularly fast. Animations run quickly enough, but on my fastest computer, a 250 MHz Power Mac G3, actions such as starting up, quitting, and opening or (worst of all) dragging a window, are so painfully slow that you think the computer has locked up. Kids are more likely to have hand-me-down computers than the fastest G3s, so the performance problems are especially troubling.
Nor is the simulation particularly pleasant. Unfamiliar interface elements such as scroll arrows that point the wrong way and lack scrollbars, tab rectangles that reveal or hide regions of a window, and colored corners that you drag to change a window's size, are clumsy devices, ill-behaved and too tiny to click comfortably. Type is too small as well. There are few keyboard shortcuts; everything must be done by clicking and dragging. I understand why the Java implementation was chosen, but I can't bring myself to like it.
Still, I don't want to leave the impression that Stagecast is other than delightful. This program is both educational and engaging; it's also a testament to its makers' ingenuity and originality. It's the perfect blend of programming and play: how could any child not be attracted to it? Personally, I enjoy making animations, and then I enjoy playing with them or just watching them. And so can you. Even if you don't buy Stagecast Creator, you can use Stagecast Player, a free 2 MB download, to run Stagecast animations, and even view them in your browser (Macintosh users must use Apple's Macintosh Runtime for Java (MRJ) 2.1, which limits the field to Internet Explorer). You can download sample animations; I've even posted one of my own, a little entertainment easily cobbled together from pieces provided with the program, that I call "Beachdog". (Be patient downloading it, it's 350K.)
Stagecast Creator retails for $60 and comes on a hybrid Mac/Windows CD. Installation requires 35 MB, plus 11 MB for MRJ, which is included. StageCast Creator is available for PowerPC-based systems only; a fast machine with Mac OS 8.1 or better is recommended. A trial version is available for download.