• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Drawing a shrinking circle the closer you are to a target

XD005

Member
Code:
if (dir=0)
{
draw_set_color(c_white);
draw_set_alpha(0.50);
draw_circle(x+sprite_width/2,y+sprite_height/2,clamp(90-(90*((room_width-x-32)/1120)),0,90),false);
draw_set_alpha(1);
}
else
{
draw_set_color(c_white);
draw_set_alpha(0.50);
draw_circle(x+sprite_width/2,y+sprite_height/2,clamp(90-(90*(x/1120)),0,90),false);
draw_set_alpha(1);
}
draw_set_color(c_white);
draw_text(x+4,y+4,string(90-clamp((90*abs((32/-x))),0,90)))
Hello guys, so basically I have a circle that can either move to the left or to the right.
Basically dir0 is left (x-4 in step event), dir 1 is the opposite, moving to the right.
What I'm basically trying to do is draw a shrinking circle that shrinks completely to zero once the circle is in the proper position. When moving to the right, it needs to be at 1120, when moving to the left it needs to be at 32.
I can't figure out how to make it shrink correctly for direction 0.
 

TheSnidr

Heavy metal viking dentist
GMC Elder
How about:
Code:
draw_set_color(c_white);
draw_set_alpha(0.50);
if dir==0
{
    radius = abs(x - 32);
}
else
{
    radius = abs(1120 - x);
}
draw_circle(x + sprite_width / 2, y + sprite_height / 2, radius, false);
 

XD005

Member
How about:
Code:
draw_set_color(c_white);
draw_set_alpha(0.50);
if dir==0
{
    radius = abs(x - 32);
}
else
{
    radius = abs(1120 - x);
}
draw_circle(x + sprite_width / 2, y + sprite_height / 2, radius, false);
Thanks, this works perfectly. Much less confusing than my code too.
 
Top