SFML community forums

Help => Graphics => Topic started by: bryce910 on March 26, 2015, 07:44:12 pm

Title: Bullet Movement angle issue
Post by: bryce910 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. ???
Title: Re: Bullet Movement angle issue
Post by: G. on March 26, 2015, 08:00:30 pm
Add 90°.
Or draw your sprite in a way that it is facing right at 0°.
Title: Re: Bullet Movement angle issue
Post by: StormWingDelta 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. :)
Title: Re: Bullet Movement angle issue
Post by: bryce910 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!