hope it’s allowed to “crosspost” between stackexchange site…
Does anyone know how to solve the following “math” problem ?
https://gamedev.stackexchange.com/questions/5041/correct-blitting-2-surface-problem
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your problem seems to be that you’re blitting the turret with respect to its top left corner, when you actually want to blit it with respect to the center of the actual turret. Now, assuming your turret has its center at
x_1,y_1, rotating it clockwise bythetadegrees should give you a “new” center atx_2=x_1*cos(theta),y_2=y_1*sin(theta). You then have to line this up with the center of the turret hole, located at13,13. This shouldn’t be a problem (keep in mind I’m not very versed in C#, so this is probably syntactically incorrect):Where
x1andy1are the coordinates of the center of the turret in “tank_turret_long.png“.I’ll crosspost this answer on gamedev as well.