April 18, 2024, 09:00:15 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Proper Spaceship Rotation

Started by definitelyokay, November 24, 2009, 10:37:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

definitelyokay

I've been working on a game, but I've been doing some simple research and development demos first, to get the hang of the 2D engine.

Well, right now I'm stuck on some math. Attached is a zip file containing my current source, along with a picture of a triangle pointing up (a spaceship placeholder).

I would like the spaceship/triangle to rotate to where the tip is pointing at the mouse. I've tried different equations, but wasn't able to pull it off. Perhaps somebody more knowledgeable in math can help out.

I've really had a lot of fun working with the 2D commands in EB.

I'd very much appreciate any help!!

definitelyokay

I've actually already figured this one out after researching some more.

I used this here:

   otherX = MouseX() - X
   otherY = MouseY() - Y
   Angle = (fAtan2D(otherX, otherY)*-1)-90 ' subtract 90 since the ship is facing up in the original image
   SpriteAngle(spaceship, DegreesToRadians(Angle))