I Wanna Community
Fangames => Game Design => Programming Questions => Topic started by: Junior Nintendista on September 13, 2015, 10:51:07 AM
-
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?
-
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.
-
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.
Yes, I want it turning, but also want the stars randomly create the room from anywhere.
-
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.
(https://i.imgur.com/cVAvxRf.png)
-
instance_create(random(800),random(608),objStar);
-
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.
-
instance_create(random(800),random(608),objStar);
I do not want to create only one star, I want to appear several stars randomly by side to be sucked into the blackhole.
-
//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);
-
//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);
I will explain once again, it is to create the stars themselves endlessly, creating all the time without stopping.
-
That will create the star object infinitely though.
-
That will create the star object infinitely though.
But not infinitely created, created just a few and then did not create more. I'm actually asking these questions because I'm doing the fucking I Wanna Call Me It in my medley.
-
Do you not understand why I set alarm[0] in the alarm 0 event? That resets the alarm and the process happens again infinitely.
-
Do you not understand why I set alarm[0] in the alarm 0 event? That resets the alarm and the process happens again infinitely.
Be more specific, it is very complicated, I am unable to understand.
-
//spawning object's create event
alarm[0]=1; //sets the alarm at the start
//spawning object's alarm 0 event
for(i=0;i<(number of objects you want spawned per alarm);i+=1){ //10 stars are created per alarm
instance_create(random(800),random(608),star);
}
alarm[0]=(how frequently you want this to occur); //alarm is reset and everything happens again
-
>tfw
basically alarm events are activated when you set them, so alarm[0]=10 will make alarm 0 activate after 10 frames. if you set an alarm inside an alarm, you can make an infinite loop. Then you just put in the create star code and that should do it.
-
>tfw
basically alarm events are activated when you set them, so alarm[0]=10 will make alarm 0 activate after 10 frames. if you set an alarm inside an alarm, you can make an infinite loop. Then you just put in the create star code and that should do it.
Another error, the speed of stars is absurd's very fast and not giving this to change.
-
O_O
(https://i.imgur.com/qCVjIYi.png)
-
Try this: https://www.mediafire.com/download/7menx7w7soy8q4e/
Edit: updated, previous version was unfinished.
-
Try this: https://www.mediafire.com/download/7menx7w7soy8q4e/
Edit: updated, previous version was unfinished.
It's almost that, but objects can only be constantly spinning on the screen.