Fangames > Programming Questions

Handle rotary object

(1/4) > >>

Junior Nintendista:
I was wondering how to make a sucker for the background, for example, I put stars as an object and put a put another object in the center to suck, but the stars are turning to this subject in the center (like a black hole). How to do this?

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

direction=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:

speed=(maximum speed you want) / (maximum distance from the object) * point_distance(x,y,blackhole.x,blackhole.y);
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 get rotated inward, I have a way of doing that as well.

Junior Nintendista:

--- Quote from: lawatson on September 13, 2015, 11:42:26 AM ---in the object getting sucked in, put this in the create event:

direction=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:

speed=(maximum speed you want) / (maximum distance from the object) * point_distance(x,y,blackhole.x,blackhole.y);
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 get rotated inward, I have a way of doing that as well.

--- End quote ---
Yes, I want it turning, but also want the stars randomly create the room from anywhere.

Junior Nintendista:
This may explain more or less in the center is the object and the stars will be randomly created from anywhere in the room and will be sucked into these object with the star revolving movement.

infern0man1:
instance_create(random(800),random(608),objStar);

Navigation

[0] Message Index

[#] Next page

Go to full version