Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Member Since 12 Sep 2010
Offline Last Active May 27 2014 11:03 PM

Topics I've Started

a mouse controlled paddle (semicircle)

12 September 2010 - 11:21 AM

hi everyone. im trying to make a breakout game in c++/SDL where the paddle is a semi-circle shape (rotating around the center of the screen), and its angle o facing is controlled by moving the mouse in the direction you want it to point to. this allows for 360 degrees of freedom. everything is setup so that every frame all I have to do is calculate the new angle that the paddle should point for that frame. my function to calculate the angle is failing miserably however :)

every frame I get the relative mouse position (x, y) that the mouse moved from the last frame, then I warp the mouse back to the center of the screen. I get the correct readings for relative mouse position every frame, and its not affected by warping the mouse back to the center.

so basically everything is in place, I have all my data (current paddle's angle, mouse x and y displacement) for each frame, now what I need to do is figure out how to calculate a new angle to move the paddle.

how can I do this? my idea is if you set your X axis to the line that is perpendicular to the paddle's current facing (and y axis parallel to the paddle's current facing angle), then the only mouse displacement that will be used for determing how far to rotate the paddle will be that movement which lies on the x axis. I hope that made sense. I spent all day yesterday trying to figure this out and am failing miserably :(. for starters I just tried to set the angle of the paddle each frame to arctan( relativeMouseY / relativeMouseX ) but that doesn't seem to work either, my paddle jumps all over the place.

any help is appreciated :)