Enhance Pygame Simple Dodge Game

Job ID: 39799897

Budget: ₹750 – ₹1,250 INR

To achieve success in study import pygame
import random

# Pygame initialize
pygame.init()

# Screen size
WIDTH, HEIGHT = 600, 400
win = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Simple Dodge Game")

# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)

# Player settings
player_size = 50
player_x = WIDTH // 2 - player_size // 2
player_y = HEIGHT - player_size - 10
player_speed = 5

# Obstacle settings
obstacle_size = 50
obstacle_x = random.randint(0, WIDTH - obstacle_size)
obstacle_y = -obstacle_size
obstacle_speed = 5

# Game loop
clock = pygame.time.Clock()
run = True
while run:
clock.tick(60) # 60 FPS
win.fill(WHITE)

# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False

# Player movement
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and player_x - player_speed > 0:
player_x -= player_speed
if keys[pygame.K_RIGHT] and player_x + player_speed + player_size < WIDTH:
player_x += player_speed

# Obstacle movement
obstacle_y += obstacle_speed
if obstacle_y > HEIGHT:
obstacle_y = -obstacle_size
obstacle_x = random.randint(0, WIDTH - obstacle_size)

# Collision detection
if (player_x < obstacle_x + obstacle_size and
player_x + player_size > obstacle_x and
player_y < obstacle_y + obstacle_size and
player_y + player_size > obstacle_y):
print("Game Over!")
run = False

# Draw player and obstacle
pygame.