I want to be able to click on the box and then click somewhere else and have it move to that location. I have no idea how to do it. Some of the ways I tried work but they only work for one image(if i have 2 or more boxes it wont work). Can you modify this code so when the box is clicked it becomes selected, then if anywhere else on the screen is clicked, the box will move to that new location?
Here is the code:
import pygame # Import the pygame module
# Initialize pygame
pygame.init()
# Set the screen size
screen = pygame.display.set_mode((512, 512))
# Set the title of the screen
pygame.display.set_caption("Screen")
image = pygame.transform.scale(pygame.image.load('image.png'),(64,64))
# Run the game loop
running = True
while running: # Main game loop
for event in pygame.event.get(): # Check for events
if event.type == pygame.QUIT: # If the user clicks the close button
running = False # Exit the game loop
# Clear the screen
screen.fill((255, 255, 255))
# Draw the image#
screen.blit(image,(224,224))
# Update the screen
pygame.display.update()
# Quit pygame
pygame.quit()