Message
Message
Message
import random
# Initialize pygame
pygame.init()
# Define colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
YELLOW = (255, 255, 0)
BLUE = (0, 0, 255)
def draw_ghost():
pygame.draw.circle(screen, BLUE, ghost_position, 20)
pygame.draw.rect(screen, BLUE, (ghost_position[0] - 20, ghost_position[1] - 20,
40, 40))
def draw_food():
for food_position in food_list:
pygame.draw.circle(screen, RED, food_position, 5)
def move_pacman():
global pacman_position, pacman_direction
keys = pygame.key.get_pressed()
if keys[pygame.K_RIGHT]:
pacman_position[0] += pacman_speed
pacman_direction = 0
elif keys[pygame.K_DOWN]:
pacman_position[1] += pacman_speed
pacman_direction = 1
elif keys[pygame.K_LEFT]:
pacman_position[0] -= pacman_speed
pacman_direction = 2
elif keys[pygame.K