|
« on: January 13, 2013, 03:20:59 pm »
|
|
Simply put: I have two objects a head objects that has a random movement part in it and a body object that follows the head object, currently using the codes below, but it looks horrible. All suggestions are appriciated. Its one of the last mini-bosses that are yet uncompleted, I can do 1 object bosses and 1 other 2 object boss without a problem, but this one with the following in it seems to be more then I can do alone. Information about object: objDodongo1Head Sprite: sprDodongohead Solid: false Visible: true Depth: 0 Persistent: false Parent: Mask:
Create Event:
execute code:
if global.killed1Dmboss=1 {instance_destroy()} HP=3 eating=0 swollen=0 image_speed=0 alarm[0]=10 alarm[2]=15
Alarm Event for alarm 0:
execute code:
if(!global.pause ){ switch floor(random(4)){ //Pick a random number, make it an integer, and see what it is case 0: direction=360 //Right image_index=2 break; case 1: direction=90 //Up image_index=3 break; case 2: direction=180 //Left image_index=0 break; case 3: direction=270 //Down image_index=1 break; } //Set the speed switch floor(random(2)){ //Pick a random number, make it an integer, and see what it is case 0: speed=0 break; case 1: speed=0.5 break; } //Reset the alarm } alarm[0]=55+random(20)
Alarm Event for alarm 1:
execute code:
image_alpha=1
Step Event:
execute code:
if !place_free(x+1,y) && ( direction=360 or direction = 0 ){speed=0; x=xprevious; y=yprevious} if !place_free(x,y-1) && direction=90 {speed=0; x=xprevious; y=yprevious} if !place_free(x-1,y) && direction=180 {speed=0; x=xprevious; y=yprevious} if !place_free(x,y+1) && direction=270 {speed=0; x=xprevious; y=yprevious} if(!global.pause){
if HP<=0{ instance_change(objEDie,true) } }
End Step Event:
execute code:
vx = 0 //Set up some placeholders to save space vw = 160 vy = 32 vh = 158
if (x< vx) { x=xprevious y=yprevious }
else if ((x+sprite_width) > vx+vw) { x=xprevious y=yprevious }
else if (y< vy) { x=xprevious y=yprevious }
else if ((y+sprite_height) > vh) { x=xprevious y=yprevious }
Information about object: objDodongo1body Sprite: sprDodongobody Solid: false Visible: true Depth: 1 Persistent: false Parent: Mask:
Create Event:
execute code:
if global.killed1Dmboss=1 {instance_destroy()} activated=0 alarm[0]=2
Alarm Event for alarm 0:
execute code:
activated=1
Step Event:
execute code:
targetx=objDodongo1Head.x targety=objDodongo1Head.y
if activated=1 && objDodongo1Head.speed=.5 && (objDodongo1Head.direction=360 or objDodongo1Head.direction=0) { x=targetx-15;y=targety-1;speed=.5 }
if activated=1 && objDodongo1Head.speed=.5 && objDodongo1Head.direction=90 { x=targetx;y=targety+15;speed=.5 }
if activated=1 && objDodongo1Head.speed=.5 && objDodongo1Head.direction=180 { x=targetx+15;y=targety-1;speed=.5 }
if activated=1 && objDodongo1Head.speed=.5 && objDodongo1Head.direction=270 { x=targetx;y=targety-16;speed=.5 }
if activated=1 && objDodongo1Head.speed=0 { move_towards_point(objDodongo1Head.x,objDodongo1Head.y,0.5) }
if activated=1 && self.x=objDodongo1Head.x && self.y=objDodongo1Head.y { speed=0 activated=0 }
if activated=0 && objDodongo1Head.speed=0.5 { alarm[0]=3 }
//direction=360 //Right //direction=90 //Up //direction=180 //Left //direction=270 //Down
End Step Event:
execute code:
vx = 0 //Set up some placeholders to save space vw = 160 vy = 32 vh = 158
if (x< vx) { x=xprevious y=yprevious }
else if ((x+sprite_width) > vx+vw) { x=xprevious y=yprevious }
else if (y< vy) { x=xprevious y=yprevious }
else if ((y+sprite_height) > vh) { x=xprevious y=yprevious }

Logged
|
|