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

#1 2010-08-13 08:21:18

Enzo1997
Scratcher
Registered: 2008-06-14
Posts: 500+

Wait 1 second vs. timer

Wait one second takes more time than 1 second...


Your music tastes are bad, therefore your argument is irrelevant.

Offline

 

#2 2010-08-13 08:37:32

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Wait 1 second vs. timer

Enzo1997 wrote:

Wait one second takes more time than 1 second...

yes, its due to lag. I'm not sure if there is a solution.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#3 2010-08-13 09:05:41

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Wait 1 second vs. timer

it's intentional lag. it waits for something like 0.025 at each loop end.
so the script [blocks]
<repeat( 40
<wait( 1 )secsc>
<end>
[/blocks]
would take 41 seconds instead of 40.
or something on those lines anyway

Offline

 

#4 2010-08-13 11:45:45

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Wait 1 second vs. timer

just use
wait 0.975 secs


You can now reach me on Twitter @johnnydean1_

Offline

 

#5 2010-08-14 05:33:36

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Wait 1 second vs. timer

but even then, there's also a tiny lag which is different on all PCs...

Offline

 

#6 2010-08-14 06:47:21

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Wait 1 second vs. timer

LS97 wrote:

but even then, there's also a tiny lag which is different on all PCs...

And the more you get it to do, the slower it gets. Why is there that 0.025 second wait period though?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#7 2010-08-14 07:00:26

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Wait 1 second vs. timer

i think it's rpobably because if you make a script [blocks]
<repeat( 10 ))
<move( 2 )steps>
<end> [/blocks]
it would jump 20 pixels instantly. with the 0.02 second break, the sprite would take at least 0.25 seconds to do those 20 pixels. in fact, it takes about 0.5 to 1 seconds...

Last edited by LS97 (2010-08-14 07:00:56)

Offline

 

#8 2010-08-14 07:06:51

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Wait 1 second vs. timer

markyparky56 wrote:

LS97 wrote:

but even then, there's also a tiny lag which is different on all PCs...

And the more you get it to do, the slower it gets. Why is there that 0.025 second wait period though?

Because of what ls said and the fact it has to check how many times it still has to do it, and deduct one each time it loops.

Offline

 

#9 2010-08-14 08:02:39

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Wait 1 second vs. timer

LS97 wrote:

i think it's rpobably because if you make a script [blocks]
<repeat( 10 ))
<move( 2 )steps>
<end> [/blocks]
it would jump 20 pixels instantly. with the 0.02 second break, the sprite would take at least 0.25 seconds to do those 20 pixels. in fact, it takes about 0.5 to 1 seconds...

So its for smoothness...


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#10 2010-08-14 09:32:54

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Wait 1 second vs. timer

Do you want to see how much lag it really has? Look here


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#11 2010-08-14 10:34:36

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Wait 1 second vs. timer

LS97 wrote:

i think it's rpobably because if you make a script [blocks]
<repeat( 10 ))
<move( 2 )steps>
<end> [/blocks]
it would jump 20 pixels instantly. with the 0.02 second break, the sprite would take at least 0.25 seconds to do those 20 pixels. in fact, it takes about 0.5 to 1 seconds...

This is because loops yield to other processes after running one time through. This means that the loop is only executed once per frame, rather than all in one frame (BYOB's "atomic")


nXIII

Offline

 

#12 2010-08-24 12:55:44

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Wait 1 second vs. timer

I did a few tests, and it turns out that the [forever] block is a little more than 4.7222222222222222... percent slower than realtime.


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

Board footer