Mewkyuu

Untitled

Jan 24th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.19 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.  
  50. function SetBossAnimation(BossDraw_modeNew, BossModeUsageTime) { BossDraw_count = 0; BossDraw_mode = BossDraw_modeNew; BossDraw_count = BossModeUsageTime; }
  51. // Wahahaha. Here's a function for easily making the boss use different sprite animations.
  52.  
  53. function SetBossAnimeStyle(idle,spell,shoot,move) { ACT_IDLE = idle; ACT_SPELL = spell; ACT_SHOOT = shoot; ACT_MOVE = move; }
  54. // And this thing lets you choose how the boss animates.
  55.  
  56.  
  57. sub CreateBossAnimation { // Here we go!
  58. SetTexture(spr); // First we set the boss texture so Danmakufu has an image to work with.
  59. // Ok, so now we have the boss texture set.
  60. // We need to make sure this stuff happens every frame while the boss exists, so we put this here.
  61. let angle = GetSpeedX<0; // This makes it so that when the boss moves, the image we're using should be flipped to match the boss's movement.
  62. 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.
  63. SetGraphicAngle(0, 0, 0);
  64. } 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.
  65. if(angle) { SetGraphicAngle(0, 0, 0); } // the boss is leaning to the left
  66. else { SetGraphicAngle(180, 0, 0); } // the boss is leaning to the right
  67. }
  68. 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.
  69. alternative(BossDraw_mode) // Your mission starts now! Are you ready?
  70. case(BossMode_IDLE) { // Ok, first we set what happens when the boss is idle.
  71. alternative(ACT_IDLE) // Alright, since we have different types of idle animation, we make different animation codes for each.
  72. 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.
  73. alternative(BossFrame_IDLE) // Here we make the boss use different sprites at different times.
  74. case(0) { BossDraw_rectpair=[0,0]; } // frame 0
  75. case(1) { BossDraw_rectpair=[1,0]; } // frame 1
  76. case(2) { BossDraw_rectpair=[2,0]; } // frame 2
  77. case(3) { BossDraw_rectpair=[3,0]; } // frame 3
  78. }
  79. case(ACT_IDLE_3) { // Idle animations 3 and 4 are sorta different, so I'll just code in animation 3 for now.
  80. alternative(BossFrame_IDLE) // Same stuff from just above applies to here, nothing different, sorta.
  81. case(0,3,6) { BossDraw_rectpair=[0,0]; } // frame 0
  82. case(1,4,7) { BossDraw_rectpair=[1,0]; } // frame 1
  83. case(2,5,8) { BossDraw_rectpair=[2,0]; } // frame 2
  84. case(9) { BossDraw_rectpair=[3,0]; } // frame 3
  85. }
  86. case(ACT_IDLE_4) { // Finally, we code idle animation 4. That wasn't so bad, was it?
  87. alternative(BossFrame_IDLE) // Same thing as above, just even more different.
  88. case(0,2,4,6,8) { BossDraw_rectpair=[0,0]; } // frame 0
  89. case(1,5,9) { BossDraw_rectpair=[1,0]; } // frame 1
  90. case(3,7,11) { BossDraw_rectpair=[2,0]; } // frame 2
  91. case(10) { BossDraw_rectpair=[3,0]; } // frame 3
  92. }
  93. BossFrame_IDLE++; // We put this here so that the animation will actually work.
  94. BossFrame_IDLE%=BossDraw_anilimit[BossMode_IDLE][ACT_IDLE]; // This makes it so that the boss's animation loops once it's over.
  95. } // And we're done the idle animation process.
  96. case(BossMode_SPELL) { // Onto the spell casting animation part!
  97. alternative(ACT_SPELL) // We shouldn't have any problems with the coding now that we've done all that from above, right?
  98. 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.
  99. alternative(BossFrame_SPELL) // I'll stop putting these comments so you can just read it properly.
  100. case(0) { BossDraw_rectpair=[0,1]; }
  101. case(1) { BossDraw_rectpair=[1,1]; }
  102. case(2) { BossDraw_rectpair=[2,1]; }
  103. case(3) { BossDraw_rectpair=[3,1]; }
  104. }
  105. if(BossDraw_count>1){
  106. BossFrame_SPELL++;
  107. 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.
  108. BossFrame_SPELL%=BossDraw_anilimit[BossMode_SPELL][ACT_SPELL];
  109. } else {
  110. alternative(BossDraw_count)
  111. case(0) { BossDraw_rectpair=[0,1]; // Here we override the selection of graphic rects.
  112. BossDraw_mode=BossMode_IDLE; } // Of course, once we finish the ending animation, we go back to being idle.
  113. case(1) { BossDraw_rectpair=[1,1]; } // But since it takes time to finish the animation, we do this other stuff.
  114. case(2) { BossDraw_rectpair=[2,1]; }
  115. }
  116. } // I won't be commenting so much for the next two sections as we already know how to do all this.
  117. case(BossMode_SHOOT) { // But anyways, onto the "bullet shooting animation" section.
  118. 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.
  119. case(ACT_SHOOT_0, ACT_SHOOT_1) {
  120. alternative(BossFrame_SHOOT)
  121. case(0) { BossDraw_rectpair=[0,2]; }
  122. case(1) { BossDraw_rectpair=[1,2]; }
  123. case(2) { BossDraw_rectpair=[2,2]; }
  124. case(3) { BossDraw_rectpair=[3,2]; }
  125. }
  126. if(BossDraw_count>1){
  127. BossFrame_SHOOT++;
  128. if(BossFrame_SHOOT>4){BossFrame_SHOOT-=2+ACT_SHOOT;}
  129. BossFrame_SHOOT%=BossDraw_anilimit[BossMode_SHOOT][ACT_SHOOT];
  130. } else {
  131. alternative(BossDraw_count)
  132. case(0) { BossDraw_rectpair=[0,2];
  133. BossDraw_mode=BossMode_IDLE; }
  134. case(1) { BossDraw_rectpair=[1,2]; }
  135. case(2) { BossDraw_rectpair=[2,2]; }
  136. }
  137. }
  138. case(BossMode_MOVE) {
  139. alternative(ACT_MOVE)
  140. case(ACT_MOVE_0, ACT_MOVE_1) {
  141. alternative(BossFrame_MOVE)
  142. case(0) { BossDraw_rectpair=[0,3]; }
  143. case(1) { BossDraw_rectpair=[1,3]; }
  144. case(2) { BossDraw_rectpair=[2,3]; }
  145. case(3) { BossDraw_rectpair=[3,3]; }
  146. }
  147. if(BossDraw_count>(2+ACT_MOVE)){
  148. BossFrame_MOVE++;
  149. if(BossFrame_MOVE>2+ACT_MOVE){BossFrame_MOVE-=1+ACT_MOVE;}
  150. BossFrame_MOVE%=BossDraw_anilimit[BossMode_MOVE][ACT_MOVE];
  151. } else {
  152. alternative(BossDraw_count)
  153. case(0) { BossDraw_rectpair=[0,3]; BossDraw_mode=BossMode_IDLE; }
  154. case(1) { BossDraw_rectpair=[1,3]; }
  155. case(2) { BossDraw_rectpair=[2,3]; }
  156. case(3) { BossDraw_rectpair=[3,3]; }
  157. }
  158. }
  159. 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.
  160. if(BossDraw_count<0){BossDraw_count=0;}
  161. } // Part 1 complete.
  162. SetGraphicRect( // Now we need to actually make the boss's sprites appear.
  163. BossDraw_rectpair[0]*128, BossDraw_rectpair[1]*128, // First the top left corner...
  164. BossDraw_rectpair[0]*128+128, BossDraw_rectpair[1]*128+128); // And then the bottom right corner. Wuzzah!
  165. DrawGraphic(GetX,GetY); // And we're really done now!
  166. BossDraw_frame++; BossDraw_frame%=BossDraw_next; // Finally, we can't have the animation function actually start working without this, can we?
  167. } // Mission complete! Thank you for your reading!
Advertisement
Add Comment
Please, Sign In to add comment