Fangames > Programming Questions
Spinning Circle Troubles
(1/1)
RandomFangamer:
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
WetWookie:
What you want to do is something like this
--- Code: ---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;
}
--- End code ---
For best results the sprite origins should be in the center of the boos
RandomFangamer:
Thank you so much WetWookie!
This was a real bump in the road, so this really helps
Navigation
[0] Message Index
Go to full version