• 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!

GML Drawing a partial circle

I

IceNineOcean

Guest
In a game I'm making, I want to have a gui timer element similar to the little energy circles used in Breath of the Wild; it starts as a full circle, and as it counts down, the circumference is opened, kinda like a clock. A solution I've come up with is the following:
Code:
//x,y are center coordinates
//len is radius
//angle is the calculated current angle of the timer, scaled between 450 and 90, where 450 is the starting time, 90 is 0

for (var i = angle; i>91; i--) {
        draw_line(x+lengthdir_x(len, i), y+lengthdir_y(len, i), x+lengthdir_x(len, i-1), y+lengthdir_y(len, i-1));
}
Is there a better way to do this and not include potentially 360 runs of a loop every single frame? I guess i could decrement by more than 1 and lose resolution on the circle, but that's still a lot of looping.
 
I

IceNineOcean

Guest
Looks helpful, I'll check it out once I'm back at my computer.
 
Top