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]

Subject: MIA, Ask an Expert: gravity, asciis, ...
From: mwforum@xxxxxxxxxxxxxxxxxx (Mike Sandy)
Date: Thu, 7 Oct 2004 19:27:46 +0100

Daniel's program raised
the question, exactly when
is the test for touching? applied?

The test can be used in several
1. As a WHEN[touching? "bullet "target][..]
  a. in SHOOT as in Daniel's program
  b. in startup, e.g.

to startup
  target, forever[fd .05 * targ_vel]
 t2, st 
 bullet, setpos t2's "pos st
 forever[if readchar  = "| |[shoot]]
 when[touching? "target "bullet]
    bullet,  setpos t2's "pos ht

2. For "bullet
 repeat 200
  [ifelse touching? "bullet "target
       bullet,  setpos t2's "pos ht
   [fd 1]
 or similarly for  "target.

After a bit of experimenting I found
the test is applied only after the
turtle stops moving(obvious for 2).

 The main difference between 1. and 2.
is that a hit was possible for 1. only with 
a lower bullet speeds  
With 2., hits were possible with much faster
speeds e.g. fd 10.
Anyone suggest why?

Perhaps someone with quicker responses than I have,
will find otherwise.

It does suggest that method 2. has the advantage.

Compare the number of hits you can make with the
program using WHEN(1) and then using IF(2). 
Select using slider "when/if", the text underneath
won't change until you press GO.



Attachment: shoot1.mw2
Description: Binary data

  • Previous by thread: MIA, Ask an Expert: gravity, asciis, ...
  • Next by thread: MIA, Ask an Expert: gravity, asciis, ...

  • 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