any tips and trick with performance?
could you guys help me figure out what am i doing wrong?
i have:
-1 player with platforming behavior
-5 types of enemies (24 max on screen) with platforming behavior and simple AI
-enemy heads pop off and have physics behavior
-when firing bullets that collide with platform or outside the screen are destroyed
-cartriges that pops from the gun have physics behavior and destroy outside the screen. 10 max on screen
-each enemy hit adds 15 to cash max = 5000
-a wave system, a spawning system
some power ups
-etc but the above has the most code
is it ok to lag from this?
i can post my project if requested
Like this it’s hard to know what cause lag, assuming it depends on the device you use to test it (mobile ? desktop ?).
It can’t be a lack of optimisation on graphism (sprites too big, png not optimized), too many images in animations, etc. It can be linked to collisions too.
On the events, you may have a lot of events that can be executed only one time instead of x Times/frame : i mean try to add “run once” condition on each event wich need only one trigger.
Tell us more, or show it running somewhere, that might help. Notice that i’m not familiar to HTML5 platform, maybe there are others reasons.
sprites were 16 by 16 and upscaled them to 48 by 48 because i’ll be using html5 and android devices and i can’t disable smooth image.
i’m testing the project on a laptop, an old asus rog 2ghz core 2 duo, but it shouldn’t lag.
i’ve done state machines for all entities to spread the load into states.
it doesn’t lag terrible, only spikes of lag and i haven’t noticed something that might cause it, no pattern.
i’ve almost finished the prototype and it killed me before polish, adding decorative stuff and finishing the project… (
also how do i handle double jump and wall jump? - Solved it
i tried but i can’t wrap my head around it… i’m used to button pressed/helled/releassed.
and whats the best way to use trigger once event? i’m using it as a sub event. can’t it be used with another function in the main condition? - Solved it
what’s the most efficient way to check if an object is on screen? i mean if an enemy is not on screen it’ll won’t be active Lag.zip (158 KB)