Sign in to follow this  
xraven13

How to get point from which bullets needs to be shooted if ship rotates?

Recommended Posts

xraven13    107
I tried using something like its on this picture : http://i50.tinypic.com/xknfux.png But problem is that i can't get the center. I have angle, origin of rotation ( constant that doesnt change when sprite moves and rotates) and x and y of sprite that is top left of sprite. X and y don't change when sprite rotates. But from what i see x+width/2 , y+height/2 should give the center but i dont get good results.. When i send x and y only everything is moved a little down and to right... So did i done something wrong? ( look at pic ) So again : if i have coordinates relative to the sprite from which bullets are shooted, how those coordinates are changed when sprite moves and rotates?? Thx in advance..

Share this post


Link to post
Share on other sites
fowl mouth    100
I believe you have to negate the sin of the angle to get Y, so that when using angle 90 for example X,Y for 1 point away from the center (assumed 0,0) will be (1,0) for 0 degrees (facing east), (0,-1) for 90 degrees (north), (-1,0) for 180 degrees (west), (0,1) for 270 degrees (south.) I'm assuming you are using trig angle for you ship also so that when the ship is facing west it will be at 0 degrees and north would be 90 degrees. Hope that helps.

Also until you get it down pat I recommend just firing at the same angle the ship is facing. Adding the angles is nothing but if you hold off until you get it right you can make sure bullets are coming out correctly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this