Tile for Mouse and Keyboard ?

Bob Arning arning at charm.net
Sun Dec 10 16:23:58 UTC 2000


On Sun, 10 Dec 2000 16:26:29 +0100 Karl Ramberg <karl.ramberg at chello.se> wrote:
>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 ?

Hi Karl,

In the viewer, look at the category "tests". You can use "XXX's isOverColor" and "XXX's colorSees" in a test tile to determine when the morph has entered or left a particular (differently colored) region. One way this technique has been used is in making cars that follow a road. If the car is drawn with two uniquely colored spots ahead of the car and slightly off to either side, then one can construct scripts like this

- Create a new script for the car
- In the script get a test (from the tear-off near the close button in the upper right)
- Drop the test into the script
- From the car's tests category, grab the "car's colorSees" tile and drop it to the right of the word Test (where green highlighting appears).
- Set the first color in the phrase to match the color of one of the car's steering sensors. Set the second color in the phrase to match the color of the road. Do this by clicking on the color to get a picker, then mouse down in the picker and drag the mouse to a place where the desired color is visible (i.e. the car's sensor or the road).
- In the No section of the test, drop a "car turn by" tile and set the amount to cause the car to turn back toward the road (depending, of course, on whether this is the left or right sensor).


Note: This seems to work a bit easier in 2.8 at the moment since the area for dropping the phrase into the test is larger.

Cheers,
Bob





More information about the Squeak-dev mailing list