Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - prondzyk

Pages: [1]
1
Graphics / Rotate Sprite
« on: July 02, 2009, 10:01:27 am »
Now I have:
Code: [Select]

Sprite.SetCenter(Sprite.GetSize() / 2.f);
if (App.GetInput().GetMouseX() <= Sprite.GetPosition().x) {
   Sprite.SetRotation  (-1* 360 / 3.1415926535 * (atan2(   static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) , static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))));
      } else {
      Sprite.SetRotation  (-1* 360 / 3.1415926535 *(atan2(   static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) ,      static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))));
      }
App.ConvertCoords(App.GetInput().GetMouseX(), App.GetInput().GetMouseY());

but still doesn't work properly. The same story :/

EDIT:
Success! It must look like this:
Code: [Select]
Sprite.SetCenter(Sprite.GetSize() / 2.f);
if (App.GetInput().GetMouseX() <= Sprite.GetPosition().x) {
   Sprite.SetRotation  (((-1* 360 / 3.1415926535 * (atan2(   static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) , static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))))/2)+90);
      } else {
      Sprite.SetRotation  (((-1* 360 / 3.1415926535 *(atan2(   static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) ,      static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))))/2)+90);
      }

Thanks for help!

2
Graphics / Rotate Sprite
« on: July 01, 2009, 10:17:33 pm »
Hi my first post :)
I was writning code which rotate sprite and follows the cursor.
Code: [Select]

Sprite.SetCenter(Sprite.GetSize() / 2.f);
if (App.GetInput().GetMouseX() <= Sprite.GetPosition().x) {
   Sprite.SetRotation  (-1 * 360/ 3.1415926535 * (atan(   static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) / static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))));
      } else {
      Sprite.SetRotation  (-1 * 360/ 3.1415926535 *(atan(   static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) /      static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))));
      }

but it doesn't work properly. Sprite (its rifle)isn't parallel to cursor.
It look like that:


What is wrong?

Pages: [1]