I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: RandomFangamer on July 26, 2016, 07:00:04 PM

Title: Spinning Circle Troubles
Post by: RandomFangamer on July 26, 2016, 07:00:04 PM
Hey,
I was posting about this on the Discord, but I really didn't understand how to do this so I brought it to the forums.

I am trying to make a SMW Boo Circle styled thing in Gamemaker Studio, but I don't quite understand how to get the objects to orbit around the center of the circle
Using return values I am able to make all the boos go to one position and circle around, but I want the circle to keep its shape while moving
To clarify what I want to happen, I want the boos to rotate around the top left corner of the B:
(click to show/hide)


Thanks for reading

Title: Re: Spinning Circle Troubles
Post by: WetWookie on July 26, 2016, 07:48:01 PM
What you want to do is something like this

Code: [Select]
with objBoos
    {
            //Calculate the boo's current distance from the center (or you can just use a constant)
            var dist = point_distance(other.x, other.y, x, y);
            //Calculate the boo's current angle from the center
            var dir = point_direction(other.x, other.y, x, y);
            //Add the number of degrees of the circle you want the boos to move each step
            dir += other.RotSpeed;
            //Use trig to calculate the boo's new x and y coordinates given the new angle and using the same distance
            x = other.x + cos(degtorad(dir)) * dist;
            y = other.y - sin(degtorad(dir)) * dist;
    }

For best results the sprite origins should be in the center of the boos
Title: Re: Spinning Circle Troubles
Post by: RandomFangamer on July 26, 2016, 08:04:37 PM
Thank you so much WetWookie!
This was a real bump in the road, so this really helps