Project Folders
Teacher Resources
Student Resources
How Do I?
Site Map
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: "MicroWorlds Forum" <mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: respond to mouse *and* keys
From: "Menefee, Mike - OC" <Mike@xxxxxxxxxxxxxxx>
Date: Tue, 18 May 2010 08:15:56 -0700

Hi Alan,

I love the ideas you have used (the hidden turtle).  Consider something
like this:

to point+keys

t1, ht setinstruction [forever [setpos mousepos]]

t2, setinstruction [forever [towards "t1]]

t3, setinstruction [forever [make "key ascii readchar
if :key = 38 [t2, glide 200 2]]]

everyone [clickon]




Original Message-----
From: mwforum-bounces@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
[mailto:mwforum-bounces@xxxxxxxxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Alan
G Isaac
Sent: Monday, May 17, 2010 12:08 PM
To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: respond to mouse *and* keys

My son is learning Microworlds.
I'm trying to help him when he gets stuck.
He is young (11) and I am not a Microworlds user,
so our questions may be pretty naive.

In a certain setting, he wants a turtle (say, t1) to do two things:
- keep pointing toward the mouse-pointer location, and
- move in response to the arrow keys

We can do each thing individually.

To point to the mouse-pointer position we did the following:
we created an invisible turtle that always moves to the mouse position,
and we use `towards` to point t1 towards that turtle. (Is this a good
Let's call the procedure `face`.

We then tried making a `move` procedure that
- checks for a key press (using key?)
- if an arrow key is pressed, moves
- calls face (which is *not* recursive)
- calls move

The turtle t1 does keep turning to face the mouse pointer.
Bit the key presses do not seem to be detected.

If we comment out the call to `face`, the key presses are detected
and movement is as desired.


Alan Isaac

  • Previous by thread: respond to mouse *and* keys
  • Next by thread: Re: respond to mouse *and* keys

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.

    © copyright 2001 - 2008