Author Topic: Spinning Circle Troubles  (Read 1221 times)

RandomFangamer

  • Cherry Eater
  • Posts: 71
  • Pico Pico Piiiiiii
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 47.0 Firefox 47.0
    • View Profile
  • Playstyle: Keyboard
Spinning Circle Troubles
« 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

« Last Edit: July 26, 2016, 08:05:08 PM by RandomFangamer »




:ItsBoshyTime: o o o o o :denProgress: o o o o o :paraKid:

WetWookie

  • Cherry Eater
  • Posts: 90
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 43.0 Firefox 43.0
    • View Profile
  • Playstyle: Keyboard
Re: Spinning Circle Troubles
« Reply #1 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

RandomFangamer

  • Cherry Eater
  • Posts: 71
  • Pico Pico Piiiiiii
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 47.0 Firefox 47.0
    • View Profile
  • Playstyle: Keyboard
Re: Spinning Circle Troubles
« Reply #2 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




:ItsBoshyTime: o o o o o :denProgress: o o o o o :paraKid: