Guest User

Hypocycloid 2

a guest
Feb 10th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. #TouhouDanmakufu
  2. #Title[Profielwerkstuk 1]
  3. #Text[(easy)]
  4. #Player[FREE]
  5. #ScriptVersion[2]
  6.  
  7. script_enemy_main{
  8.  
  9. let CSD = GetCurrentScriptDirectory;
  10.  
  11. let imgBoss = CSD ~ "img/Death Ball.png";
  12. let bg = CSD ~ "img/Stars.png";
  13.  
  14. let slide = 0;
  15.  
  16. @Initialize{
  17. SetLife(1000);
  18. SetTimer(60);
  19. SetScore(100000);
  20.  
  21. SetX(GetCenterX);
  22. SetY(GetClipMaxY/4);
  23.  
  24. LoadGraphic(imgBoss);
  25. LoadGraphic(bg);
  26.  
  27. CutIn(YOUMU,"Wind Bullets - easy -",imgBoss,0,0,100,100);
  28.  
  29. LoadMusic(CSD ~ "bgm\Bad Situation.mp3");
  30. PlayMusic(CSD ~ "bgm\Bad Situation.mp3");
  31.  
  32. mainTask;
  33.  
  34. }
  35.  
  36. @MainLoop{
  37. SetCollisionA(GetX,GetY,50);
  38. SetCollisionB(GetX,GetY,40);
  39.  
  40. yield;
  41. }
  42.  
  43. @DrawLoop{
  44.  
  45. SetTexture(imgBoss);
  46. SetRenderState(ALPHA);
  47. SetAlpha(255);
  48. SetGraphicRect(0,0,100,100);
  49. SetGraphicScale(1,1);
  50. SetGraphicAngle(0,0,0);
  51. DrawGraphic(GetX,GetY);
  52.  
  53. }
  54.  
  55. @BackGround{
  56.  
  57. SetTexture(bg);
  58. SetRenderState(ALPHA);
  59. SetAlpha(255);
  60. SetGraphicRect(0,0-slide,512,512-slide);
  61. SetGraphicScale(1,1);
  62. SetGraphicAngle(0,0,0);
  63. DrawGraphic(GetCenterX,GetCenterY);
  64.  
  65. slide +=2;
  66. }
  67.  
  68. @Finalize{
  69.  
  70. DeleteGraphic(imgBoss);
  71. DeleteGraphic(bg);
  72.  
  73.  
  74. }
  75.  
  76. //main task, activates stuff
  77. task mainTask{
  78. yield;
  79. //movement;
  80. hypocycloid1(GetEnemyX,GetEnemyY,100,0.7,0.8);
  81. hypocycloid2(GetEnemyX,GetEnemyY,100,0.7,0.8);
  82. }
  83.  
  84. task movement{
  85. wait(120);
  86. loop{
  87. SetMovePosition01(GetCenterX-100,120,5);
  88. wait(120);
  89. SetMovePosition01(GetCenterX+100,120,5);
  90. wait(120);
  91. yield;
  92. }
  93. }
  94.  
  95. task hypocycloid1(a,b,r,k,l){
  96. let t = 0;
  97. let obj = Obj_Create(OBJ_SHOT);
  98. ObjShot_SetGraphic(obj,RED01);
  99. while(Obj_BeDeleted(obj)==false) {
  100. t += 3;
  101. let x = a + r * ( (1 - k) * cos(t) + l * k * cos((1 - k) / k * t));
  102. let y = b + r * ( (1 - k) * sin(t) - l * k * sin((1 - k) / k * t));
  103. Obj_SetPosition(obj,x,y);
  104. yield;
  105. }
  106. }
  107.  
  108. task hypocycloid2(a,b,r,k,l){
  109. loop{
  110. k = absolute(trunc(10*k)/10 - trunc(k));
  111. let limit = 360 * (ToFractionNom(k) / GCD(ToFractionNom(k), ToFractionDeNom(k)));
  112. let t = 0;
  113. loop(200){
  114. t += limit/200;
  115. let x = a + r * ( (1 - k) * cos(t) + l * k * cos((1 - k) / k * t));
  116. let y = b + r * ( (1 - k) * sin(t) - l * k * sin((1 - k) / k * t));
  117. RotatingBullet(a, b, x, y, GetAngleToPlayer, RED01);
  118. }
  119. wait(300);
  120. }
  121. }
  122.  
  123. task RotatingBullet(a, b, x, y, angle, graphic) {
  124. let obj=Obj_Create(OBJ_SHOT);
  125.  
  126. Obj_SetPosition(obj, x, y);
  127. ObjShot_SetGraphic(obj, graphic);
  128. ObjShot_SetBombResist (obj, true);
  129.  
  130. let angle2 = atan3(x-a,y-b);
  131. let t2 = 0;
  132. let r = dist(x,y,a,b);
  133. while(Obj_BeDeleted(obj)==false) {
  134. t2 += 1;
  135. a += 2*cos(angle);
  136. b += 2*sin(angle);
  137. x = a + r * cos(t2 + angle2);
  138. y = b + r * sin(t2 + angle2);
  139. Obj_SetPosition(obj, x, y);
  140. yield;
  141. }
  142. }
  143.  
  144. function dist(x1,y1,x2,y2){
  145. let d = ((x1-x2)^2 + (y1-y2)^2)^0.5;
  146. return d;
  147. }
  148.  
  149. function atan3(x,y){
  150. if ( x == 0 && y == 0 ){
  151. break;
  152. }
  153. if ( x == 0 ){
  154. if ( y > 0 ){
  155. return 90;
  156. }else{
  157. return 270;
  158. }
  159. }
  160. if ( y == 0 ){
  161. if ( x > 0 ){
  162. return 0;
  163. }else{
  164. return 180;
  165. }
  166. }
  167. let a = atan(y/x);
  168. if ( x < 0 ){a = -a;}
  169. return a;
  170. }
  171.  
  172. function GCD(a,b){
  173. let c;
  174. loop{
  175. if ( b == 0 ){return a;}
  176. c = b;
  177. b = a % b;
  178. a = c;
  179. }
  180. }
  181.  
  182. function ToFractionNom(a){
  183. loop{
  184. a *= 10;
  185. if( a == trunc(a) ){return a;}
  186. }
  187. }
  188.  
  189. function ToFractionDeNom(a){
  190. let b = 1;
  191. loop{
  192. a *= 10;
  193. b *= 10;
  194. if( a == trunc(a) ){return b;}
  195. }
  196. }
  197.  
  198. //wait function
  199. function wait (w){
  200. loop(w){yield;}
  201. }
  202. }
Advertisement
Add Comment
Please, Sign In to add comment