Help me make my algorithm more efficient

0 favourites
  • 4 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I have a grid like this:

    I want to add a behavior so that when i mouse over a square, it blurs like this:

    The way I am doing it now is basically:

    "If mouse is over square -> Set Blur enabled"

    "if mouse is not over square-> set blur disabled"

    I'm fairly certain I understand why this algorithm is inefficient, but I can't think of a better way to do it. I would really appreciate some suggestions on this specific issue and general tips for algorithm efficiency and maybe some pitfalls to look out for (like not continuously enumerating over long lists )

  • instead of using the is not over you could use an else statement..

    I'm not sure isf the blur is an effect or just a frame of an animation..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's an effect, not a frame - I figured the computing cost for enabling/disabling an effect would be small, or at least not much more than changing a frame.

  • Sounds like you are using individual sprites, so depending on the size of your grid any event that works with these sprites will need to check each of them, so if you have a large grid it will eventually kill performance as you add more and more events and actions to your game.

    Depending on your game and what these tiles are used for, you might consider switching to using a tilemap object instead, and just use 2 different images. 1 which is grey and the other that looks blurry. And then you just switch the frame whenever you mouse is over one of them. Think that would make you able to do it pretty much without any performance drop and with a much larger grid than you can have with sprites.

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