[Thread Prev] [Thread Next]
On Tue May 24 08:10:11 2005, tks asked:
> using an ifelse statement we want to have 2 seperate shapes jointly move at
> the same time
>
> to test
> tto "comp st
> setsh pick {comp1.1 comp1.2 comp2.1 comp2.2]
> tto "guy st
> ifelse "comp = "comp1.1 [setsh "guy1.1]
> [ifelse "comp = "comp1.2 [setsh "guy1.2]
> [ifelse "comp = "comp2.1 [setsh "guy2.1]
> if "comp = "comp2.2 [setsh "guy2.2]]]
> end
>
> can this be done? if yes how?
> tks
Hmmmmm....
I've not seen "ifelse" statements nested this way before. It appears to me
each of the four tests could be treated as separate "if" statements.
I notice that what's being done is the assignment of a shape for "guy. This
isn't really a movement, but something preparatory to making a movement.
Shape is a passive property. Each movement must be done with a different
turtle if they are to move at the same time.
In answer to your intent, "we want to have 2 seperate shapes jointly move at
the same time," this is usually accomplished with "launch." Launch will set
in motion some action (procedure or list of commands) of a turtle. It can be
immediately followed by additional "launches" of other turtles. In this way,
several characters can act separately but simultaneously.
If there is additional action following the launches, you need to include a
"wait" statement after the launches to give them time to execute before the
program proceeds to the next thing. Figuring out the correct length of the
wait can be done by trial-and-error until you find the right length of time.
So, a fragment of the program might read something like:
tto "compA launch [guy1thing]
tto "compB launch [guy2thing]
tto "compC launch [guy3thing]
wait 56
--Jeff
Previous by thread:
MIA, Ask an Expert: animating shapes
Next by thread:
RE: MIA, Ask an Expert: animating shapes
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.
|