Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //||---------------------------------------------------------------------------------------------------------||
- //||--||Task which creates a circular lifebar.||-------------------------------------------------------------||
- task Lifebar(Vertexes,Fillspeed,Maxhealth,Lifeadd,Version){
- //Vertexes - Amount of vertexes.
- //Fillspeed - How fast the lifebar fills up. Does not apply if Version is equal to 2.
- //Maxhealth - The health of the current single script.
- //Lifeadd - Offset to change the location the lifebar ends at.
- //Version - Version 0 is for fadein, 1 is for the first part of each phase and 2 for the other parts of each phase.
- HBobj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
- let HBimg = GetCurrentScriptDirectory ~ "Graphics/lifebar.png";
- let HBalpha = 0;
- let HBcounter = 0;
- if(Version==2){
- HBcounter=1;}
- let vertexcount = 0;
- LoadTexture(HBobj);
- ObjPrim_SetTexture(HBobj,HBimg);
- ObjSprite2D_SetDestCenter(HBobj);
- ObjPrim_SetPrimitiveType(HBobj,PRIMITIVE_TRIANGLESTRIP);
- ObjPrim_SetVertexCount( HBobj, (Vertexes-1)*2+2 );
- ascent(V in 0..Vertexes){
- ObjPrim_SetVertexUVT(HBobj,V*2,7,1);
- ObjPrim_SetVertexUVT(HBobj,V*2+1,12,1);
- ObjPrim_SetVertexPosition(HBobj,V*2,50*cos(V*360/(Vertexes-1)-90 ),50*sin(V*360/(Vertexes-1)-90 ), 0);
- ObjPrim_SetVertexPosition(HBobj,V*2+1,57*cos(V*360/(Vertexes-1)-90 ),57*sin(V*360/(Vertexes-1)-90 ), 0);
- }
- Obj_SetRenderPriorityI(HBobj,50);
- ObjRender_SetAngleY(HBobj,180);
- while(!Obj_IsDeleted(HBobj)){
- ObjRender_SetPosition(HBobj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
- if(HBcounter==0){
- if(vertexcount<Vertexes){
- loop(Fillspeed){
- ObjPrim_SetVertexUVT(HBobj,vertexcount*2,1,1);
- ObjPrim_SetVertexUVT(HBobj,vertexcount*2+1,6,1);
- vertexcount++;}
- }}
- if(vertexcount>=Vertexes){HBcounter=1;}
- if(HBcounter==1){
- ascent(c in 0..Vertexes){
- if( (ObjEnemy_GetInfo(objBoss,INFO_LIFE)+Lifeadd)>=( c*(Maxhealth/(Vertexes-1)) )){
- ObjPrim_SetVertexUVT(HBobj,c*2,1,1);
- ObjPrim_SetVertexUVT(HBobj,c*2+1,6,1);
- }
- if( (ObjEnemy_GetInfo(objBoss,INFO_LIFE)+Lifeadd)<( c*(Maxhealth/(Vertexes-1)) )){
- ObjPrim_SetVertexUVT(HBobj,c*2,7,1);
- ObjPrim_SetVertexUVT(HBobj,c*2+1,12,1);
- }
- }}
- if(GetPlayerX<ObjMove_GetX(objBoss)+60 && GetPlayerX>ObjMove_GetX(objBoss)-60 && GetPlayerY<ObjMove_GetY(objBoss)+60 && GetPlayerY>ObjMove_GetY(objBoss)-60){
- ascent(fade in 0..Vertexes){
- ObjPrim_SetVertexAlpha(HBobj,fade*2,155);
- ObjPrim_SetVertexAlpha(HBobj,fade*2+1,155);
- }}else{
- ascent(fade in 0..Vertexes){
- ObjPrim_SetVertexAlpha(HBobj,fade*2,255);
- ObjPrim_SetVertexAlpha(HBobj,fade*2+1,255);
- }}
- yield;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement