GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2016-07-01 07:59:30

omar
Member
Registered: 2016-06-23
Posts: 8

draw_healthbar_circular()

customize your own circular progress bar

Expand/// draw_healthbar_circular(Prec,X,Y,Amount,Rot,Rad1,Rad2)
/// GMLscripts.com/license

var Prec,A,B,X,Y,Pos,Rot,Rad1,Rad2,N;
Prec=abs(argument0);            //Precision
X=argument1;                    //x position
Y=argument2;                    //y position
Pos=Prec*(argument3/100);       //amount (0 - 100)
Rot=argument4;                  //rotation
Rad1=argument5;                 //radius 1
Rad2=argument6;                 //radius 2

draw_primitive_begin(pr_trianglestrip)
for(N=0; N>=-Pos; N-=1)
{
    A=X+lengthdir_x(Rad1,Rot+360*N/Prec);
    B=Y+lengthdir_y(Rad1,Rot+360*N/Prec);
    draw_vertex(A,B);
    
    A=X+lengthdir_x(Rad2,Rot+360*N/Prec);
    B=Y+lengthdir_y(Rad2,Rot+360*N/Prec);
    draw_vertex(A,B);
}
draw_primitive_end();

example :

Expanddraw_set_color(c_dkgray)
draw_healthbar_circular(45,mouse_x,mouse_y,100,90,100,110)
draw_set_color(c_orange)
draw_healthbar_circular(45,mouse_x,mouse_y,70,90,102,108)

the rotation direction is clockwise

if you want to make a waiting (loading) progress bar set Amount to static value (50 for example) and change the Rot value from 0 to 360 to make a loop

you can also use this script to draw a regular polygon width line by setting the Precision to the number of sides, or filled polygon by setting Rad1 or Rad2 to 0

Last edited by omar (2016-07-01 11:30:29)

Offline

#2 2016-07-02 05:54:30

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: draw_healthbar_circular()

Thanks for another useful script.


Abusing forum power since 1986.

Offline

Board footer

Powered by FluxBB