i have this code:
import pygame
width, height = 500, 500
screen = pygame.display.set_mode((width, height))
turret_image = pygame.image.load("Turret.png")
player_image = pygame.image.load("player.png")
turret_x, turret_y = 225, 225
player_x, player_y = 225, 50
player_pressed = False
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type == pygame.MOUSEBUTTONDOWN:
player_pressed = True
if event.type == pygame.MOUSEBUTTONUP:
player_pressed = False
if player_pressed:
(x, y) = pygame.mouse.get_pos()
player_x = x - 25
player_y = y - 25
screen.fill((0, 0, 0))
screen.blit(turret_image, (turret_x, turret_y))
screen.blit(player_image, (player_x, player_y))
pygame.display.update()
currently this moves an image along with the mouse while its held down what i want to do is to get the turret_image surface to always face the player image. the turret image needs to stay at the same position and rotate to look at the player at all times.