I'm attempting to make a Pygame game where the player holds a weapon that points towards the mouse, the movement is fine, but I cannot get the weapon to point to the cursor! I took and edited a code snippet from somewhere else but it doesn't seem to be working; here's the code:
# weapons ---------------------------------------------------------------
mouse = pygame.mouse.get_pos()
angle = 360-math.atan2(mouse[0]-x,mouse[1]-y)*180/math.pi
rotimage = pygame.transform.rotate(shotgun_sprite,angle)
WIN.blit(rotimage,(250-rotimage.get_width()/2,250-rotimage.get_height()/2))
# end of loop --------------------------------------------------------------