Help me make my algorithm more efficient

Get help using Construct 2

Post » Tue Sep 23, 2014 4:11 pm

I have a grid like this:
Image

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

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 ;) )
B
5
S
1
Posts: 11
Reputation: 397

Post » Tue Sep 23, 2014 4:29 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Sep 23, 2014 5:27 pm

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.
B
5
S
1
Posts: 11
Reputation: 397

Post » Wed Sep 24, 2014 2:30 am

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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests