Lag making your game unplayable? Here are a few tips to help eradicate the lag and keep your gameplay smooth as a smoothie:
1. Show as few variables and lists as possible - Variables and lists slow down movement in your game. When playtesting your game, make sure to hide all unnecessary variables.
2. Use as few sprites as possible - I find that many sprites usually slow down projects to a crawl. If you NEED some stuff to be shown, try putting it in the background, or using one sprite with different costumes and scripts.
3. Try to use less scripts/combine as many scripts as possible into one script - The more scripts running at any time, the slower your game will be. If you combine a bunch of scripts into one big script, your game will be a lot smoother. Obviously, you can't do this with all scripts because of stuff like 'Wait Until <______>'.
4. Use as few loops (forevers, repeats) and "When green flag clicked" as possible - This tip goes hand-in-hand with the last tip. Loops and "When green flag clicked's" are the root of most of your lag. If you can combine your other scripts into one script, there won't be a need for very many loops and "When green flag clicked's".
If you have any more tips, post and I'll try and add them
Last edited by Sunrise-Moon (2010-08-30 21:21:09)
Offline
Excellent guide! My one suggestion is to put more emphasis on the last point, as it is the primary reason for almost all lag. Replacing them with "repeats" is obviously the way to go; most forever blocks are only needed at one or two points during the game
Other than that, fantastic guide!
Offline
coolstuff wrote:
Excellent guide! My one suggestion is to put more emphasis on the last point, as it is the primary reason for almost all lag. Replacing them with "repeats" is obviously the way to go; most forever blocks are only needed at one or two points during the game
Other than that, fantastic guide!
Thanks! I added another little sentence saying that they're the root of most of the lag.
Jwosty wrote:
Wow! Great tutorial! Maybe a little more info (if any is found) and it would be a perfect sticky-worthy topic! Keep up the good work.
![]()
Thank you! This is basically all I know about lag right now, but maybe other people know some other stuff about the lag.
Last edited by Sunrise-Moon (2010-08-30 20:40:57)
Offline
Sunrise-Moon wrote:
Jwosty wrote:
Wow! Great tutorial! Maybe a little more info (if any is found) and it would be a perfect sticky-worthy topic! Keep up the good work.
![]()
Thank you! This is basically all I know about lag right now, but maybe other people know some other stuff about the lag.
Yea, I go a weird color sensing glitch on this project, but it's probbably because of the online Java Player...
Last edited by Jwosty (2010-08-30 20:44:44)
Offline
Jwosty wrote:
Sunrise-Moon wrote:
Jwosty wrote:
Wow! Great tutorial! Maybe a little more info (if any is found) and it would be a perfect sticky-worthy topic! Keep up the good work.
![]()
Thank you! This is basically all I know about lag right now, but maybe other people know some other stuff about the lag.
Yea, I go a weird color sensing glitch on this project, but it's probbably because of the online Java Player...
![]()
Yeah, the project seems to run at a pretty good speed, so I don't think it has anything to do with lag in the project.
Offline
Sunrise-Moon wrote:
Jwosty wrote:
Sunrise-Moon wrote:
Thank you! This is basically all I know about lag right now, but maybe other people know some other stuff about the lag.
Yea, I go a weird color sensing glitch on this project, but it's probbably because of the online Java Player...
![]()
Yeah, the project seems to run at a pretty good speed, so I don't think it has anything to do with lag in the project.
Oops! It isn't a lag problem, the bugs just spin in circles when they get to the edges. But Paddle had a suggestion that worked to fix that!
I made the pen marks thicker and the sensors on the bugs bigger, and now I have ERADICATED the problem.
Offline
Excellent guide! You might want to mention the dangers of loops though.
Offline
Jonathanpb wrote:
Excellent guide! You might want to mention the dangers of loops though. :)
Thanks! Alright, I'll add it in with the last tip :o
Offline
Forever-if blocks run faster than an If inside a Forever - you might want to add that.
Offline
Cool guide bro.
Offline
Also, use as few broadcasts as posible.
Offline
Chrischb wrote:
Forever-if blocks run faster than an If inside a Forever - you might want to add that.
![]()
That's not quite lag-related.
Offline
j4142000 wrote:
I really want to make a platform game,but i don't know how!One of them gave me a headache,and the other one didn't work!
One of the platform games you tried to make gave you a headache? Are you asking me in particular?
Offline
Sunrise-Moon wrote:
3. Try to use less scripts/combine as many scripts as possible into one script - The more scripts running at any time, the slower your game will be. If you combine a bunch of scripts into one big script, your game will be a lot smoother. Obviously, you can't do this with all scripts because of stuff like 'Wait Until <______>'.
Uh, could you check to make sure these actually work before misleading newbies with them? Here's where you're wrong. Long scripts cause more lag than many short scripts.
Offline
Ace-of-Spades wrote:
Sunrise-Moon wrote:
3. Try to use less scripts/combine as many scripts as possible into one script - The more scripts running at any time, the slower your game will be. If you combine a bunch of scripts into one big script, your game will be a lot smoother. Obviously, you can't do this with all scripts because of stuff like 'Wait Until <______>'.
Uh, could you check to make sure these actually work before misleading newbies with them? Here's where you're wrong. Long scripts cause more lag than many short scripts.
Oh, ok. Sorry, I'll edit it in a second.
Offline
How do you write a project without broadcasts and Forever loops? I see both of these mentioned as "avoid this" all the time but I can't write loopless projects.
Offline
Locomule wrote:
How do you write a project without broadcasts and Forever loops? I see both of these mentioned as "avoid this" all the time but I can't write loopless projects.
You should avoid them as much as possible, but you will usually use at least 2 in your projects.
Offline
Locomule wrote:
How do you write a project without broadcasts and Forever loops? I see both of these mentioned as "avoid this" all the time but I can't write loopless projects.
About forever loops: I find that there are some cases where they can be avoided via substitution with "repeat until" loops; that way the loops don't repeat all the time throughout a project (too many loops occurring at one time can cause lag, sometimes even offline). Of course, such substitution will depend on the the project is designed.
Offline
I heard that broadcasts were great offline but terrible online?
I have already started doing some offline testing of my own and will post the results when finished. I never expect anything to work online as my serious projects get kinda crazy with the scripting.
Offline
Amazing! Should be pinned!
Offline