Introducing Squeak Alice


"Moving the bunny"

The PlayWithMe window showing the Squeak Alice capabilities includes a Squeak Wonderland with a bunny as actor. Wonderlands are 3D environments in Squeak-Alice. You can use the script editor to do cool thing with the 3D bunny:

sqk00056.gif (2921 bytes)

Let's start out by moving the bunny. Evaluate bunny move: forward. in
the Alice Editor.The bunny moved forward 1 meter. You can also specify how far to move actors. Click the undo button to move the bunny back.
sqk00057.gif (3171 bytes)
Evaluate bunny move: up distance: 1/2.

Note that by default everything in Squeak-Alice animates over 1 second. You can change this by specifying a duration for animations.
Evaluate bunny move: forward distance: 2 duration: 4. for an example.

sqk00058.gif (2923 bytes)
Ok, now click undo twice to move the bunny back and down. You can also
move actors relative to other actors. The following command moves the bunny
in the camera's forward direction. bunny move: forward asSeenBy: camera.
Click Undo to move him back.
sqk00059.gif (2461 bytes)
See the list of actors in the scene to the left? Notice that the bunny is actually broken up into parts. You can actually type commands to those parts as well. Try the following.
bunny drum setColor: green. (Notice that this animates as well!)

 

sqk00060.gif (2644 bytes)
Evaluate bunny drum resize: 1/5.and bunny head resize: 1.5 to shrink the drum and stretch the head of the bunny. Evaluate bunny head turn: left turns: 1. to turn the head of the bunny.You can also specify the speed at which things should occur instead of their duration. The following turns the bunny's head around at 2 turns per second:
bunny head turn: left turns: 2 speed: 2.
sqk00061.gif (2798 bytes)
Squeak-Alice also provides some higher level behaviors. The following
makes the bunny's head point at the camera: bunny head pointAt: camera.
sqk00062.gif (2809 bytes)
You can also build component animations out of simple animations. To see
this, first we'll create an animation and name it jump jump := bunny move: up.
Now create an animation called fall: fall := bunny move: down.
Now we'll compose them. There are two ways to compose animations - in order (so they happen one after another) or together (so they happen at the same time).
hop := w doInOrder: { jump. fall }. Now we can do different things with hop.
hop start. Make hop run once hop loop: 2. Make hop run twice
hop loop. Make hop loop forever When you get tired of hop, you can stop it from looping.
hop stopLooping.
sqk00063.gif (2593 bytes) sqk00062.gif (2809 bytes)
So far our world isn't very interactive. Although you can click on the bunny with the left mouse button (red button) and drag him around (try it -you can always click Undo to move him back), we haven't defined any new interactive behaviors. Let's make the bunny hop when we click on him with the right mouse button (yellow button)
bunny respondWith: [:event | hop start ] to: rightMouseClick
Squeak-Alice also allows you to establish constraints. Here's a simple constraint that turns the bunny at a constant speed bunny turn: left speed: 0.5.
sqk00064.gif (2475 bytes)
Now let's tell the bunny to always look at the camera. We can do this using
eachFrame for the duration bunny head pointAt: camera duration: eachFrame.
sqk00065.gif (2776 bytes)
You can give commands to the camera just like any other object camera move: up.
Click undo to move the camera back down. You can also use the mouse to
move the camera around the scene, but first you need to show that camera's
controls cameraWindow showCameraControls.
Click on the controls and drag the mouse. If you don't hold any keys down, the camera moves forward/back and turns left/right. If you hold shift down, the camera moves up/down and left/right. If you hold control down the camera turns left/right. And if you hold control and shift down the camera turns up/down.
When you're done mousing around the scene, click Undo until the camera is back where it started.
sqk00066.gif (2854 bytes)
            sqk00067.gif (1496 bytes)
Let's finish up with one last thing. Squeak-Alice allows you to blend the 2D and 3D aspects of Squeak. To see this, do the following lines one at a time:
ground hide.
camera turnBackgroundOff.
cameraWindow hideCameraControls.

Check this out:
cameraWindow sendToFront.
w doInOrder: { cameraWindow move: right distance: 400. cameraWindow move: left distance: 400 }.

sqk00068.gif (1938 bytes)
If you're getting tired of the bunny, try the following:
bunny destroy.
You can always just click Undo to bring him back. For those of you who actually read this far, here's a last fun example.First we'll stop the bunny's existing constraints.
bunny stop.
Now we'll tell his head to follow the mouse pointer. We need the bunny to determine where the mouse pointer is each frame, so we'll make his head point at the mouse pointer immediately each frame. Select all three lines...
bunny head doEachFrame: [ bunny head pointAt: (camera
transformScreenPointToScenePoint: (Sensor mousePoint) using: bunny)
duration: rightNow ].

Now our bunny watches our mouse pointer as it moves around.
You can also lots of other things in Squeak-Alice. For example:
- bring in multiple objects  (w makeActorFrom: 'actorFile.mdl')
- create multiple cameras  (w makeCamera)
- rearrange the object hierarchy
- place actors relative to each other
- and much more!
sqk00069.gif (1768 bytes)

sqk00070.gif (3207 bytes)