Stencyl 3.4.0 is now out. Get it now!

Malaika Princess : The game [PERFORMANCE HELP NEEDED ]

squeeb

  • Posts: 1079
i try not to use any updating except when necessary... i usually do a when created and then do every .1 seconds and run a few things there.. then ill do a different do every .x seconds and run a few things there... is that efficient?  im not really sure.. ive been trying to find a few different ways to keep the fps up near 60.. what do you guys think?

airman4

  • Posts: 828
It's efficient , for me at least
I only have two Always Block now

I cant use another way cause the always blocks are for the TIME

One for the time you do  and another for counting the overall time passed on my game

Now the Do always block have code like :


increment attrb number by stepsize/round of 1000  (for the time passed )

Calculate the distance (point of the game is to survive the longest , therefore make the biggest distance in km)
if nb attrib =0 (when you do nothing , normal glide )
increment attrb2 number by stepsize/round of 1000

if nb attrib =1  (when you speed up , your distance increase )
increment attrb2 number by stepsize/round of 11/10

if nb attrib =2 (when you slow )
increment attrb2 number by stepsize/round of 14/10

I may have to remove the when you slow

But yeah , i use only , when created , Do every now -> it seems to consume the less  out of the options we got


edit
Currently my build is very fluid
generally having 40 and 50 fps ! very happy*

I'd say i removed a lot of things and effects , unfortunetly , it's a flash game with an heavy gameplay (not super heavy but still )  so having huge backgrounds and too many things at screen is out of question so i removed many speed effects for example.

« Last Edit: March 06, 2017, 08:52:16 am by airman4 »

domagojbulat

  • *
  • Posts: 132
For my enemies' AI I made do each 0.1s block. It still does the job with 10 times less Frequency. I think that helps fps a bit.

airman4

  • Posts: 828
0.1 for every ?
Okay , mine every blocks generally are 0.0001
I'll try to test others less small numbers

domagojbulat

  • *
  • Posts: 132
Yes, like this following and running away behavior for enemy floaters. But I am pretty much a beginner, I am not sure if it helps a lot to improve FPS...

airman4

  • Posts: 828
Do always seems way more stronger than do every 0.1 , but how much i can't tell the frequency of a do always
But yeah avoid them , also try to add this code into a When created and then you add Do every to see if its improve


Today dev video gplay
You can ride on water , the heroine chinue made it into my 2009 anime
https://www.youtube.com/watch?v=j0AHYArVvU4
I was reluctant to do it but it would be illogical if we talk continuity (the game happens  some years after the anime )

squeeb

  • Posts: 1079
ive been trying to test this also.. ill do a when created event and do every .101 seconds.. and another one ill do .211 they wont ever run at the same time.. if you do  every .1 seconds.. and then do another do every .2 seconds.. every other run would execute the code in .2 at the same time as the .1 do every...  resulting in more process to be completed that run.. does that make sense?  and is it efficient.. anyone wanna test as well and let us know results ?

merrak

  • *
  • Posts: 1491
The resolution of time is .01 second, and "Do Always" is every .01 second. You can pull these values from the Engine.hx file and even modify them if you want to (see the definition of STEP_SIZE).

squeeb

  • Posts: 1079
good to know! thank you..do always is 100 times per second? .01.. and when created do every .1 would be executed 10 times per second?

domagojbulat

  • *
  • Posts: 132
Yes! And I think your strategy for different triggering times is good. I thought of such sollution too, but didn't need it yet. It should help fps i think

squeeb

  • Posts: 1079
I've noticed when I accidently had 2 different do every .x seconds events hit on the same time..  with setting attributes  or if else statements ect...   .1.  And a .3 seemed that it would cause a hiccup every .3 seconds.. probably from both executing extensive code at the same time.. caused a drop in framerate and lag... but only when I added too many things into each  do every x seconds section.. that's why I started splitting them on way off times...  example.  .103 seconds... I wish I knew how long it took to execute a section of code or if this was a good practice

airman4

  • Posts: 828
Nice find , i'll change my code according to it and see if it works cause yeah i still have some crazy dips

I have also a ton of RANDOM INTEGRER in do after or every
codes like that

do every or do after
set xspeed to random integrer 15 and 35
push self gently to dir 1 , y 0 , random integrer 15 and 35

I have also many do after random integrer 0.5 and 1.5 for example

Does this lead to massive dips ?

airman4

  • Posts: 828
Another one for helping the framerate
It seems using stuff like
Apply effect (on a long time)
and set blend mode for self or esle to... are killing the framerate !
I removed several of them and it's way better now

Now i wonder if the blend effect of the layers (blend mode ) have any effect on the framerate too


airman4

  • Posts: 828
2 minutes gameplay !

https://www.youtube.com/watch?v=x_sAKLfVVOg

Still in wip the beginning of the endless mini game is to avoid , i added some houses to test on xd (forgot to remove them )

KramerGames

  • Posts: 403
looks like some pretty mad action, I'm looking forward to playing this!
Parasites United  (Idle Parasite Game)