GML Drawing a partial circle

Discussion in 'Programming' started by IceNineOcean, Sep 9, 2019.

  1. IceNineOcean

    IceNineOcean Member

    Joined:
    May 19, 2019
    Posts:
    3
    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.
     
  2. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    975
    IceNineOcean likes this.
  3. IceNineOcean

    IceNineOcean Member

    Joined:
    May 19, 2019
    Posts:
    3
    Looks helpful, I'll check it out once I'm back at my computer.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice