Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Information about object: oHoam
- Sprite: sHoam
- Solid: false
- Visible: true
- Depth: 0
- Persistent: false
- Parent: <no parent>
- Mask: <same as sprite>
- Create Event:
- execute code:
- alarm[0]=15;
- time=0;
- dmg=0.2;
- Step Event:
- execute code:
- time+=1;
- old=direction
- if(time>=15){
- if(instance_exists(oEnemy)){
- near_obj=instance_nearest(x,y,oEnemy);
- fdir=point_direction(x,y,near_obj.x,near_obj.y);
- if(abs(old-fdir)=0){
- time=0;
- exit;
- }else{
- use=-1;
- rotate=0;
- if((old-fdir>=-180 and old-fdir<=0) or old-fdir>=180){ use=1; }
- /*rotate left or right. Positive is to the left. If old is 0 (right), and fdir is 90 (up), it will 'rotate' left.
- 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.*/
- if(min(abs(old-fdir),12)<12){
- rotate=min(abs(old-fdir),6)*use;
- }else{
- rotate=min(abs(old-fdir),12)*use;
- //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.
- //Obviously the smaller the number the less the object will move around
- direction+=rotate
- }
- if direction<0 then
- direction+=360
- if direction>=360 then
- direction-=360
- //Keeps direction in the 0 and 360 bounds
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement