LOGO-L> Keyboard commands 
Author Message
 LOGO-L> Keyboard commands

I am  teaching Microworlds logo
to sixth graders, and they are
developing games.  The games,
though not elaborate, stretch
the students' programming
ability to the limit, because
they know what they want to
achieve, but not how to do it.
I spend a lot of time with them
going through the vocabulary in
the help menu and looking in our
MW user's guide, trying to find
how this or that cool thing
could be done.  But now I'm
stumped (don't know where to
look anymore).

Can a procedure be written that
allows the player of a game to
use only the arrow keys at the
right of the keyboard without
hitting "return" so that the
player can change the turtle's
direction?  We can easily write
procedures for buttons or
keystroke-return, but not this
additional step.  Can anyone
help?

Ruth Draper
Harford Day School
Bel Air, MD

---------------------------------------------------------------





Tue, 24 Sep 2002 03:00:00 GMT  
 LOGO-L> Keyboard commands
Ruth,

Here are procedures to drive the turtle around using the arrow keys:

to go
t1,  
    clickon
    forever [direct readchar]
end

to direct :key
if (ascii :key) = 37 [ seth 270]
if (ascii :key) = 39 [ seth 90]
if (ascii :key) = 38 [ seth 0]
if (ascii :key) = 40 [ seth 180]
if :key = "s [stopall]
end

The turtle T1 is programmed to FORWARD 1 many times, so the CLICKON command
in GO runs that turtle instruction and gets that turtle moving.

It's best to make a button with the instruction GO on it. (If you type GO
in the command center you'll then have to click somewhere on the page with
the mouse before READCHAR will work.  Since the button is on the page
clicking on the button takes care of this.)

The ASCII numbers for the arrow keys are for a PC.  For a MAC use 28, 29,
30, 31.

There's more information about this and other aspects of game programming
in articles that Hope Chafiian and I wrote.  Begin at:
http://www.logofoundation.org/LU/v7n2/v7n2.html

I hope that helps.

-Michael


Quote:
>I am  teaching Microworlds logo
>to sixth graders, and they are
>developing games.  The games,
>though not elaborate, stretch
>the students' programming
>ability to the limit, because
>they know what they want to
>achieve, but not how to do it.
>I spend a lot of time with them
>going through the vocabulary in
>the help menu and looking in our
>MW user's guide, trying to find
>how this or that cool thing
>could be done.  But now I'm
>stumped (don't know where to
>look anymore).

>Can a procedure be written that
>allows the player of a game to
>use only the arrow keys at the
>right of the keyboard without
>hitting "return" so that the
>player can change the turtle's
>direction?  We can easily write
>procedures for buttons or
>keystroke-return, but not this
>additional step.  Can anyone
>help?

>Ruth Draper
>Harford Day School
>Bel Air, MD

>---------------------------------------------------------------




================================
Michael Tempel
Logo Foundation
250 West 85th Street
New York NY 10024
phone: 212 579 8028
fax: 212 579 8013
http://www.logofoundation.org/
---------------------------------------------------------------





Wed, 25 Sep 2002 03:00:00 GMT  
 LOGO-L> Keyboard commands
Hello Ruth,
The problem you mentioned is solved in our Logo-version Superlogo (Europe)
by the following 2 procedures:

to move
setphase phase + 1
forward 10 wait 100
 if key? [which.key][move]
move
end

to which.key
make "pushed readkey
 if :pushed = -72 [setheading 0]
if :pushed = -77 [setheading 90]
 if :pushed = -80 [setheading 180]
 if :pushed = -75 [setheading 270]
end



Quote:
> I am  teaching Microworlds logo
> to sixth graders, and they are
> developing games.  The games,
> though not elaborate, stretch
> the students' programming
> ability to the limit, because
> they know what they want to
> achieve, but not how to do it.
> I spend a lot of time with them
> going through the vocabulary in
> the help menu and looking in our
> MW user's guide, trying to find
> how this or that cool thing
> could be done.  But now I'm
> stumped (don't know where to
> look anymore).

> Can a procedure be written that
> allows the player of a game to
> use only the arrow keys at the
> right of the keyboard without
> hitting "return" so that the
> player can change the turtle's
> direction?  We can easily write
> procedures for buttons or
> keystroke-return, but not this
> additional step.  Can anyone
> help?

> Ruth Draper
> Harford Day School
> Bel Air, MD

> ---------------------------------------------------------------






Wed, 25 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. LOGO-L> Re: Keyboard commands

2. LOGO-L> Logo commands

3. LOGO-L> keyboard size

4. LOGO-L> bury command in MSWlogo

5. LOGO-L> Re: Shut Down Command

6. Apple Logo II > Fill Command

7. LOGO-L> Re: Using Command Line Options

8. LOGO-L> Re: Using Command Line Options

9. LOGO-L> Using Command Line Options

10. LOGO-L> erase command

11. LOGO-L> Apple logo/MSW Logo

 

 
Powered by phpBB® Forum Software