Sunday, May 11, 2008

line rider in scratch (part two)



In Scratch drawn lines are graphics and are not programmable (except for their colour) so I introduced arrow sprites which have properties such as direction, which can be accessed and transferred to the cat character

Make a global variable, named catDirection. Then when the cat touches a line a message is broadcast to the other sprites. Each arrow sprite has its own local direction property, which can be assigned to catDirection.

For more than one arrow you need to create a "touching?" (boolean) variable which detects if the character is touching any arrow. Then you need another if not touching ... and statement to set the direction to straight down when it slides off the end of the arrows


To have the cat speed up when falling down and slow down on an up arrow make another variable, "distance", which increases for down angles and decreases for up angles

Send me an email if you want the step by step instructions. Here are a couple more of the code segments:

1 comment:

squidinkcalligraphy said...

Kinda similar to this is the physics simulator I've just discovered: phun (look it up on google). Think somewhere between linerider and armadillo run (worth a look if you haven't seen it) with a few more possibilities.