How do i Optimize Game

Get help using Construct 2

Post » Thu May 21, 2015 10:02 pm

Right now i am setting all collisions properties to False for every sprite that is used as a "detail" for the levels

I also went and decided to make 1 big shared event sheet where all the player controls are, such as movement and pausing, so the code wouldn't have to be repeated in every level's sheet

After doing some research about further possible optimizations here are my following "Unanswered" questions:

= I read this
"To ensure previews are fast, duplicate images are not removed when previewing. However when exporting, Construct 2 looks for and removes duplicate images. This helps reduce the download size and memory use, since there's no point having identical images downloaded twice or loaded in to memory twice." from another thread here.

I often used the same image (resource) but opened with in different sprite(because i wanted one block to do nothing and another to do something while they were both identical on the outside)
Can i be assured that all the repeating objects i have won't be included in the final file size? (as in, all those sprites on the right that i imported but deleted or that i imported more than once because "noob" mistakes)


=i read this: (regarding minifing script)
"This renames everything possible in the javascript code to use the shortest names possible, which makes the script smaller and quicker to download."
But most importantly
"It may also make the resulting Javascript slightly more efficient, since it employs some basic optimisations like inlining and removal of unused code."

Does this mean that all those Copied variables i have (for example: at the start i copied all my movement code, including variables, and now i have (for example) variable: canyoudoublejump2 on level2 canyoudoublejump3 on level 3 and so on) and that are, most probably, not used will be removed from the code thus i can just ignore them in the project and not "hunt" the unused variables since, upon exporting, they won't be an issue?



=i read this:
"If you have many background and graphics sprites, you can add all the images in one sprite and make the animation speed to 0 , then change the frames as you like.
This better than using 50 sprites as background and graphics."

Does this have a big impact on the framerate/loading overall performance or is it something done because it is more "convenient" (and i could see why it would be!)




And a side question:
I have a text object on all of my levels that indicates the distance of the player from the end of the level, to do this im using the distance between 2 points code i found here, my question is: Since im using the "calculate distance and put in text" code "on player moving" , does this affect the performance since every time the player moves the CPU has to calculate X1-x1,y1-y2 or is it insignificant in terms of performance drop?
B
5
Posts: 48
Reputation: 319

Post » Thu May 21, 2015 10:43 pm

To find out what images are in the final build export it and look in the images folder.

There are different levels of minifying, I can't say for sure which C2 uses but if a variable is never referenced it should be automatically removed. You could try find an example, open the js file for editing and search for it to see.
[Note some minification will rename variables to shorter names too and not as you wrote them]

Calculating the distance will be negligible, however displaying it every tick would have some impact, instead update it every second or so.
B
13
S
4
Posts: 65
Reputation: 875

Post » Sat May 23, 2015 10:28 pm

@majesticAsFk Hey man thanks for the reply (and sorry for the late answer :P)
First i'd like to say AMAZING name really, hahah
And second: I did the following things to fix the overall performance:

As you suggested i checked the resources in the final build export and there are only the used ones (construct 2 removes the unused ones apparently)
As you suggested, again :P, i changed the text display to change every 0.3 seconds
As for the minifying and variable issue i didn't know how to check the js file myself so i just went on an eight hour adventure of hunting down every unused variable!

Also, for those interested, removing Collisions Enabled to every non player interactive sprite improves everything!
aaaand not repeating code also helps, using a common event sheet helped me lower my lines of code from 1800 to 1055! (and i could have probably lowered it even more if i used functions and such similar magical inventions!)

Overall achieved Fps increase and size drop, good!
B
5
Posts: 48
Reputation: 319

Post » Sun May 24, 2015 2:34 pm

Ah excellent, great tip with the collisions.
B
13
S
4
Posts: 65
Reputation: 875


Return to How do I....?

Who is online

Users browsing this forum: Cub3D, David181, yiuyiu6666 and 26 guests