Getting Started with Scripting


Excercise 8 - Scripting one morph to chase another

Get a morph (which you've named, say, "rabbit") busily animating with an ever-ticking script involving "forward by" and either "turn by" or "bounce".Construct another Morph, name it "chaser" and script it to pursue the animating morph by giving it an ever-ticking script of the form:

chaser move toward §

§ here refers to the little symbol in the bottom-left of the window - the one object in the world that starts out life with "identity", this serves as the sample parameter for any Player-valued scripting element, just like the "5" in "forward by 5" serves as a sample parameter for "forward by".

To make the object move not toward § but rather toward the "rabbit" you've earlier animated, you'll want to tear off a tile to represent the rabbit. There is a handle near the top left of the Halo which, when you mouse down on it, will yield you just such a tile. Get it, and drop it over the "§" tile, and it will replace that tile, so that your script will now read:

chaser move toward rabbit

You can adjust the speed at which pursuit takes place by adding a numeric slot to chaser and calling it "speed".