Advertisement
Guest User

Test

a guest
Jul 2nd, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. #TouhouDanmakufu[Single]
  2. #ScriptVersion[3]
  3. #Title["Test"]
  4. #Text["Test"]
  5.  
  6. //load the default shotsheet
  7. #include"script/default_system/Default_ShotConst.txt"
  8.  
  9. //----------------------------------------------------
  10. //Declaring Global Variables
  11. //----------------------------------------------------
  12. let objEnemy; //enemy object
  13. let objPlayer; //player object
  14. let frame = 0; //Counter for timing enemy movements
  15.  
  16. //----------------------------------------------------
  17. //Enemy movement
  18. //----------------------------------------------------
  19. @Event
  20. {
  21. alternative(GetEventType())
  22. case(EV_REQUEST_LIFE)
  23. {
  24. //Script requests for the enemy life
  25. SetScriptResult(500);//setting enemy life to 500
  26. }
  27. }
  28.  
  29. @Initialize
  30. {
  31. //Sets variable "objPlayer" to the Player ID
  32. objPlayer = GetPlayerObjectID();
  33.  
  34. //Create and register enemy object
  35. objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
  36. ObjEnemy_Regist(objEnemy);
  37.  
  38. //Setting the enemy's image
  39. let imgExRumia = GetCurrentScriptDirectory ~ "ExRumia/ExRumia.png"; //file path to enemy image
  40. ObjPrim_SetTexture(objEnemy, imgExRumia); //Setting the above image file as a texture to the enemy object(objEnemy)
  41. ObjSprite2D_SetSourceRect(objEnemy, 64, 1, 127, 64); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).
  42. ObjSprite2D_SetDestCenter(objEnemy); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
  43.  
  44. //Moving to the coordinate (cx, 120) in 60 frames
  45. let cx = GetStgFrameWidth() / 2;//defines the variable cx as the horizontal middle of the stage. (Stage width / 2)
  46. ObjMove_SetDestAtFrame(objEnemy, cx, 120, 60);
  47. }
  48.  
  49. @MainLoop
  50. {
  51. //retrieving enemy coordinates
  52. let ex = ObjMove_GetX(objEnemy);
  53. let ey = ObjMove_GetY(objEnemy);
  54.  
  55. if(frame == 180)
  56. {
  57. //executes when frame is equal to 180
  58. //retrieves player coordinates
  59. let px = GetPlayerX();
  60. let py = GetPlayerY();
  61.  
  62. //calculats angle between enemy and player
  63. let angleToPlayer = atan2(py - ey, px - ex);
  64.  
  65. //Creates a 5-way shot by increasing the angle by 15, starting from -30 degrees.
  66. let angle=0;
  67. while(angle<360)
  68. {//(Executes while "angle" is less than 360, while increasing by 15 degrees each loop)
  69. //Creates bullets that will
  70. //angle towards the player at the same time
  71. let obj = CreateLooseLaserA1(ex, ey, 2, angle, 100, 20, DS_BEAM_RED, 30);
  72. //60 frames after being fired, the bullets are angled and aimed at the player
  73. ObjMove_AddPatternA4(obj, 60, 3, 0, 0, 0, 3, objPlayer, NO_CHANGE);
  74. angle += 15;
  75. }
  76.  
  77. frame = 0;//frame is returned to 0 after firing
  78. }
  79.  
  80. //Setting the enemy hit box
  81. ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);//hitbox against player bullets. 32 is the radius.
  82. ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 24);//hitbox against the player. 24 is the radius.
  83.  
  84. //adding +1 to frame. "frame++" is equivalent to "frame = frame + 1;" or "frame += 1;"
  85. frame++;
  86.  
  87. //if the enemy's life is 0
  88. if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0)
  89. {
  90. //The enemy is killed immediately when life is 0
  91. //As this is a beginner sample script,
  92. //the script is ended immediately without waiting for an explosion effect.
  93. Obj_Delete(objEnemy);
  94. CloseScript(GetOwnScriptID());
  95. return;
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement