Mewkyuu

Untitled

Aug 25th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.52 KB | None | 0 0
  1. // First we define some variables for us to use. ///////////////
  2.  
  3. let BossDraw_frame = 0; // counter for setting graphic rects
  4. let BossDraw_next = 5; // time to wait until setting the next set of rects
  5. let BossFrame_IDLE = 0; // counter used to set the graphic rects of boss's idle animation
  6. let BossFrame_SPELL = 0; // counter used to set the graphic rects of boss's spellcard animation
  7. let BossFrame_SHOOT = 0; // counter used to set the graphic rects of boss's bullet shooting animation
  8. let BossFrame_MOVE = 0; // counter used to set the graphic rects of boss's moving animation
  9. let BossDraw_mode = 0; // action that the boss is doing at the moment
  10. let BossMode_IDLE = 0; // 0 = idle
  11. let BossMode_SPELL = 1; // 1 = spell casting
  12. let BossMode_SHOOT = 2; // 2 = regular shot
  13. let BossMode_MOVE = 3; // 3 = moving
  14. let BossDraw_rectpair = [0,0]; // graphic rects to set
  15. let BossDraw_count = 0; // countdown until end of animation
  16.  
  17. let ACT_IDLE_0 = 0; // Idle animation 0: no movement
  18. // < 1 >
  19. let ACT_IDLE_1 = 1; // Idle animation 1: loop frames 1 to 3
  20. // < 1, 2, 3 >
  21. let ACT_IDLE_2 = 2; // Idle animation 2: loop frames 1 to 4
  22. // < 1, 2, 3, 4 >
  23. let ACT_IDLE_3 = 3; // Idle animation 3: loop frames 1-3 3 times, then use frame 4 as a blinking animation frame
  24. // < [(x3) 1, 2, 3] 4 >
  25. let ACT_IDLE_4 = 4; // Idle animation 4: loop through the first three frames 3 times, then use frame 4 as a blinking animation frame
  26. // < [(x3) 1, 2, 1, 3] 4 >
  27. let ACT_SPELL_0 = 0; // Spell casting animation 0: play through frames until end of animation, freeze at frame 4, then finish with playing frame 2
  28. // < 1, 2, 3, [ 4 ] 2 >
  29. let ACT_SPELL_1 = 1; // Spell casting animation 1: play through, loop frames 3/4, end with frame 2
  30. // < 1, 2, [ 3, 4 ] 2 >
  31. let ACT_SHOOT_0 = 0; // Bullet shooting animation 0: play through frames until end of animation, freeze at frame 4, then finish with playing frame 2
  32. // < 1, 2, 3, [ 4 ] 2 >
  33. let ACT_SHOOT_1 = 1; // Bullet shooting animation 1: play through, loop frames 3/4, end with frame 2
  34. // < 1, 2, [ 3, 4 ] 2 >
  35. let ACT_MOVE_0 = 0; // Moving animation 0: play through frames 1/2, freeze at frame 3, finish by playing backwards
  36. // < 1, 2, [ 3 ] 2, 1 >
  37. let ACT_MOVE_1 = 1; // Moving animation 1: play through frames 1/2, switch between frames 3/4, finish by playing backwards
  38. // < 1, 2, [ 3, 4 ] 3, 2, 1 >
  39. let ACT_IDLE = 0; // Default idle animation ID is 0.
  40. let ACT_SPELL = 0; // Default spell casting animation ID is 0.
  41. let ACT_SHOOT = 0; // Default bullet shooting animation ID is 0.
  42. let ACT_MOVE = 0; // Default moving animation ID is 0.
  43. let BossDraw_anilimit = [ // Alright, so we're going to have to set the frames when the boss animations reset. Ready, set, go!
  44. [1, 3, 4, 10, 12], // Idle frames
  45. [5, 5], // Spell casting frames
  46. [5, 5], // Bullet shooting frames
  47. [4, 5], // Moving frames
  48. ];
  49. ACT_IDLE = ACT_IDLE_4;
  50. ACT_SPELL = ACT_SPELL_1;
  51. ACT_SHOOT = ACT_SHOOT_1;
  52. ACT_MOVE = ACT_MOVE_1;
  53.  
  54. function SetBossAnimeAction(BossDraw_modeNew, BossModeUsageTime) { BossDraw_mode = BossDraw_modeNew; BossDraw_count = BossModeUsageTime; }
  55. // Wahahaha. Here's a function for easily making the boss use different sprite animations.
  56.  
  57.  
  58. // Now we make the actual task! ////////////////////////////////
  59.  
  60. task BossSpriteDraw(BossEnemyID, bossspritetexture) { // Here we go!
  61. ObjPrim_SetTexture(BossEnemyID, bossspritetexture); // First we set the boss texture so Danmakufu has an image to work with.
  62. while(!Obj_IsDeleted(BossEnemyID)) { // We need to make sure this stuff happens every frame while the boss exists, so we put this here.
  63. // By the way, this task ends once the boss is deleted.
  64. let angle = ObjMove_GetAngle(BossEnemyID); // This makes it so that when the boss moves, the image we're using should be flipped to match the boss's movement.
  65. if(BossDraw_mode != 3) { // Of course, when the boss ISN'T moving, we're setting the boss's image to be facing the right way.
  66. ObjRender_SetAngleY(BossEnemyID, 0);
  67. } else { // But when the boss IS moving, we're going to have to do some special stuff to do make the boss look like it's moving the right way.
  68. if(cos(angle) < 0) { ObjRender_SetAngleY(BossEnemyID, 0); } // the boss is leaning to the left
  69. else { ObjRender_SetAngleY(BossEnemyID, 180); } // the boss is leaning to the right
  70. }
  71. if(BossDraw_frame == 0){ // Ok, so this is what we're going to be using to make the boss look like it's doing something.
  72. alternative(BossDraw_mode) // Your mission starts now! Are you ready?
  73. case(BossMode_IDLE) { // Ok, first we set what happens when the boss is idle.
  74. alternative(ACT_IDLE) // Alright, since we have different types of idle animation, we make different animation codes for each.
  75. case(ACT_IDLE_0, ACT_IDLE_1, ACT_IDLE_2) { // Idle animations 0, 1, and 2 have similar coding, so we'll group them all into one like this.
  76. alternative(BossFrame_IDLE) // Here we make the boss use different sprites at different times.
  77. case(0) { BossDraw_rectpair=[0,0]; } // frame 0
  78. case(1) { BossDraw_rectpair=[1,0]; } // frame 1
  79. case(2) { BossDraw_rectpair=[2,0]; } // frame 2
  80. case(3) { BossDraw_rectpair=[3,0]; } // frame 3
  81. }
  82. case(ACT_IDLE_3) { // Idle animations 3 and 4 are sorta different, so I'll just code in animation 3 for now.
  83. alternative(BossFrame_IDLE) // Same stuff from just above applies to here, nothing different, sorta.
  84. case(0,3,6) { BossDraw_rectpair=[0,0]; } // frame 0
  85. case(1,4,7) { BossDraw_rectpair=[1,0]; } // frame 1
  86. case(2,5,8) { BossDraw_rectpair=[2,0]; } // frame 2
  87. case(9) { BossDraw_rectpair=[3,0]; } // frame 3
  88. }
  89. case(ACT_IDLE_4) { // Finally, we code idle animation 4. That wasn't so bad, was it?
  90. alternative(BossFrame_IDLE) // Same thing as above, just even more different.
  91. case(0,2,4,6,8) { BossDraw_rectpair=[0,0]; } // frame 0
  92. case(1,5,9) { BossDraw_rectpair=[1,0]; } // frame 1
  93. case(3,7,11) { BossDraw_rectpair=[2,0]; } // frame 2
  94. case(10) { BossDraw_rectpair=[3,0]; } // frame 3
  95. }
  96. BossFrame_IDLE++; // We put this here so that the animation will actually work.
  97. BossFrame_IDLE%=BossDraw_anilimit[BossMode_IDLE][ACT_IDLE]; // This makes it so that the boss's animation loops once it's over.
  98. } // And we're done the idle animation process.
  99. case(BossMode_SPELL) { // Onto the spell casting animation part!
  100. alternative(ACT_SPELL) // We shouldn't have any problems with the coding now that we've done all that from above, right?
  101. case(ACT_SPELL_0, ACT_SPELL_1) { // Idle animations 0, 1, and 2 have similar coding, so we'll group them all into one like this.
  102. alternative(BossFrame_SPELL) // I'll stop putting these comments so you can just read it properly.
  103. case(0) { BossDraw_rectpair=[0,1]; }
  104. case(1) { BossDraw_rectpair=[1,1]; }
  105. case(2) { BossDraw_rectpair=[2,1]; }
  106. case(3) { BossDraw_rectpair=[3,1]; }
  107. }
  108. if(BossDraw_count>1){
  109. BossFrame_SPELL++;
  110. if(BossFrame_SPELL>4){BossFrame_SPELL-=2+ACT_SPELL;} // I'm adding this here so that it makes the boss sprite loop between the two frames.
  111. BossFrame_SPELL%=BossDraw_anilimit[BossMode_SPELL][ACT_SPELL];
  112. } else {
  113. alternative(BossDraw_count)
  114. case(0) { BossDraw_rectpair=[0,1]; // Here we override the selection of graphic rects.
  115. BossDraw_mode=BossMode_IDLE; } // Of course, once we finish the ending animation, we go back to being idle.
  116. case(1) { BossDraw_rectpair=[1,1]; } // But since it takes time to finish the animation, we do this other stuff.
  117. case(2) { BossDraw_rectpair=[2,1]; }
  118. }
  119. } // I won't be commenting so much for the next two sections as we already know how to do all this.
  120. case(BossMode_SHOOT) { // But anyways, onto the "bullet shooting animation" section.
  121. alternative(ACT_SHOOT) // I think I'm just going to blatantly copy-paste the code from the spellcard casting section since it's all the same, as I decided it to be.
  122. case(ACT_SHOOT_0, ACT_SHOOT_1) {
  123. alternative(BossFrame_SHOOT)
  124. case(0) { BossDraw_rectpair=[0,2]; }
  125. case(1) { BossDraw_rectpair=[1,2]; }
  126. case(2) { BossDraw_rectpair=[2,2]; }
  127. case(3) { BossDraw_rectpair=[3,2]; }
  128. }
  129. if(BossDraw_count>1){
  130. BossFrame_SHOOT++;
  131. if(BossFrame_SHOOT>4){BossFrame_SHOOT-=2+ACT_SHOOT;}
  132. BossFrame_SHOOT%=BossDraw_anilimit[BossMode_SHOOT][ACT_SHOOT];
  133. } else {
  134. alternative(BossDraw_count)
  135. case(0) { BossDraw_rectpair=[0,2];
  136. BossDraw_mode=BossMode_IDLE; }
  137. case(1) { BossDraw_rectpair=[1,2]; }
  138. case(2) { BossDraw_rectpair=[2,2]; }
  139. }
  140. }
  141. case(BossMode_MOVE) {
  142. alternative(ACT_MOVE)
  143. case(ACT_MOVE_0, ACT_MOVE_1) {
  144. alternative(BossFrame_MOVE)
  145. case(0) { BossDraw_rectpair=[0,3]; }
  146. case(1) { BossDraw_rectpair=[1,3]; }
  147. case(2) { BossDraw_rectpair=[2,3]; }
  148. case(3) { BossDraw_rectpair=[3,3]; }
  149. }
  150. if(BossDraw_count>(2+ACT_MOVE)){
  151. BossFrame_MOVE++;
  152. if(BossFrame_MOVE>2+ACT_MOVE){BossFrame_MOVE-=1+ACT_MOVE;}
  153. BossFrame_MOVE%=BossDraw_anilimit[BossMode_MOVE][ACT_MOVE];
  154. } else {
  155. alternative(BossDraw_count)
  156. case(0) { BossDraw_rectpair=[0,3]; BossDraw_mode=BossMode_IDLE; }
  157. case(1) { BossDraw_rectpair=[1,3]; }
  158. case(2) { BossDraw_rectpair=[2,3]; }
  159. case(3) { BossDraw_rectpair=[3,3]; }
  160. }
  161. }
  162. if(BossDraw_count>0){BossDraw_count-=BossDraw_next;} // We're going to make the boss use certain sprites at the end of some animations so we'll use this to make stuff happen.
  163. if(BossDraw_count<0){BossDraw_count=0;}
  164. } // Part 1 complete.
  165. ObjSprite2D_SetSourceRect(BossEnemyID, // Now we need to actually make the boss's sprites appear.
  166. BossDraw_rectpair[0]*128, BossDraw_rectpair[1]*128, // First the top left corner...
  167. BossDraw_rectpair[0]*128+128, BossDraw_rectpair[1]*128+128); // And then the bottom right corner. Wuzzah!
  168. ObjSprite2D_SetDestCenter(BossEnemyID); // And we're really done now!
  169. BossDraw_frame++; BossDraw_frame%=BossDraw_next; // Oh by the way, we can't have the animation function actually start working without this, can we?
  170. yield; // Finally, the yield so we can make it all work.
  171. } // Mission complete! Thank you for your reading!
  172. }
Advertisement
Add Comment
Please, Sign In to add comment