Advertisement
LordSolrac2

Patch2; Hoaming Bullet Fixed

Oct 16th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Information about object: oHoam
  2.  
  3. Sprite: sHoam
  4. Solid: false
  5. Visible: true
  6. Depth: 0
  7. Persistent: false
  8. Parent: <no parent>
  9. Mask: <same as sprite>
  10.  
  11. Create Event:
  12. execute code:
  13.  
  14. alarm[0]=15;
  15. time=0;
  16. dmg=0.2;
  17.  
  18.  
  19.  Step Event:
  20. execute code:
  21.  
  22. time+=1;
  23. old=direction
  24.  
  25.  
  26.  
  27. if(time>=15){
  28.     if(instance_exists(oEnemy)){
  29.         near_obj=instance_nearest(x,y,oEnemy);
  30.         fdir=point_direction(x,y,near_obj.x,near_obj.y);
  31.     if(abs(old-fdir)=0){
  32.         time=0;
  33.         exit;
  34.     }else{
  35.         use=-1;
  36.         rotate=0;
  37.         if((old-fdir>=-180 and old-fdir<=0) or old-fdir>=180){ use=1; }
  38.     /*rotate left or right.  Positive is to the left.  If old is 0 (right), and fdir is 90 (up), it will 'rotate' left.
  39.     Really rotate just stands for the change in direction.  I just used it in this code because I rotated the sprite in game, so the variable made sense.*/
  40.         if(min(abs(old-fdir),12)<12){
  41.             rotate=min(abs(old-fdir),6)*use;
  42.         }else{
  43.             rotate=min(abs(old-fdir),12)*use;
  44.     //You can change the 12 and 6 around, or you can get rid of the if, rotate, and else statement and just leave the second rotate statement.
  45.     //Obviously the smaller the number the less the object will move around
  46.             direction+=rotate
  47.         }
  48.         if direction<0 then
  49.             direction+=360
  50.         if direction>=360 then
  51.             direction-=360
  52.     //Keeps direction in the 0 and 360 bounds
  53.     }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement