Create a retro-themed, horse-racing arcade game in Python. The game design looks like it…
- User
Create a retro-themed, horse-racing arcade game in Python. The game design looks like it could have been played in an arcade back in the 80's. Do not rely on external file uploads and instead create your own assets and designs.
Assistant
Certainly! Below is a simple retro-themed horse-racing arcade game created in Python using the
pygamelibrary. This game captures the aesthetic of 80's arcade games with pixel art and simple mechanics.First, ensure you have
pygameinstalled. You can install it using pip if you haven't already:pip install pygameHere is the complete code for the retro-themed horse-racing arcade game:
import pygame import random # Initialise pygame pygame.init() # Constants SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 horse_width = 30 horse_height = 40 track_width = SCREEN_WIDTH - 40 FPS = 60 WHITE = (255, 255, 255) BLACK = (0, 0, 0) GREEN = (0, 255, 0) # Set up the screen screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("Retro Horse Racing") # Load fonts font = pygame.font.SysFont("monospace", 16) # Horse class class Horse(pygame.sprite.Sprite): def __init__(self, color, lane): super().__init__() self.image = pygame.Surface((horse_width, horse_height)) self.image.fill(color) self.rect = self.image.get_rect() self.rect.x = 20 self.rect.y = lane self.speed = random.randint(3, 6) def update(self): self.rect.x += self.speed if self.rect.x > SCREEN_WIDTH: self.rect.x = -horse_width self.speed = random.randint(3, 6) # Track class class Track(pygame.sprite.Sprite): def __init__(self): super().__init__() self.image = pygame.Surface((track_width, SCREEN_HEIGHT)) self.image.fill(GREEN) self.rect = self.image.get_rect() self.rect.x = 20 self.rect.y = 0 # Draw lanes for i in range(5): pygame.draw.line(self.image, WHITE, (0, i * 80), (track_width, i * 80), 2) # Create sprite groups all_sprites = pygame.sprite.Group() horses = pygame.sprite.Group() # Create the track track = Track() all_sprites.add(track) # Create horses lanes = [40, 120, 200, 280, 360] horse_colours = [(255,0,0), (0,0,255), (0,255,0), (255,255,0), (255,0,255)] for i, lane in enumerate(lanes): horse = Horse(horse_colours[i], lane) all_sprites.add(horse) horses.add(horse) # Game loop clock = pygame.time.Clock() running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Update all_sprites.update() # Check for winner for horse in horses: if horse.rect.x >= SCREEN_WIDTH - horse_width: winner_text = font.render(f"Winner: Horse {horses.sprites().index(horse) + 1}", 1, WHITE) screen.blit(winner_text, (SCREEN_WIDTH // 2 - winner_text.get_width() // 2, SCREEN_HEIGHT // 2 - winner_text.get_height() // 2)) pygame.display.flip() pygame.time.wait(2000) # Show winner for 2 seconds horse.rect.x = -horse_width # Reset horse position break # Draw screen.fill(BLACK) all_sprites.draw(screen) pygame.display.flip() clock.tick(FPS) pygame.quit()Explanation:
-
Initialization:
- Pygame is initialized, and constants for screen size, horse dimensions, and colours are defined.
- The screen is set up, and a font is loaded for rendering text.
-
Horse Class:
- Each horse is a sprite with a coloured rectangle.
- Horses move at a random speed between 3 and 6 pixels per frame.
- When a horse goes off-screen, it resets to the start with a new random speed.
-
Track Class:
- The track is a green rectangle with white lanes drawn at regular intervals.
-
Sprite Groups:
all_spritesincludes both the track and the horses.horsesincludes only the horse sprites.
-
Horse Creation
- Horses are created with different colours and placed in different lanes.
-
Game Loop:
- The game loop handles events, updates sprite positions, and redraws the screen.
- If a horse reaches the end of the track, a winner message is displayed for 2 seconds before resetting the horse's position
This game captures the simple, pixelated aesthetic of 80's arcade games and provides a basic but fun horse-racing experience.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- grok-3-mini-highCompare side by side →
mistral-medium-2505Compare side by side →
llama-3.3-70b-instructCompare side by side →
amazon.nova-pro-v1:0Compare side by side →
claude-sonnet-4-20250514Compare side by side →
gemini-2.5-flash-preview-04-17Compare side by side →
gemini-2.5-flash-lite-preview-06-17-thinkingCompare side by side →