0

Sorry For Bad English

by.x is my sprite x position, by.y is my sprite y position

I want to image gets my sprite's position and gets direction to target pos. I write this code, but it isn't like my wanted.

main_skill_image.blit(pygame.transform.rotate(main_skill_image,math.atan2(target_pos[1]-by.y,target_pos[0]-by.x)/math.pi*180 + 180),(by.x,by.y))

1 Answers1

0

Looking at this question You could do something like this:

angle = 360-math.atan2(pos[1]-by.x,pos[0]-by.y)*180/math.pi
mai_skill_image= pygame.transform.rotate(main_skill_image,angle)

Haven't tested it, if it doesn't work, ill test it and fix it.

The Big Kahuna
  • 2,097
  • 1
  • 6
  • 19