# Correct Blitting 2 surface problem

this is a graphics/math problem. Consider this 2 sprite / surface

As you can see they are a tank and his gun turret. Now, i manage the turret rotation, and it works, and, also, the rotation of the tank on the screen.

What it'snt work is the correct "blitting" of the turret on my tank.

The problem is that the turret is never blitted correctly on the tank. This is a math problem, and i'm not so good in math ! How can i correct blit the turret centered on the "right" hole of my tank sprite ?

I'm using c# and sdl.net and actually i blit the turret with this code ( 13,13 are the X and Y position of the 'black' hole of the tank, but, i know, this is not the right method to blit it!):

``````            Surface tmpsurf = new Surface("graphics/tank_turret_long.png");

Surface turretSurf = tmpsurf.CreateRotatedSurface(cannonangle);

turretSurf.Transparent = true;

turretSurf.TransparentColor = Color.Black;

Point posTurret = new Point(13+this.X,13+this.Y);
Video.Screen.Blit(torrettaSurf,posTorretta);
``````

-

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 by `theta` degrees should give you a "new" center at `x_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 at `13,13`. This shouldn't be a problem (keep in mind I'm not very versed in C#, so this is probably syntactically incorrect):
``````Point posTurret = new Point(13 + this.X - x1*Math.cos(cannonangle),
Where `x1` and `y1` are the coordinates of the center of the turret in "`tank_turret_long.png`".