PDA

View Full Version : I need a little help...


jrrTolkien
05-08-2014, 12:48 PM
I have been using Alice for several years now, and have been posting answers to many people's questions, but now I have a question that needs answering! I have had experience with most code in Alice, but I don't know what the "for" statements do. The "for all in order" and "for all together" are the ones that I mean. I know that it has something to do with the lists, because it wants you to specify one when you drag it in, and that the for all in order plays the code in that order, and the all together plays them at the same time, but I don't know what the list is used for. If anyone can help with that, please do! Thanks,

-Jrr

djslater107
05-09-2014, 07:05 AM
You are correct... These statements are for lists...

Assume you have a list of cars, for a racing game. You will use the move command, with a random distance traveled.

For all together will have each car in the list move at the same time, but each for a difference distance. You build this statement by dragging in the move command for one of the cars, and then replace the car name in the move command with the "<obj> item from list" tile from the for all... statement. See attached screen shot.

All cars in the list will move at the same time, but with different random distances...

For all in order works the same way, but each car will move one after another (in the order they were added to the list)...

I hope that this helps...