[Home] [Back to Message Index]

Global SchoolNet - Automated Message Archive

Re: LOGO-L> MWorlds ?@ keys




Michael Tempel (michaelt@media.mit.edu)
Fri, 17 Jan 1997 06:27:34 -0500

>One of my sixth graders is using Microworlds and is trying to program a
>soccer game. One of the things he wants to do is have the arror keys or the
>number keys on the keyboard have spacific functions for his game. Like
>turning and moving the players.

[snip]

>Is there a way to program keys in MW or not?

Sure. Here's a sample I gave to my sixth and seventh graders. The ascii
codes 28, 29, 30, and 31 correspond to the Macintosh arrow keys. There are
two turtles on the page. One is programmed to SEEK "many times" and the
other to DRIFT "many times". There's a GO button which you click to start
the game.

to go
everyone [clickon]
t1, forever [direct readchar]
end

to direct :key
if (ascii :key) = 28 [ seth 270]
if (ascii :key) = 29 [ seth 90]
if (ascii :key) = 30 [ seth 0]
if (ascii :key) = 31 [ seth 180]
if :key = "s [stopall]
end

to seek
fd 5
if touching? "t1 "t2
[announce "gotcha!! stopall]
end

to drift
glide 500 1
seth random 360
end

The kids have developed some pretty elaborate games from this start,
especially mazes.

-Michael

Michael Tempel tel: 212 579 8028
Logo Foundation fax: 212 579 8013
250 West 85th Street michaelt@media.mit.edu
New York NY 10024
http://el.www.media.mit.edu/groups/logo-foundation/

---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org. Mail
questions about the list administration to logofdn@gsn.org. To
unsubscribe send unsubscribe logo-l to majordomo@gsn.org.