0 Favourites

Improving Performance in Auto Runner

  • Hey Developers,

    The project I'm working on includes an auto runner game. What are some keys ways to get 40+ fps on the layout?

    My game isnt really heavy demanding when it comes to GPU but it seems to take alot of CPU & Draw Calls at like 75%. I've tried using "60 * dt" on everything that moves in the layout but I cant seem to get any higher than 17 fps. I'm destroying platforms that are less than -Self.Width.

    I'm testing on a blackberry z10 which has webgl already in the browser.

    Is there something I can add to the xml or index.html?

    C2 is a powerful engine, I feel like 40+ fps in auto runner should be doable with webgl I just cant pin point exactly what I'm doing wrong or overlooking

  • Preview in debug mode, then check profile for cpu load %

    You can easily spot which piece is sluggish

  • Without capx, it's really hard to help.. Check collisions, game logic etc.

  • Its weird cause while debugging with Webgl "Off" (With game running in canvas2D) I get the fps that I'm looking for (40-60) but the game will crash even tho not a whole lot is going on cpu wise (stays under 30%). The Blackberry Z10 comes with web gl integrated but if the game didn't crash so much in canvas 2D I would of just stuck with that because of the higher frame rate.

    With webgl on I get about 18-20 fps the most but the frames are always jumping & dropping so its not consistent.

    I'm testing on a BB 10 device, I think the low frame rate may have to do with the many global variables active while the layout runs. In the Auto Runner I'm having frame issues with, I'll use variables to account for the platforms speed and its color ( since tiled background don't have animation sequences I created my own way of changing platform colors as the player progresses in distance traveled.)

    The global variables are always active and may be the reason for a high Draw Calls percent, so if I could use instance variables to account for things like platform speed & color that might help me improve the frame rate.

    My Goal is to make an auto runner that gets 40+ fps and has accelerating platforms that's color changes as the total distance traveled increases. I've been able to do everything but get the 40+ fps WITH WEB GL ON. I'll try to convert as many global variables down to instance variables as possible and if I get any luck with that I will let yall know.

  • EyezWidee, try to limit the number of top-level actions, because those are being checked every tick.

    One of the performance measures I've added into my game was using the System condition "Every x seconds". Then, I put many things as sub-events under that. For example you can put at least the following as subconditions to "Every 0.2 seconds":

    • Update the score on screen
    • Check for player falls out of bounds
    • Destroy blocks that go off screen.

    This is much more efficient than every tick.

  • I am going to try that today, it makes sense that not all actions need to be checked every tick. Also I didn't think about how sub-events could help performance as oppose to having a bunch of actions taking place every tick including score which goes into local storage.

    So I'm guessing there's not much of a difference, performance-wise, in having instance variable account for things like accelerating platforms or having global variables account for those things.

    I also have a Block color variable that allows me to change the color sequence of platforms since they are tiled backgrounds with no animation sequences built in like sprites.

    Thanks again I'll def try out your method danialgoodwin

  • It worked! danialgoodwin

    • Best Regards
  • It worked! danialgoodwin

    - Best Regards

    Happy to hear it! By the way, I'm glad you checked the FPS before doing these changes. So, what's your FPS now?

  • I get different fps in debug mode. If it on inspect then the fps is 20+ with low CPU%, when on Watch or Profile I get 45+ fps.

    Not sure which tab is the most accurate but if I just run the layout without debugging it looks like 40+ fps

    Do you happen to know why the fps changes between Inspect , Watch , Profile (While in Debug mode) ?

    If I had to guess Inspecting requires checking all conditions every tick.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I just checked within the layout by using text & setting it to display fps.I get 30+ which playable. If I made a few more tweaks I might be able to get to stay 40+

  • Do you happen to know why the fps changes between Inspect , Watch , Profile (While in Debug mode) ?

    If I had to guess Inspecting requires checking all conditions every tick.

    I suspect that you are right. The system does have to do a lot more in order to show all those debugging values. So, the most accurate/important is how it runs for the user. In some of my games, I like to create a keyboard event to toggle showing FPS. I think it is a good practice when developing games.

  • Wow! Just stumbled upon this post, and have to say thanks danialgoodwin! I was thinking of how to increase the framerates and decrease collision checks of my game and this sounds like the perfect thing to try! Huhu can't wait to test it out!

  • Makes sense, so its pretty safe to say that I got from 18 fps to 35+ with your help. It runs way smoother now, gotta admit this was a tough obstacle for me so I thank you again danialgoodwin and wish you the best of success with your games.

  • In some of my games, I like to create a keyboard event to toggle showing FPS. I think it is a good practice when developing games.

    IE 11 has the FPS view and CPU usage build in :)

    CTRL + SHIFT + U

    Perhaps not the best browser to test in, but if you have a web app/game that should be compatible with IE, IEs option has majorly advanced and this will give a good ndication.

    This way your app will show a more precise FPS on actual running apps .... for IE at least haha. (ofc results will differ comparing to other browsers)

    It also has the option to test repsonse time of user interface options through the web dev console. Also profiling options.

  • IE 11 has the FPS view and CPU usage build in :)

    CTRL + SHIFT + U

    Thanks for the tip! I didn't know about that. Recently, I've mainly been building for Windows 8 and Window Phone, so it should be handy. =]

    I'm glad I could help others too. ;)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)