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:
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.
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));
}