Advertisement
Guest User

Ph3 Enemy Task

a guest
Aug 21st, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. function Enemy(img,positionX,positionY,life,shotrate,bombrate){
  2. let obj= ObjEnemy_Create(OBJ_ENEMY);
  3. let GetX = ObjMove_GetX(obj);
  4. let GetY = ObjMove_GetY(obj);
  5. let frame = 0;
  6. ObjEnemy_Regist(obj);
  7. ObjEnemy_SetLife(obj,life);
  8. ObjEnemy_SetDamageRate(obj,shotrate,bombrate);
  9. ObjEnemy_SetIntersectionCircleToShot(obj,GetX,GetY,15);
  10. ObjEnemy_SetIntersectionCircleToPlayer(obj,GetX,GetY,15);
  11. ObjPrim_SetTexture(obj, GetCurrentScriptDirectory() ~ img); //adding a texture
  12. //ObjSprite2D_SetSourceRect(obj, 0, 0, 32, 32); //selecting the right texture
  13. ObjSprite2D_SetSourceRect(obj, 97.5, 0, 129.5, 33.5);
  14. ObjSprite2D_SetDestCenter(obj); //positioning the texture
  15. FairyMaintenance(obj);
  16. return obj;
  17.  
  18.  
  19. task FairyMaintenance(fairy) {
  20. while(!Obj_IsDeleted(fairy) && ObjEnemy_GetInfo(fairy, INFO_LIFE) > 0) { // tests if the fairy is still alive
  21. // ObjEnemy_SetIntersectionCircleToShot(fairy, ObjMove_GetX(fairy), ObjMove_GetY(fairy), 16); // if not, give it a radius to be hit by stuff
  22. yield; //... you know what this does, right?
  23. }
  24. frame++;
  25. if(frame==60){;
  26. CreateShotA1(GetX,GetY,2,90,402,10);
  27. frame = 0;
  28. }
  29.  
  30. if(ObjEnemy_GetInfo(fairy, INFO_LIFE) <= 0 && !Obj_IsDeleted(fairy)) { //tests if the fairy is dead
  31. // Obj_Delete(fairy); //makes the fairy dead
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement