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: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: respond to mouse *and* keys
From: Alan G Isaac <alan.isaac@xxxxxxxxx>
Date: Mon, 17 May 2010 15:08:09 -0400

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 way?)
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: touching is not working in some situation
  • 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