I am new to coding, and recently I used python to generate a starting/begging code for me. Sadly when I pasted this into Apple Swift, it shows up with "Expected Expression". Does anyone know how to fix this?
# Initialize Pygame
pygame.init()
# Set up the screen
screen_width = 800
screen_height = 600
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Loading Screen")
# Define the colors for the gradient
colors = [(255, 204, 0), (255, 102, 0), (255, 0, 0)]
# Define the rectangle for the gradient
gradient_rect = pygame.Rect(0, 0, screen_width, screen_height)
# Draw the gradient
for i in range(screen_height):
color = tuple(map(lambda x, y: int(x + (y - x) * i / screen_height), colors[0], colors[-1]))
pygame.draw.line(screen, color, (0, i), (screen_width, i))
# Update the screen
pygame.display.flip()
# Set the time for the loading screen
loading_time = 5000 # 5 seconds
# Start the loading screen
loading_screen_start = pygame.time.get_ticks()
# Main loop
while True:
# Check for events
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
# Check if the loading screen is over
if pygame.time.get_ticks() - loading_screen_start >= loading_time:
# End the loading screen
break
# Quit Pygame
pygame.quit()