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

#1 2011-08-17 12:37:46

LFCm4d227
New Scratcher
Registered: 2011-08-03
Posts: 16

A few questions about laggy games

I've noticed games with a lot of scripts tend to lag more than games that don't have a lot of scripts. But I still have a few questions:

1) Is it the amount of scripts of the amount of blocks that affect lag (I don't know if they're called blocks, but I mean the things that make up the script)?

2) Which would lag more: 2 scripts, both with 50 blocks, or 1 script, but with 100 blocks?

3) Does the amount of sprites affect lag?

I think there's more that I've just forgotten, so I may reply to my own post to ask them.

P.S. experienced Scratchers only please, and don't just guess, only answer if you know!

Thanks!

Offline

 

#2 2011-08-17 14:01:15

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A few questions about laggy games

I am an experienced Scratcher here are some answers:

2. One script with 100 blocks for sure
3. Sometimes.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#3 2011-08-17 14:05:52

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: A few questions about laggy games

1. I don't know what you mean.
2. 100 blocks
3. Yes

Offline

 

#4 2011-08-17 15:15:05

Flait7
Scratcher
Registered: 2008-04-14
Posts: 100+

Re: A few questions about laggy games

1) Is it the amount of scripts of the amount of blocks that affect lag (I don't know if they're called blocks, but I mean the things that make up the script)?

What affects lag are things like the size of your project, the number of sprites you have, the amount of scripts they have, the amount of forever blocks you're using, and the size of your scripts.

2) Which would lag more: 2 scripts, both with 50 blocks, or 1 script, but with 100 blocks?

1 script with 100 blocks would cause more lag than 2 scripts with 50 blocks each

3) Does the amount of sprites affect lag?

Having a large amount of sprites can affect lag.


http://scratch.mit.edu/static/projects/Flait7/2248016_sm.pnghttp://scratch.mit.edu/static/projects/Flait7/1827934_sm.png

Offline

 

#5 2011-08-17 15:27:00

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: A few questions about laggy games

There are a lot of things that can be done to speed projects up, I'm not so sure that sprite count has a big effect.  Check out AsteroidBattle.  It has 68 sprites and 260 scripts.  It runs well in Flash.

Some ideas:

*Instead of a forever loop, I use forever if,  the condition in the forever if can be used to turn off a script when it isn't needed.  (if a "bullet" isn't flying it doesn't need to do anything)

*Think about whether a loop needs to run as fast as possible, or whether it's OK to put a wait statement in it.  If your project does something (like calculate gravity) that can just be done every 1/2 second or so (because gravity changes, but in the example project is doesn't change quickly) put a wait statement in to free up the loops that have to run fast.

*Operator input (looking at keypressed?) should ususally have no waits, likewise with motion. 

*If you need to check for Left/Right arrow and Up/Down arrow for operator input -
use two scripts that run as fast as possible.

*Detecting color touching takes time (or maybe that's my imagination) - so I try to use sprite touching sprite for collisions.

Offline

 

Board footer