You'll be able to program in three dimensions once you've
created a 3D Squeak System Browser!
Squeak Smalltalk includes a dedicated
authoring environment called Alice which you can use
to build a 3D landscape or ‘Wonderland’.
Alice is also available as an independent authoring tool
(more information from www.alice.org). Version 3.7 of
Squeak (but not version 3.8) displays a window called ‘Worlds
Of Squeak’ when
it is first run. If you expand this window then click
the window labelled ‘3D’ you will open
up an Alice programming tutorial which explains how
to make a drumming bunny move around inside a 3D world.
If you are new to Smalltalk and Squeak, you may want
to follow our two part Squeak
tutorial before going any
further. There are more Squeak tutorials on the Why
Smalltalk? site: http://www.whysmalltalk.com/tutorials/squeak.htm
Now, without more ado, let's start programming in 3D.
Every step is shown in this Flash
Tutorial and is documented
below.
- Left-click the Squeak workplace.
- Select Open from the popup menu.
- Select Workspace from the next menu.
- In the blank workspace enter this text:
Wonderland
new
- Highlight this text (clicking once just beyond
the text will do this).
- Right-click and select ‘Do It’ from
the popup menu.
- A new type of workspace appears with a small ‘landscape’ view
to the left and a larger Script pane at the right.
- In the Script pane enter this text:
w makePlaneNamed: ‘testplane’
- Highlight this text.
- Right-click and select ‘Do It’ from
the popup menu.
- Notice that a vertical plane has appeared in the
small ‘landscape’ picture.
- Try clicking the plane in the landscape view. You
can drag it back and forth. If you press the Shift
key and click you can move it vertically. If you press
Ctrl and click you can rotate it.
- Press the Alt key and left-click in the ‘sky’ area
of the landscape. A set of tools will appear around
the edge of the picture.
- Click the red ‘menu’ tool (2nd from
left at the top).
- From the menu that pops up, click ‘accept
drops’.
- Now, in the landscape view, Alt+left-click the white
plane to pop up icons around the plane.
- Left-click the red menu icon.
- In the menu, click ‘enable active texture’.
- Alt+left-click the plane again.
- Left-click the red menu icon.
- In the menu, click ‘auto adjust to texture’.
- Left-click an area of the background in the main
Squeak window (i.e. the gradient purple-blue colour).
- From the popup menu, select Help.
- From the new menu, select Preferences.
- Click once to fix the Preferences panel in place.
- Delete the text in the Search box and enter the
following:
systemW
- Click Search
- Two results will be displayed with empty checkboxes.
- Click the checkbox by systemWindowEmbedOK
- Click the ‘close’ button in the caption
bar to close the Preferences panel.
Note: If the caption bar is not visible (in the
Flash Tutorial you will see that it has scrolled
beyond the top of the Squeak workspace) you can display
the icons by Alt+left-clicking the Preferences window.
Click the black ‘pickup’ icon at the
middle-top and drag the window to a new position.
Click the ‘close’ button (that’s
the one at the left of the window’s title bar,
not the icon just above it) to close it. |
- Now close the Workspace window (the one containing
the text ‘Wonderland
new’). Click ‘Yes’ when
prompted.
- Make sure the mini landscape view is visible.
If necessary, Alt+left-click its ‘sky’ area
and use the black ‘pickup’ icon to drag
it to a clear area of the desktop.
- Left-click the main Squeak desktop.
- From the menu select Open. Then select Browser.
- A system Browser pops up.
- In the top-left pane select Kernel-Methods.
- In the next pane, select InstructionPrinter.
- In the 4th pane (top-right), select the method jump:if:
- Alt+left-click the system browser to pop up icons
around its edges.
- Click the black ‘pickup’ icon (top
centre) and drag this directly onto the white plane
in the small ‘landscape’ view.
Release the mouse button.
- You will see that a mini browser had now been
placed onto the plane.
- Alt+left-click the mini-browser. Icons will appear
around its edges.
- Left-click the red menu icon.
- From the menu, select ‘disable active texture’
- Alt+left-click
the sky area of the landscape.
- Hold-down the Shift key, click the yellow Change
Size icon (bottom right) and drag this to increase
the size of the landscape window.
- If necessary, click and drag the browser shown in
the landscape or rotate it (Ctrl+Left-click and drag)
if you happen to be seeing its reverse face at the
moment.
- Alt+left-click the browser in the landscape.
- Click the red menu icon.
- From the menu select ‘enable active texture’.
- This causes the browser in the window to change
from being a mere picture to a real browser in which
the panes and text are active.
- To prove this place your cursor just beyond the
end of the code in the bottom pane and left-click to
highlight it.
- Press the Delete key to delete the code.
- In its place, enter the following:
Hello from
the 3D browser - we can now write Smalltalk code in
3D.
- Of course this text is not meaningful code so if
you select another method in your 3D browser you
will be asked if you wish to cancel your changes.
Select ‘Yes’ to
do so.
If you are new to Squeak, you probably won’t
want to keep your work at this stage (it would be all
too easy to create some unexpected side effects by writing
code in your 3D browser). So when you quit Squeak, don’t
save your changes. Alternatively, if you want to carry
on playing later on, left-click the desktop background
and select Save As. Enter a name such as 3DBrowser.image and click Accept. Then quit Squeak without saving. Squeak
will prompt to load a specific image file when you next
run it. Your default image won’t have the 3D browser
while the one you just saved will have it.
Torsten Bergmann writes a programming
blog, The Hitchhiker's Guide To.... at http://astares.blogspot.com/
August 2005 |