Conditions Constantly being Called

  • So in my game I have a condition that says,

         Player overlapping Fog

              do stuff

    Question I have is, is that a Resource Hog? I think it might be, let me explain.

    So If the player is in a Room (All Rooms have fog of same size of room) he would be triggering the above condition, so it is checking and/or doing stuff 60 times a second due to the Game Loop.

    so is that bad? Should I add a Trigger Once somewhere? What is the best approach where you need to test if Player is overlapping X and then have it do stuff, but you don't want it to consume all the resources, maybe have it check after player moves instead of constantly?

    thoughts.

    Thank you.

  • it depends on what are you trying to achieve? if you need the "do stuff" just 1 time you shuld restrict it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If the fog is like a rectangular area (i have 'zones' in my game), you can for each fog/zone check that the players x coordinate is between the fogs left and right edge x, and then the same for Y.

    I used to do it with overlap, but with a bunch of objects than can move between all the zones, it could slow down.

    the downsides are that the condition is met only when the players origin passes into the fog, also you can't rotate the fog without .. maths

  • Ashley, I agree totally with that article, it has actually helped me not be so picky in my code and just finish the project, but in this case I am not having those kinds of issues. I basically have a function that is constantly called, and 99% of the time no condition is met so I am calling it for no reason, in effect Memory Leak. I would think that could eventually drag down performance, like not killing sprites that go off screen, they will build up and eventually cause problems.

    keepee that is in effect what I am doing, but in stead of isPlayer within X/Y I just see if overlap. Not sure I see how between X/Y would really be different then onoverlap, can you explain a bit more? thank you.

  • jbmoyer - the whole point of that blog post is unless you can measure a performance impact, you are most likely wasting your time. Have you been able to measure that it affects performance in a significant way? Many events run surprisingly fast, so it may simply be of no concern at all - a totally insignificant impact on performance. It's also not a memory leak unless it keeps allocating more and more memory, which the ordinary use of events will never cause.

  • Ashley, ok I understand that is a great point, if it cant be measured, and/or you cant see any impact to the app MOVE ON! :) ok thank you, much appreciated. I am MOVING ON! :)

    Thanks

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