Wait command

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Wait command

Roman Zilber
Hi all,

I am trying to find a way to control speed of motion and can't find it. Here an example:

Script:
repeat 4 times:
do:
Rocket.turn by (90)
Rocket.forward by (100)

All the lines of code executed immediately, I want to have a pause between motions.

Script:
repeat 4 times:
do:
Rocket.turn by (90)
Rocket.wait(1)
Rocket.forward by (100)
Rocket.wait(1)

Is there option to do it?

Thanks,

Roman







_______________________________________________
Squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Wait command

K. K. Subramaniam
On Friday 01 May 2009 7:33:03 am Roman Zilber wrote:

> Hi all,
>
> I am trying to find a way to control speed of motion and can't find it.
> Here an example:
>
> Script:
> repeat 4 times:
> do:
> Rocket.turn by (90)
> Rocket.forward by (100)
>
> All the lines of code executed immediately, I want to have a pause between
> motions.
You can assemble a timer in Etoys yourself. E.g. Paint a second hand and a
script that will trigger the next steps when it reaches a specified angle.
Hide the painted hand, if necessary :
     line turn: 1
     if line heading > 15 then
        line heading = 0
        run next step

HTH .. Subbu

_______________________________________________
Squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Wait command

Bert Freudenberg
In reply to this post by Roman Zilber
On 01.05.2009, at 04:03, Roman Zilber wrote:

Hi all,

I am trying to find a way to control speed of motion and can't find it. Here an example:

Script:
repeat 4 times:
do:
Rocket.turn by (90)
Rocket.forward by (100)

All the lines of code executed immediately, I want to have a pause between motions.

The "repeat" block is not meant for animation. As you noticed, it's executed in a single step.

To animate an etoys object, set a script to "ticking" and describe what the object does in any single step. It's an object-centric approach. We're not telling the object "do this, then wait, then do that". Instead, try to imagine what your object needs to do at any single point in time. That is going to be the script. 

To go slowly in a square, we might want to go 20 steps of 5 pixels each, then turn by 90 degrees. So I would make a variable "steps" and then use this script:

MyObj's steps increase by 1
MyObj forward by 5
Test MyObj's steps > 20
  Yes
    MyObj turn by 90
    MyObj's steps ← 0
  No

- Bert -


_______________________________________________
Squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland