Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

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

[Thread Prev] [Thread Next]

To: <mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: MIA, Ask an Expert: control turtle with keys
From: "Alain Tougas" <alain@xxxxxxx>
Date: Fri, 2 Mar 2007 09:24:39 -0500

Hi,

I won't give you the exact code, but here's the general technique.

Reading the keyboard involves
1. detecting a key being pressed
2. checking its ASCII value (each key has one)

To find out what the ASCII values are, type this in the command center
repeat 4 [show ascii readchar]
click on the page (important for readchar to work)
then hit the four arrow keys in order
Note the four values that you got in the Ccenter

Now the procedure:

to drive
if key? [react ascii readchar]
end

to react :thiskey
if :thiskey = ?? [whatever]
if :thiskey = ?? [whatever]
if :thiskey = ?? [whatever]
if :thiskey = ?? [whatever]
end

You must execute "drive" forever (forever command, button or clickable
turtle - buttons and clickable turtles are better because they "force" you
to click on the page, which is mandatory for readchar to work)

Ciao,

Alain

-----Original Message-----
From: mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
[mailto:mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sent: March 1, 2007 11:42 PM
To: askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: MIA, Ask an Expert: control turtle with keys

This is an automatic message sent from the web form at:
http://mia.openworldlearning.org/howdoi.htm

from: Scott <Smobley@xxxxxxxxxxxxxxxxxxxxx>
date: Thu Mar  1 21:41:56 2007
platform: Mac OS10
version: MicroWorlds Ex

How do I program my project so that I can control a turtle
with the keyboard (arrow keys)?





  • Previous by thread: MIA, Ask an Expert: control turtle with keys
  • Next by thread: MIA, Ask an Expert: hangman questions

  • 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