Tile for Mouse and Keyboard ?
Alan Kay
Alan.Kay at disney.com
Mon Dec 11 01:50:00 UTC 2000
Karl --
Let's suppose you have named your player "car". You can have any of
the colors of your car act as collision sensors.
First get a scriptor. Then drop in a conditional tile (this can be
dragged out of the little thumbnail at the top of the scriptor). Look
under "Tests" in your car's viewer for "color sees" (this is a very
nice feature by Ted Kaehler).
Drop "color sees" into the "Test" line of the conditional. It will
expand into:
car's color < > sees < >
where there is a color in each of the < >s. Touch each of these
colors to get a color picker. You can also choose any color in the
world. For the first color, pick a color in the car (we usually paint
a special sensor dot). Then pick another color in the world for the
second color. The test will be true when the first color touches the
second color.
A good first project is to draw a road. Put a sensor dot in front of
your car (remember that paintings don't have to have contiguous
paint). Then write the script:
car follow <ticking>
car forward 3
Test car's color <sensor color> sees <road color>
Yes car turn -5
No car turn 5
and start the car near the road on the outside.
You can motivate your child to come up with this elegant algorithm by
having them try to follow a wall with their eyes closed. Pretty soon
the child will realize that a good strategy is to go forward heading
towards the wall until it is touched, then to turn away from the way
until contact is broken, then to turn back, etc.
A next good project is to think of ways to keep the car in the center
of the of road, etc. The 9 and 10 year old children in the Spring
2000 class that Kim and BJ Allen ran came up with some very elegant
solutions (the nicest ones used multiple processes instead of nested
conditionals).
You can do some nice maze running by making forward, left and right
sensor dots, etc.
Cheers,
Alan
-------
At 4:26 PM +0100 12/10/00, Karl Ramberg wrote:
>Alan Kay wrote:
>>
>> Hi Karl --
>>
>> Look in the viewer for playfields (also, the world is a playfield) to
>> find mouseX and mouseY. I think Scott is planning to allow keyboard
>> events and chars from the keyboard sometime soon.
>
>Found it :-) Thanks.
>After a little effort I'm starting to get the hang of the tiles and
>it seems quite flexible. The tiles are really slow on my old mac,
>but executing the scrips seems quite fast.
>I'm building a simple game with my son and we were looking for
>a collision test but could not find it. Do you have another hint ?
>
>Karl
More information about the Squeak-dev
mailing list
|