# Rotating image around a given point

Im trying to simulate shadows in a 2d RPG, So far I can make the shadows but i cant blit them properly, Im trying to rotate them according to where the "sun" is (just a position)

I have looked at other questions, they say to move the center of the image to the point rotate it then move it back so that what I'm trying to do

here is my code to rotate it:

def rotate(self, shadow, rect):
copy = rect.copy() #get copy of rect
angle = degrees(atan2(self.center[0]-self.sun[0], self.center[1]-self.sun[1]))-180 #get angle from "sun" to center of screen

if angle < -180:
angle += 360

angle /= -5

rect.center = copy.midbottom #move rect to rotation point
rect.center = copy.center # move it back

return shadow, rect #return the image and rect to blit them


when the angle is negative it seem like its working and I get this result (which isnt really what I want):

but when I rotate it positively:

so I think I'm doing this totally wrong! I've been trying to figure it out for awhile now, I think I'm blitting it wrong, or not at the right state

I don't know pygame and how blitting works there but it seems that you translate rect but rotate shadow. Are you sure that's right?