Tips & Tricks for Optimization
Reloaded
Platform Builder is quite slow sometimes, and slow games are boring. Here are some tips and tricks for optimizating your game. This is a reloaded version to the original, with more stuff. Let's go:
1.- Avoid cluttering tilesTilesets are not very laggy, but if you use too much of them, they will start to lag. Use no more than the necessary and also use expandable tiles if possible.
2.- If you use looping command prompts, use constant type: As far of my researchs, constant looping is much faster than normal, even if it sounds stupid. You can set this type of looping by executing
loop = constant
at the start of the area.
3.- Minimize hud commandsIt's not recommended to loop hud updates if you're using custom HUDs. If you want to update the hud when you collect a coin, do it when you collect a coin and only the money counter for better optimization.
Example:
//Collect CP. Money item
money + 1
<hud text 2>[money]$ //This is an example if the hud text 2 was the money.
4.- Use curly brackets less as possibleWhen using conditionals, you may notice these are sometimes laggy and you can find them weak. If your conditional only executes 1 command, remove the curly brackets so you can do this.
//Bad code
if score > 1000
{
lives + 1
}
//Better code
if score > 1000
lives + 1
This trick gave me better optimization for my "test" games.
5.- Use area variables as much as possible: When you run a code, you may need to use variables to do fast calculations for THAT code. Use just area variables for that.
In fact, much variables saved on memory actually causes lag, so, it's better to make their values stay in memory as least as possible. Area variables remove after the area finishes.
Also, if you use variables for only 1 code, and doesn't need to be saved for more than 1 frame, use the same name for all them, so they are reused each time you need a variable for only 1 code.
Example of names I use:
var i = 0
var j = 1
var k = 2
//In general, 1 is good.
Hope these tips are useful for you. Thanks for reading and happy building!