# How do I set biggest value between two overlapping objects

Get help using Construct 2

### » Sun May 24, 2015 12:38 pm

Hello everyone. Lately I'm trying to develop this game where the HSL of the screen changes depending on the distance the character is from certain objects.
Like light bulbs, if the player is close to them the HSL it set to 100 and the screen get bright and colorful, if the player is far from them the screen gets gradually darker and in black and white.

The problem here is, sometimes the player is really close to one of those light bulbs but the screen gets too dark because he is really far away from another one.

Is there any way I can determine which of the actives light bulbs will have the higher HSL before setting it?
I tried to set only the higher HSL but then after the HSL reaches 100 it never goes down again so I'm kind of lost.

Thank you guys for the assistance o/
B
17
S
7
Posts: 280
Reputation: 2,522

### » Sun May 24, 2015 1:52 pm

i have used opacity in example... capx> http://s000.tinyupload.com/index.php?fi ... 5810331358

If this did not help,please upload capx...
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,104

### » Sun May 24, 2015 4:17 pm

Dude! This helped A LOT!

A didn't knew about the function get nearest, this completely solved the problem. Thank you very much.

Also, I didn't knew about the function distance, I was calculating the distance mathematically you know?
sqrt( (player.x - bulb.x)^2 + (player.y - bulb.y)^2 )

You not only solved my problem but you also helped me to clean my code and make it simpler.

Thank you, thank you very much
B
17
S
7
Posts: 280
Reputation: 2,522