Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clock.tick(60) #define o clock
- screen.fill((255, 255, 255)) #pinta a tela de branco
- player_rect = player.get_rect() #recupera o retangulo da imagem, ou seja, as dimensoes
- mouse_x, mouse_y = pygame.mouse.get_pos() #recupera o x e y do mouse
- hypo = math.sqrt(math.pow(player_rect.centerx - mouse_x, 2) + math.pow(player_rect.centery - mouse_y, 2))
- cos = math.cos((player_rect.centerx - mouse_x) / hypo)
- sin = math.sin((player_rect.centery - mouse_y) / hypo)
- angle = (180 / math.pi) * -math.atan2(sin, cos)
- newplayer = pygame.transform.rotate(player, angle) #rotaciona de acordo com o angulo
- 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