Advertisement
Guest User

tes

a guest
Dec 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1.   clock.tick(60) #define o clock
  2.         screen.fill((255, 255, 255)) #pinta a tela de branco
  3.         player_rect = player.get_rect() #recupera o retangulo da imagem, ou seja, as dimensoes
  4.         mouse_x, mouse_y = pygame.mouse.get_pos() #recupera o x e y do mouse
  5.  
  6.         hypo = math.sqrt(math.pow(player_rect.centerx - mouse_x, 2) + math.pow(player_rect.centery - mouse_y, 2))
  7.         cos = math.cos((player_rect.centerx - mouse_x) / hypo)
  8.         sin = math.sin((player_rect.centery - mouse_y) / hypo)
  9.  
  10.  
  11.         angle = (180 / math.pi) * -math.atan2(sin, cos)
  12.  
  13.         newplayer = pygame.transform.rotate(player, angle) #rotaciona de acordo com o angulo
  14.         screen.blit(newplayer, [100, 100]) #mostra na tela o newplayer que recebe a rotacao do player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement