Author Topic: Handle rotary object  (Read 5291 times)

Junior Nintendista

  • Guest
Handle rotary object
« 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?

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 45.0.2454.85 Chrome 45.0.2454.85
    • View Profile
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #1 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.
(click to show/hide)

smoke weed everyday

Junior Nintendista

  • Guest
Re: Handle rotary object
« Reply #2 on: September 13, 2015, 12:24:43 PM »
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.

Junior Nintendista

  • Guest
Re: Handle rotary object
« Reply #3 on: September 13, 2015, 02:02:26 PM »
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

  • ~(=^・ω・^)ψ
  • Global Moderator
  • Oatmeal Killer
  • Posts: 1.021
  • Dear sir stroke madam, fire exclamation point
  • OS:
  • Windows Vista/Server 2008 Windows Vista/Server 2008
  • Browser:
  • Chrome 45.0.2454.85 Chrome 45.0.2454.85
    • View Profile
    • Twitter
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #4 on: September 13, 2015, 02:08:40 PM »
instance_create(random(800),random(608),objStar);

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 45.0.2454.85 Chrome 45.0.2454.85
    • View Profile
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #5 on: September 13, 2015, 02:37:34 PM »
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.
(click to show/hide)

smoke weed everyday

Junior Nintendista

  • Guest
Re: Handle rotary object
« Reply #6 on: September 13, 2015, 06:05:59 PM »
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.

infern0man1

  • ~(=^・ω・^)ψ
  • Global Moderator
  • Oatmeal Killer
  • Posts: 1.021
  • Dear sir stroke madam, fire exclamation point
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 45.0.2454.85 Chrome 45.0.2454.85
    • View Profile
    • Twitter
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #7 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);
« Last Edit: September 13, 2015, 06:11:53 PM by infern0man1 »

Junior Nintendista

  • Guest
Re: Handle rotary object
« Reply #8 on: September 13, 2015, 06:23:31 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);
I will explain once again, it is to create the stars themselves endlessly, creating all the time without stopping.

Sudnep

  • Global Moderator
  • Spike Dodger
  • Posts: 124
  • OS:
  • Windows NT 10.0 Windows NT 10.0
  • Browser:
  • Chrome 45.0.2454.85 Chrome 45.0.2454.85
    • View Profile
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #9 on: September 13, 2015, 06:50:14 PM »
That will create the star object infinitely though.

Junior Nintendista

  • Guest
Re: Handle rotary object
« Reply #10 on: September 13, 2015, 07:07:22 PM »
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.
« Last Edit: September 13, 2015, 07:27:03 PM by Junior Nintendista »

infern0man1

  • ~(=^・ω・^)ψ
  • Global Moderator
  • Oatmeal Killer
  • Posts: 1.021
  • Dear sir stroke madam, fire exclamation point
  • OS:
  • Linux Linux
  • Browser:
  • Chrome 45.0.2454.84 Chrome 45.0.2454.84
    • View Profile
    • Twitter
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #11 on: September 13, 2015, 07:26:20 PM »
Do you not understand why I set alarm[0] in the alarm 0 event? That resets the alarm and the process happens again infinitely.

Junior Nintendista

  • Guest
Re: Handle rotary object
« Reply #12 on: September 13, 2015, 07:29:12 PM »
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.

infern0man1

  • ~(=^・ω・^)ψ
  • Global Moderator
  • Oatmeal Killer
  • Posts: 1.021
  • Dear sir stroke madam, fire exclamation point
  • OS:
  • Linux Linux
  • Browser:
  • Chrome 45.0.2454.84 Chrome 45.0.2454.84
    • View Profile
    • Twitter
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #13 on: September 13, 2015, 07:32:05 PM »
//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


lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 45.0.2454.85 Chrome 45.0.2454.85
    • View Profile
  • Playstyle: Keyboard
Re: Handle rotary object
« Reply #14 on: September 13, 2015, 08:06:34 PM »
>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.
(click to show/hide)

smoke weed everyday