Fangames > Programming Questions

Handle rotary object

<< < (2/4) > >>

lawatson:
Alright, I've got some tricks up my sleeve for that. I'll just modify the original message into this post.

in the object getting sucked in, put this in the create event:

radius=point_distance(x,y,blackhole.x,blackhole.y);
angle=point_direction(x,y,blackhole.x,blackhole.y);
speed=(maximum speed you want) / (maximum distance from the object) * point_distance(x,y,blackhole.x,blackhole.y);

step event code:

x=blackhole.x+(radius*cos(degtorad(angle)));
y=blackhole.y+(radius*-sin(degtorad(angle)));
angle+=(rotation speed here);
speed=(maximum speed you want) / (maximum distance from the object) * point_distance(x,y,blackhole.x,blackhole.y);
radius-=speed;
if point_distance(x,y,blackhole.x,blackhole.y)<speed{instance_destroy();}

If you want it to lose alpha as it approaches the object, put this in the step event too:

image_alpha=1-(1/(maximum distance from the object)*point_distance(x,y,blackhole.x,blackhole.y));

If you want it to lose rotation speed as it approaches the object, replace the angle+=(rotation speed here) code with:

angle+=(maximum speed you want) - ((maximum speed you want) / (maximum distance from the object) * point_distance(x,y,blackhole.x,blackhole.y));

That should be it. If there's a bug, post it.

Junior Nintendista:

--- Quote from: infern0man1 on September 13, 2015, 02:08:40 PM ---instance_create(random(800),random(608),objStar);

--- End quote ---
I do not want to create only one star, I want to appear several stars randomly by side to be sucked into the blackhole.

infern0man1:
//spawning object's create event
alarm[0]=1;

//spawning object's alarm 0 event
for(i=0;i<(number of objects you want spawned per alarm);i+=1){
  instance_create(random(800),random(608),star);
}
alarm[0]=(how frequently you want this to occur);

Junior Nintendista:

--- Quote from: infern0man1 on September 13, 2015, 06:08:49 PM ---//spawning object's create event
alarm[0]=1;

//spawning object's alarm 0 event
for(i=0;i<(number of objects you want spawned per alarm);i+=1){
  instance_create(random(800),random(608),star);
}
alarm[0]=(how frequently you want this to occur);

--- End quote ---
I will explain once again, it is to create the stars themselves endlessly, creating all the time without stopping.

Sudnep:
That will create the star object infinitely though.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version