View Full Version : keywind and in each iteration it "winds down"
compstuft
10-10-2008, 06:16 PM
Hi Alice community,
I am working on a project, and the object (turtle) is like a wind up toy. It moves as the key on its back spins.
I need to make it so that for every time the key rotates, the turtle moves 2 steps. So far, I have a key that turns and eventually winds down (one second for first iteration, two seconds for second, three for third...). I also have the turtle that moves two steps. Now the thing I am having trouble with is syncing the turtle with the key rotation. For example, key turns once, turtle takes 2 steps, key turns the second time, turtle takes 2 more steps, key turns a third time...I am not sure how to sync this because the key is "winding down." Please help me. Thanks.
I have attached the file that I am working on.
DickBaldwin
10-11-2008, 07:50 AM
Hi Alice community,
I am working on a project, and the object (turtle) is like a wind up toy. It moves as the key on its back spins.
I need to make it so that for every time the key rotates, the turtle moves 2 steps. So far, I have a key that turns and eventually winds down (one second for first iteration, two seconds for second, three for third...). I also have the turtle that moves two steps. Now the thing I am having trouble with is syncing the turtle with the key rotation. For example, key turns once, turtle takes 2 steps, key turns the second time, turtle takes 2 more steps, key turns a third time...I am not sure how to sync this because the key is "winding down." Please help me. Thanks.
I have attached the file that I am working on.
Have you tried using the do together block? (I didn't have time to download and examine the file that you attached.)
Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free Scratch tutorials: http://www.dickbaldwin.com/tocHomeSchool.htm
Free Java/C#, etc. tutorials: http://www.dickbaldwin.com/toc.htm
check page 151 of the "Programming with Alice" book:
http://books.google.com/books?id=NwIbWrnyHeYC&pg=PA150&lpg=PA150&dq=alice+function+method+ball+net+roll&source=web&ots=KJP1bvBg_r&sig=QPp7DpEbuQ4c4mExQInApVuZwDY&hl=en&sa=X&oi=book_result&resnum=1&ct=result#PPA151,M1
Similar problem, how to get a ball look like it's actually rolling along the ground by sync-ing "move forward" and "turn" in a do together block. Problem is, it can look like bad if you guess the values wrong, i.e., barely turning while moving forward too fast or turning too much while not moving forward enough. The book suggests creating a function, for the purposes of the ball rolling example, that takes an input of distance (how far to roll the ball) with an output value of # of revolutions to turn. In this case, the function is calculated by the circumference of the ball determining how much to turn for a given distance. You probably have a similar relationship with your key and turtle, how much the turtle moves should be a function of the key turning and so on.
Hope that helps.
Best regards,
-- DanG / Daniel Green / Sun Microsystems
here's an attached version that adds a function like was mentioned above. There's a world level function, "walkVsWind" which for now returns 1:1 assuming one turn should make the turtle walk forward once. A different ratio (walk a lot for one turn or turn a lot for one walk) would mean adjusting the return value of the function accordingly. Have fun.
-- DanG / Daniel Green / Sun Microsystems
compstuft
10-14-2008, 12:49 AM
Thanks to everyone who replied. To the person who posted above me:
Thanks! The key is synced with the turtle's movement, but the key isn't winding down, so I think I will incorporate some of your method with what I have.