Advertisement
Guest User

Lifebar Effect

a guest
Sep 24th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. //||---------------------------------------------------------------------------------------------------------||
  2. //||--||Task which creates a circular lifebar.||-------------------------------------------------------------||
  3.  
  4. task Lifebar(Vertexes,Fillspeed,Maxhealth,Lifeadd,Version){
  5.  
  6. //Vertexes - Amount of vertexes.
  7. //Fillspeed - How fast the lifebar fills up. Does not apply if Version is equal to 2.
  8. //Maxhealth - The health of the current single script.
  9. //Lifeadd - Offset to change the location the lifebar ends at.
  10. //Version - Version 0 is for fadein, 1 is for the first part of each phase and 2 for the other parts of each phase.
  11.  
  12. HBobj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
  13. let HBimg = GetCurrentScriptDirectory ~ "Graphics/lifebar.png";
  14.  
  15. let HBalpha = 0;
  16. let HBcounter = 0;
  17.  
  18. if(Version==2){
  19. HBcounter=1;}
  20.  
  21. let vertexcount = 0;
  22.  
  23. LoadTexture(HBobj);
  24. ObjPrim_SetTexture(HBobj,HBimg);
  25. ObjSprite2D_SetDestCenter(HBobj);
  26.  
  27. ObjPrim_SetPrimitiveType(HBobj,PRIMITIVE_TRIANGLESTRIP);
  28.  
  29. ObjPrim_SetVertexCount( HBobj, (Vertexes-1)*2+2 );
  30.  
  31. ascent(V in 0..Vertexes){
  32.  
  33. ObjPrim_SetVertexUVT(HBobj,V*2,7,1);
  34. ObjPrim_SetVertexUVT(HBobj,V*2+1,12,1);
  35.  
  36. ObjPrim_SetVertexPosition(HBobj,V*2,50*cos(V*360/(Vertexes-1)-90 ),50*sin(V*360/(Vertexes-1)-90 ), 0);
  37. ObjPrim_SetVertexPosition(HBobj,V*2+1,57*cos(V*360/(Vertexes-1)-90 ),57*sin(V*360/(Vertexes-1)-90 ), 0);
  38.  
  39. }
  40.  
  41. Obj_SetRenderPriorityI(HBobj,50);
  42.  
  43. ObjRender_SetAngleY(HBobj,180);
  44.  
  45. while(!Obj_IsDeleted(HBobj)){
  46.  
  47.  
  48. ObjRender_SetPosition(HBobj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
  49.  
  50. if(HBcounter==0){
  51. if(vertexcount<Vertexes){
  52. loop(Fillspeed){
  53. ObjPrim_SetVertexUVT(HBobj,vertexcount*2,1,1);
  54. ObjPrim_SetVertexUVT(HBobj,vertexcount*2+1,6,1);
  55. vertexcount++;}
  56. }}
  57.  
  58. if(vertexcount>=Vertexes){HBcounter=1;}
  59.  
  60.  
  61.  
  62. if(HBcounter==1){
  63. ascent(c in 0..Vertexes){
  64.  
  65. if( (ObjEnemy_GetInfo(objBoss,INFO_LIFE)+Lifeadd)>=( c*(Maxhealth/(Vertexes-1)) )){
  66. ObjPrim_SetVertexUVT(HBobj,c*2,1,1);
  67. ObjPrim_SetVertexUVT(HBobj,c*2+1,6,1);
  68. }
  69.  
  70. if( (ObjEnemy_GetInfo(objBoss,INFO_LIFE)+Lifeadd)<( c*(Maxhealth/(Vertexes-1)) )){
  71. ObjPrim_SetVertexUVT(HBobj,c*2,7,1);
  72. ObjPrim_SetVertexUVT(HBobj,c*2+1,12,1);
  73. }
  74.  
  75. }}
  76.  
  77.  
  78.  
  79. if(GetPlayerX<ObjMove_GetX(objBoss)+60 && GetPlayerX>ObjMove_GetX(objBoss)-60 && GetPlayerY<ObjMove_GetY(objBoss)+60 && GetPlayerY>ObjMove_GetY(objBoss)-60){
  80. ascent(fade in 0..Vertexes){
  81. ObjPrim_SetVertexAlpha(HBobj,fade*2,155);
  82. ObjPrim_SetVertexAlpha(HBobj,fade*2+1,155);
  83. }}else{
  84. ascent(fade in 0..Vertexes){
  85. ObjPrim_SetVertexAlpha(HBobj,fade*2,255);
  86. ObjPrim_SetVertexAlpha(HBobj,fade*2+1,255);
  87. }}
  88.  
  89.  
  90.  
  91. yield;
  92. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement