Asuma Posted April 16, 2010 Report Share Posted April 16, 2010 I'm trying to achieve this type of rotation. I know there's LarkSS missile example, but his seems rotate towards a point. I just need something to rotate in the direction it's traveling in. I'm using the emeralds movement in SW as I want the objects movement as I want the object to move around the player. Link to comment Share on other sites More sharing options...
DimensionWarped Posted April 17, 2010 Report Share Posted April 17, 2010 Looks simple enough. The following assumes you are using degrees and not radians for your angles. Start with Phase = 0 Start with OutwardShift = 0 every frame increment phase by 1. If it reaches 360 (or better yet some multiple thereof if you want to have better control over the speed of rotation) set it back to 0 before the incrementation event. Increase OutwardShift every frame by some constant value. every frame once the timing value increasing is done, set the following: TrueShift = Max((OutwardShift^0.5), constant representing the limit of the shift) For the first of the 4 rotating objects... xPos = shift * cos(phase) yPos = shift * sin(phase) For the second xPos = shift * cos(phase + 90) yPos = shift * sin(phase + 90) For the third xPos = shift * cos(phase + 180) yPos = shift * sin(phase + 180) For the fourth xPos = shift * cos(phase + 270) yPos = shift * cos(phase + 270) And that should achieve roughly what you are describing. I think. Truth be told, it might actually rotate counterclockwise instead, but you can fix that just by reversing the phase incrementation (IE counting down from whatever). Also, if you want 7 emeralds, start from zero and add (360/7) to the phase shift in the individual placement of objects each time instead of 90. Aaaand holy crap, I just used trig to make a swastika. Link to comment Share on other sites More sharing options...
LarkSS Posted April 17, 2010 Report Share Posted April 17, 2010 Uh, I thought he just wanted to figure out how to make the objects rotate toward their movement angle, not create that movement, though I may be mistaken. In any case, if you want to make an object rotate to where it's moving and know the X and Y speeds, you can get the angle from 0,0 to speedX,speedY. You can use Damizean's angle calculator by setting the Xdiff to speedX and the Ydiff to speedY, and then calculating the angle. Or, just do the MMF2 equivalent of this: Atan2( speedX, speedY ) Would be something like: Atan( speedY / speedX ) ...with different checks for angles outside of the first quadrant and consideration for MMF2's inversed Y axis. Link to comment Share on other sites More sharing options...
Asuma Posted April 17, 2010 Author Report Share Posted April 17, 2010 Ah. Wait. So, should I replace SpeedX/SpeedY with the Delta speed? Link to comment Share on other sites More sharing options...
DimensionWarped Posted April 17, 2010 Report Share Posted April 17, 2010 Oh, we are talking about sprite rotation then and not simply the act of rotating in said pattern. Sorry, I was just going by that extremely prominent image. Link to comment Share on other sites More sharing options...
Asuma Posted April 17, 2010 Author Report Share Posted April 17, 2010 Maybe I should have if fade out. Link to comment Share on other sites More sharing options...
Recommended Posts