G
Gabriel
Guest
So, I'm kind of having a math trouble to create a simple effect (let's call it so) in my game.
When the player is wearing this x-ray specs, I want a hidden arrow to show up, indicating the path to a secret area.
There are two conditions, though:
- The player can only see the arrow if he's close to it, therefore, the arrow opacity must change as he gets closer or farther.
- When the distance player - - - arrow is equal or less than 200 (pixels), the arrow must be completely opaque.
For that, I've used the following code in the arrow's draw event:
But I don't want the arrow to appear out of nowhere. Instead, it should appear gradually as the player approaches the point which is 200px farther from the arrow.
How can I add an else statement for that to happen? I can't quite figure which formula to use, so the opacity lowers as the player departs...
When the player is wearing this x-ray specs, I want a hidden arrow to show up, indicating the path to a secret area.
There are two conditions, though:
- The player can only see the arrow if he's close to it, therefore, the arrow opacity must change as he gets closer or farther.
- When the distance player - - - arrow is equal or less than 200 (pixels), the arrow must be completely opaque.
For that, I've used the following code in the arrow's draw event:
Code:
///Draw Self According to Ghost Distance
var op = 0;
if ghost.xray == true
{
if distance_to_object(ghost) <= 200
{
var op = 1;
}
}
draw_sprite_ext(sprite_index, 0, x, y, 1, 1, 0, c_white, op);
How can I add an else statement for that to happen? I can't quite figure which formula to use, so the opacity lowers as the player departs...
Last edited by a moderator: