[Thread Prev] [Thread Next]
Hi!
If your program is similar to the "SnacMan sample", you have an OnTouch rule
that says:
WhoAreYou
and such procedure on the Procedures tab:
to whoareyou
ifelse touchedturtle = "ghost
[zapped]
[eat]
setstrength strength + 1000
end
The problem is, only ONE ghost can be called ghost.
My proposal goes like this:
Name your ghosts: ghost1 ghost2 ghost3 etc.
Then the procedure should check if the "beginning" of the name of the
touched turtle is "ghost". In other words, TRIM the number at the end of the
turtle's name and check if the remaining = ghost.
to whoareyou
ifelse (butlast touchedturtle) = "ghost
[zapped]
[eat]
setstrength strength + 1000
end
The trick is: butlast "ghost1 is "ghost. Butlast "ghost2 is also "ghost. In
other words, (butlast touchedturtle) = "ghost will be true for any turtle
that has a name made of GHOST plus one character.
You need the parenthesis because without them
butlast touchedturtle = "ghost
MicroWorlds will do touchedturtle = "ghost
which will report false, and butlast will report the butlast of the word
FALSE, which is FALS. Not what you want.
-----Original Message-----
From: mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
[mailto:mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sent: October 4, 2007 2:30 PM
To: askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: MIA, Ask an Expert: pacman ghosts
This is an automatic message sent from the web form at:
http://mia.openworldlearning.org/howdoi.htm
from: Todd <Todd.Whitefleet@xxxxxxxxxxxxx>
date: Thu Oct 4 12:29:42 2007
platform: PC
version: MicroWorlds Ex
I have a pacman type turle that loses a life when it hits a
floating ghost. How do I get it to lose a life when there
is more than one ghost? It eats them like the food pellets
instead of losing a life.
Previous by thread:
MIA, Ask an Expert: pacman ghosts
Next by thread:
The Logo Paradise is back
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.
|