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

#1 2009-03-22 05:59:38

Uncanny
Scratcher
Registered: 2008-09-06
Posts: 100+

How to improve FPS

sometimes if you have a lot of sprites, or smooth animations, your game will slow down STACKS. (I just notices this when I tried to make a lighting effect). Here are some ways I dreamed up to keep the FPS up whenever possible.

1. Taking turns to switch costume
The human eye can see at 60 fps, and scratch has goal smoothness of 100 fps. So you don't need to have sprites animating every second. You might only need them to animate about 5 times a second. So that will *theoretically* take out 95% of the lag. But you will still have the frame rate dropping 5% of the time!
Then if you tell certain sprites to wait an amount of time before switching costume, eg, wait 0.05 seconds, then the costumes start switching every 5 seconds, it will keep the framerate consistant, but it can take time to program.

2. Don't make it animate if it is not visible
A useful way to take out unnecesary lag is to not make a sprite animate if it is not visible, this can simply be done by (if distance to object (you) is less than 240, then do whatever animation the sprite would want to do). This will be useful if you are doing a background scroller.

3. Big images eat up FPS when they do stuff
Just make the big image turn into a tiny costume like a dot, and then use let it move. also you can make it not move unless it is visible, by using variables to let it keep track of it's position.

4. Don't make object's 'float' when they aren't in the room.
-floating is when a object highlights when it touches the mouse pointer, this can be ghost effects, colorising, etc...

-what I mean by room is that sometime you are in a main menu, and then you click 'play game' to play the game. Then the broadcasting is done, and you go into a different 'room.'

this is a minor way to speed things up, but sometimes you can be out of the main menu, and although the buttons will be 'hiding,' you can see in the sprites area that their colorising effect is still taking place. You don't want this to happen when you don't even need the buttons, so just make the buttons 'float' when you are in the 'menu' room.

5. Avoid effects if able to do so.
transparency can be made when you put diagonal transparent lines accross the sprite, sometimes this can make it ugly, but do it when you are able to.

other effects such as whirl, pixilate and colorising will take up lots of space and time when you animate them, so don't try to work around these effects!

I hope you found this 'lag-destroyer' tips helpful!


http://scratch.mit.edu/projects/Uncanny/383474
This is an original song that I have made.

Offline

 

#2 2009-03-22 09:55:23

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: How to improve FPS

Nice tips! I was disappointed by the "menu highlighting" suggstion (my projects do it a lot) but I guess in the end it would reduce lag.

About tip number one, how would you reduce the frame rate? I thought that Scratch was set at 100 fps. Or is there a way to work around that? Also, adding a wait block I thought would increase lag. It is just adding another script for Scratch to process.

Great job anyway!

Offline

 

#3 2009-03-23 02:46:30

Uncanny
Scratcher
Registered: 2008-09-06
Posts: 100+

Re: How to improve FPS

lag is when the game becomes jumpy and there is nothing you can do about, when you make it wait for 0.01 seconds at 100 FPS, it will wait for 0.01 seconds. if you tell it to wait for 0.01 seconds at 30 fps, it will wait for about 0.033 seconds.
oh- i get what you mean, but if you just do it at the start, as I described, it will only slow down the first 0.1 seconds of the game, it is still worth it, i think. You don't HAVE to do it.

Last edited by Uncanny (2009-03-23 02:47:46)


http://scratch.mit.edu/projects/Uncanny/383474
This is an original song that I have made.

Offline

 

#4 2009-03-24 20:24:21

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: How to improve FPS

Uncanny wrote:

lag is when the game becomes jumpy and there is nothing you can do about, when you make it wait for 0.01 seconds at 100 FPS, it will wait for 0.01 seconds. if you tell it to wait for 0.01 seconds at 30 fps, it will wait for about 0.033 seconds.
oh- i get what you mean, but if you just do it at the start, as I described, it will only slow down the first 0.1 seconds of the game, it is still worth it, i think. You don't HAVE to do it.

Oh O.K. I was just confused about  doing it while the project is running. But I see what you mean, if you put it at the beginning of a project (something I never thought to do) it would definitely help cut unnecessary lag. BTW, is lag an abbreviation? I've never heard anyone use anything but that term (but it might be good to know, just for future reference).

Offline

 

#5 2009-03-25 01:18:58

Uncanny
Scratcher
Registered: 2008-09-06
Posts: 100+

Re: How to improve FPS

not that I know...


http://scratch.mit.edu/projects/Uncanny/383474
This is an original song that I have made.

Offline

 

#6 2009-03-31 02:56:09

Uncanny
Scratcher
Registered: 2008-09-06
Posts: 100+

Re: How to improve FPS

http://en.wikipedia.org/wiki/Lag

maybe i should resuggest the 'instant' block. i am aware that scratch delibirately puts 0.01 seconds in between each block to make things easier to keep track of, but and instant block in which all the blocks inside that block can be done instantly (to the extent of that which the computer allows) that would say hi to loads of new stuff, like 3D, loads of sprite, costume changes, efficient duplicating (lists or cool stuff!).


http://scratch.mit.edu/projects/Uncanny/383474
This is an original song that I have made.

Offline

 

#7 2010-05-30 20:02:14

mman2112
Scratcher
Registered: 2009-11-21
Posts: 27

Re: How to improve FPS

REMEMBER if you are making a project and not going to put it online use BYOB 2.99


http://i35.tinypic.com/ie367k.png

Offline

 

Board footer