This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-02-18 20:27:35

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

repeat every 0.03 seconds

For a lot of my games and simulations, I want a loop to be initiated on a regular basis, like every 0.1 seconds.  It would be nice to have a block that did

repeat every 0.03 seconds
    ....


I suppose one could get a similar effect with a variable and the timer:

set next_time to timer
forever
     ....
     change next_time by 0.03
     wait until timer > next_time


Of course, a properly implemented built-in version of this could report an error (turn red) if the computer was not fast enough to keep up with the requested loop rate.  It would also be good not to have to create a variable for each such loop, and to be able to reset the timer, which this workaround doesn't permit.

I'm not sure, but I believe that flash has an implicit
  repeat every 0.1 seconds

Offline

 

#2 2008-02-18 22:20:05

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: repeat every 0.03 seconds

kevin_karplus wrote:

It would be nice to have a block that did

repeat every 0.03 seconds

Couldn't you do (supposing its a forever loop)
                   

                                      <repeat until>
                                      <wait(0.3)secs>
                                      <broadcast[ blah

I only said broadcat because its an example but you get the point.


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#3 2008-02-19 13:56:45

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: repeat every 0.03 seconds

kevin_karplus wrote:

I'm not sure, but I believe that flash has an implicit
  repeat every 0.1 seconds

Flash can execute code at intervals. It would be nice to have some sort of interval block in scratch.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#4 2008-02-20 18:13:04

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: repeat every 0.03 seconds

See this is why changing quotes is good.


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

Board footer