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

Author Topic: Bullet Movement angle issue  (Read 1872 times)

0 Members and 1 Guest are viewing this topic.

bryce910

  • Newbie
  • *
  • Posts: 31
    • View Profile
Bullet Movement angle issue
« on: March 26, 2015, 07:44:12 pm »
So I have asked this before and I got it working correctly on mac. But now that I have put this on my windows machine I am having some issues. What I am trying to do is have the bullet move in the angle it is set to.

                int radion = laserList[i].getRotation() * 3.14159265 / 180;
                float movementX = cos(radion) * 30.0f;
                float movementY = sin(radion) * 30.0f;
                laserList[i].move(movementX, movementY);
 

As my angle is straight up at 0 degree it moves the bullets directly to the right. If I have the sprite facing down (180 degree) the bullets shoot directly to the left.

Doesn't seem to make much sense. ???

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Bullet Movement angle issue
« Reply #1 on: March 26, 2015, 08:00:30 pm »
Add 90°.
Or draw your sprite in a way that it is facing right at 0°.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: Bullet Movement angle issue
« Reply #2 on: March 27, 2015, 12:36:19 am »
The idea is to make sure that the starting firing angle matches that of the starting facing angle of the sprite.  That way the bullets move the way you want them too. :)
I have many ideas but need the help of others to find way to make use of them.

bryce910

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Bullet Movement angle issue
« Reply #3 on: March 27, 2015, 05:26:49 pm »
Thanks for the feedback and the help on the issue I was getting.

I did get the problem fixed by  adding -90 degrees when getting the rotation of the sprite to offset it to the correct location.


float radion = (laserList[i].getRotation() - 90) * 3.14159265 / 180;

 

Thanks again guys!

 

anything