Advertisement
Jaykin

Sprite not showing up

Oct 9th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.68 KB | None | 0 0
  1. #TouhouDanmakufu[Single]
  2. #ScriptVersion[3]
  3. #Title["Tutorial 01"]
  4. #Text["Simple enemy bullet tutorial"]
  5.  
  6. let bossObj;
  7. let bossX=0;
  8. let bossY=0;
  9. let imgBoss = GetCurrentScriptDirectory ~ "Ichirin.png";
  10.  
  11. #include "script/default_system/Default_ShotConst.txt"
  12.  
  13.  
  14. @Initialize {
  15.     //define a boss in bossObj and register it
  16.     bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
  17.     ObjEnemy_Regist(bossObj);
  18.    
  19.     //Warp the boss to this ocation when loaded
  20.     ObjMove_SetPosition(bossObj,192,-100);
  21.    
  22.     //Warp boss to desired x y location at desired speed
  23.     ObjMove_SetDestAtSpeed(bossObj,192,120,5);
  24.    
  25.    
  26.    
  27.     //move boss
  28.     ObjMove_SetDestAtSpeed(bossObj,192,120,5);
  29.    
  30.     mainTask;
  31.  
  32. }
  33.  
  34. @Event {
  35.     //setting the boss timer and life
  36.     alternative(GetEventType())
  37.     case(EV_REQUEST_LIFE) {
  38.         SetScriptResult(1000);
  39.     }
  40.     case(EV_REQUEST_TIMER){
  41.         SetScriptResult(45);
  42.     }
  43.        
  44.    
  45.  
  46. }
  47.  
  48. @MainLoop{
  49.     bossX=ObjMove_GetX(bossObj);
  50.     bossY=ObjMove_GetY(bossObj);
  51.        
  52.     //collision for the shots and player
  53.     ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
  54.     ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
  55.     yield;
  56.  
  57. }
  58.  
  59. @Finalize{
  60.  
  61. }
  62. // your best friend forever.
  63. function wait(w){loop(w){yield;}}
  64.  
  65. task mainTask{
  66.     renderBoss;
  67.     movement;
  68.    
  69. }  
  70.  
  71. task renderBoss{
  72.     let dir;
  73.     let speed;
  74.    
  75.     //texture the boss, set centre as true centre
  76.     ObjPrim_SetTexture(bossObj,imgBoss);
  77.     ObjSprite2D_SetSourceRect(bossObj,0,0,32,32);
  78.     ObjSprite2D_SetDestCenter(bossObj);
  79.     ObjRender_SetScaleXYZ(bossObj,5,5,0);
  80.        
  81.    
  82.     while(!Obj_IsDeleted(bossObj)){
  83.        
  84.     //update boss speed and direction locally
  85.     dir = ObjMove_GetAngle(bossObj);
  86.     speed = ObjMove_GetSpeed(bossObj);
  87.    
  88.     // if the boss is idle, show this image/rect   
  89.     if(speed==0){ ObjSprite2D_SetSourceRect(bossObj,0,0,32,32); ObjRender_SetScaleXYZ(bossObj,0,0,0);}         //boss holding location
  90.     else if(cos(dir)<0){ObjSprite2D_SetSourceRect(bossObj,0,0,32,32); ObjRender_SetScaleXYZ(bossObj,0,0,0);}   //hence moving to the left
  91.     else if(cos(dir)>0){ObjSprite2D_SetSourceRect(bossObj,0,0,32,32); ObjRender_SetScaleXYZ(bossObj,0,180,0);} //boss moving to the right
  92.     yield;
  93.     }
  94.  
  95. }
  96.  
  97. task movement{
  98.     wait(60);
  99.     fire;
  100.     wait(30);
  101.     loop{
  102.         ObjMove_SetDestAtSpeed(bossObj,100,130,5);
  103.         wait(45);
  104.         fire;
  105.         wait(30);
  106.         ObjMove_SetDestAtSpeed(bossObj,280,120,5);
  107.         wait(45);
  108.         fire;
  109.         wait(30);
  110.  
  111.  
  112.     }
  113. }
  114.  
  115. function angleToPlayer{
  116.     let dir=atan2(GetPlayerY-bossY,GetPlayerX-bossX);
  117.     return dir;
  118. }
  119.  
  120. task fire{
  121.     let dir = angleToPlayer;
  122.     loop(10) {
  123.         CreateShotA1(bossX,bossY,3,angleToPlayer-20,14,0);
  124.         CreateShotA1(bossX,bossY,3,angleToPlayer,14,0);
  125.         CreateShotA1(bossX,bossY,3,angleToPlayer+20,14,0);
  126.         wait(3);
  127.          
  128.     }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement