Skip to content
The Chat Archive
magistral-medium-2506 LMArena Human Preference 140K

Create an snail-themed arcade game in a coding language of your choosing. Do not rely on…

  1. User

    Create an snail-themed arcade game in a coding language of your choosing. Do not rely on external file uploads and instead create your own assets and designs.

  2. Assistant

    Here's a complete implementation of a snail-themed arcade game using Python and Pygame. The game involves controlling a snail to collect lettuce while avoiding obstacles. The game has a timer and a scoring system.

    import pygame
    import sys
    import random
    
    # Initialize pygame
    pygame.init()
    
    # Set up the display
    width, height = 800, 600
    screen = pygame.display.set_mode((width, height))
    pygame.display.set_caption("Snail Adventure")
    
    # Colors
    WHITE = (255, 255, 255)
    BLACK = (0, 0, 0)
    GREEN = (0, 255, 0)
    BROWN = (139, 69, 19)
    BLUE = (0, 0, 255)
    RED = (255, 0, 0)
    
    # Game clock
    clock = pygame.time.Clock()
    
    def draw_snail(x, y):
        # Body
        pygame.draw.ellipse(screen, GREEN, (x, y, 50, 30))
        # Shell
        pygame.draw.circle(screen, BROWN, (x + 25, y + 15), 20)
        # Eyes
        pygame.draw.circle(screen, BLACK, (x + 40, y + 10), 3)
        pygame.draw.circle(screen, BLACK, (x + 45, y + 10), 3)
        # Antennae
        pygame.draw.line(screen, BLACK, (x + 40, y + 10), (x + 30, y), 2)
        pygame.draw.line(screen, BLACK, (x + 45, y + 10), (x + 35, y), 2)
    
    # Snail position
    snail_x = width // 2
    snail_y = height // 2
    snail_speed = 5
    
    # Lettuce (collectibles)
    lettuce_list = []
    for _ in range(10):
        lettuce_x = random.randint(0, width - 20)
        lettuce_y = random.randint(0, height - 20)
        lettuce_list.append([lettuce_x, lettuce_y])
    
    # Obstacles
    obstacle_list = []
    for _ in range(5):
        obstacle_x = random.randint(0, width - 50)
        obstacle_y = random.randint(0, height - 50)
        obstacle_list.append([obstacle_x, obstacle_y])
    
    # Score
    score = 0
    font = pygame.font.SysFont(None, 36)
    
    # Timer
    start_time = pygame.time.get_ticks()
    game_duration = 60000  # 60 seconds
    
    # Game loop
    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
    
        # Handle key presses
        keys = pygame.key.get_pressed()
        if keys[pygame.K_LEFT]:
            snail_x -= snail_speed
        if keys[pygame.K_RIGHT]:
            snail_x += snail_speed
        if keys[pygame.K_UP]:
            snail_y -= snail_speed
        if keys[pygame.K_DOWN]:
            snail_y += snail_speed
    
        # Keep snail within the screen
        snail_x = max(0, min(snail_x, width - 50))
        snail_y = max(0, min(snail_y, height - 30))
    
        # Check for collisions with lettuce
        for lettuce in lettuce_list[:]:
            lettuce_rect = pygame.Rect(lettuce[0], lettuce[1], 20, 20)
            snail_rect = pygame.Rect(snail_x, snail_y, 50, 30)
            if snail_rect.colliderect(lettuce_rect):
                lettuce_list.remove(lettuce)
                score += 1
                # Add a new lettuce
                lettuce_x = random.randint(0, width - 20)
                lettuce_y = random.randint(0, height - 20)
                lettuce_list.append([lettuce_x, lettuce_y])
    
        # Check for collisions with obstacles
        for obstacle in obstacle_list:
            obstacle_rect = pygame.Rect(obstacle[0], obstacle[1], 50, 50)
            snail_rect = pygame.Rect(snail_x, snail_y, 50, 30)
            if snail_rect.colliderect(obstacle_rect):
                running = False
    
        # Increase snail speed based on score
        snail_speed = 5 + score // 5
    
        # Draw everything
        screen.fill(WHITE)
        draw_snail(snail_x, snail_y)
    
        for lettuce in lettuce_list:
            pygame.draw.circle(screen, GREEN, (lettuce[0] + 10, lettuce[1] + 10), 10)
    
        for obstacle in obstacle_list:
            pygame.draw.rect(screen, RED, (obstacle[0], obstacle[1], 50, 50))
    
        # Display score
        score_text = font.render(f"Score: {score}", True, BLACK)
        screen.blit(score_text, (10, 10))
    
        # Display timer
        current_time = pygame.time.get_ticks()
        elapsed_time = current_time - start_time
        if elapsed_time >= game_duration:
            running = False
        time_left = max(0, (game_duration - elapsed_time) // 1000)
        time_text = font.render(f"Time: {time_left}", True, BLACK)
        screen.blit(time_text, (width - 150, 10))
    
        pygame.display.flip()
        clock.tick(60)
    
    # Game over screen
    screen.fill(WHITE)
    game_over_text = font.render("Game Over!", True, BLACK)
    score_text = font.render(f"Final Score: {score}", True, BLACK)
    screen.blit(game_over_text, (width // 2 - 100, height // 2 - 50))
    screen.blit(score_text, (width // 2 - 100, height // 2 + 10))
    pygame.display.flip()
    pygame.time.wait(3000)  # Wait for 3 seconds before closing
    
    pygame.quit()
    sys.exit()
    

    This code creates a simple but fun snail-themed arcade game where the player controls a snail to collect lettuce and avoid obstacles within a time limit. The game features a snail character drawn using basic shapes, a scoring system, and a timer. The game ends when the snail hits an obstacle or the timer runs out, displaying a game over screen with the final score.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.