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
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Here's a complete retro-style horse racing arcade game that captures the 80s arcade aesthetic. The game features pixel art graphics, simple controls, and that classic arcade feel.
python
import pygame
import random
import time
import sys
from pygame.locals import *
# Initialize pygame
pygame.init()
# Constants
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
FPS = 60
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
PURPLE = (128, 0, 128)
ORANGE = (255, 165, 0)
BROWN = (139, 69, 19)
GRAY = (128, 128, 128)
# Create the screen
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Retro Horse Racing")
clock = pygame.time.Clock()
# Fonts
font_small = pygame.font.SysFont('Courier', 24)
font_medium = pygame.font.SysFont('Courier', 36)
font_large = pygame.font.SysFont('Courier', 48)
# Game states
MENU = 0
RACING = 1
RESULTS = 2
game_state = MENU
# Horse class
class Horse:
def __init__(self, name, color, lane):
self.name = name
self.color = color
self.lane = lane
self.x = 100
self.y = 100 + lane * 100
self.speed = random.uniform(1.0, 3.0)
self.position = 0
self.animation_frame = 0
self.animation_speed = 0.2
self.jockey_color = self.get_jockey_color()
def get_jockey_color(self):
# Return a contrasting color for the jockey
if self.color == RED:
return BLUE
elif self.color == BLUE:
return YELLOW
elif self.color == GREEN:
return PURPLE
elif self.color == YELLOW:
return RED
elif self.color == PURPLE:
return GREEN
else:
return WHITE
def update(self):
# Random speed variation
self.speed = max(0.5, self.speed + random.uniform(-0.2, 0.2))
self.position += self.speed
# Animation
self.animation_frame += self.animation_speed
if self.animation_frame > 3:
self.animation_frame = 0
def draw(self, screen):
# Draw the horse
horse_body = [
(self.x + 20, self.y + 20),
(self.x + 60, self.y + 20),
(self.x + 70, self.y + 30),
(self.x + 60, self.y + 40),
(self.x + 20, self.y + 40),
(self.x + 10, self.y + 30)
]
# Draw horse body
pygame.draw.polygon(screen, self.color, horse_body)
# Draw legs (animated)
leg_positions = [
(self.x + 20, self.y + 40),
(self.x + 30, self.y + 40),
(self.x + 50, self.y + 40),
(self.x + 60, self.y + 40)
]
for i, pos in enumerate(leg_positions):
if i < 2:
# Front legs
if self.animation_frame < 1.5:
pygame.draw.line(screen, self.color, pos, (pos[0], pos[1] + 20), 4)
else:
pygame.draw.line(screen, self.color, pos, (pos[0], pos[1] + 10), 4)
else:
# Back legs
if self.animation_frame >= 1.5:
pygame.draw.line(screen, self.color, pos, (pos[0], pos[1] + 20), 4)
else:
pygame.draw.line(screen, self.color, pos, (pos[0], pos[1] + 10), 4)
# Draw head
pygame.draw.circle(screen, self.color, (self.x + 70, self.y + 25), 10)
# Draw eye
pygame.draw.circle(screen, BLACK, (self.x + 75, self.y + 22), 2)
# Draw jockey
pygame.draw.circle(screen, self.jockey_color, (self.x + 30, self.y + 15), 8)
pygame.draw.line(screen, self.jockey_color, (self.x + 30, self.y + 15), (self.x + 30, self.y + 5), 2)
pygame.draw.line(screen, self.jockey_color, (self.x + 30, self.y + 10), (self.x + 40, self.y + 10), 2)
# Draw name
name_text = font_small.render(self.name, True, BLACK)
screen.blit(name_text, (self.x + 80, self.y + 10))
# Track class
class Track:
def __init__(self):
self.lanes = 5
self.length = 1000
self.finish_line = SCREEN_WIDTH - 100
self.grass_color = GREEN
self.dirt_color = BROWN
self.lane_color = WHITE
def draw(self, screen):
# Draw grass
pygame.draw.rect(screen, self.grass_color, (0, 0, SCREEN_WIDTH, SCREEN_HEIGHT))
# Draw track
pygame.draw.rect(screen, self.dirt_color, (50, 50, SCREEN_WIDTH - 100, SCREEN_HEIGHT - 100))
# Draw lanes
for i in range(self.lanes + 1):
y = 100 + i * 100
pygame.draw.line(screen, self.lane_color, (50, y), (SCREEN_WIDTH - 50, y), 2)
# Draw finish line
pygame.draw.line(screen, RED, (self.finish_line, 50), (self.finish_line, SCREEN_HEIGHT - 50), 5)
for i in range(5):
pygame.draw.line(screen, WHITE, (self.finish_line - 10, 100 + i * 100),
(self.finish_line + 10, 100 + i * 100), 2)
# Game class
class Game:
def __init__(self):
self.track = Track()
self.horses = [
Horse("THUNDER", RED, 0),
Horse("LIGHTNING", BLUE, 1),
Horse("STORM", GREEN, 2),
Horse("COMET", YELLOW, 3),
Horse("BLAZE", PURPLE, 4)
]
self.player_horse = None
self.race_finished = False
self.winner = None
self.bet_amount = 10
self.player_money = 100
self.race_time = 0
self.high_score = 0
self.selected_horse = 0
def reset(self):
self.horses = [
Horse("THUNDER", RED, 0),
Horse("LIGHTNING", BLUE, 1),
Horse("STORM", GREEN, 2),
Horse("COMET", YELLOW, 3),
Horse("BLAZE", PURPLE, 4)
]
self.player_horse = self.horses[self.selected_horse]
self.race_finished = False
self.winner = None
self.race_time = 0
def update(self):
if not self.race_finished:
self.race_time += 1 / FPS
# Update all horses
for horse in self.horses:
horse.update()
horse.x = 100 + (horse.position / self.track.length) * (SCREEN_WIDTH - 200)
# Check if any horse has finished
if horse.x >= self.track.finish_line - 20:
self.race_finished = True
self.winner = horse
def draw(self, screen):
# Draw track
self.track.draw(screen)
# Draw horses
for horse in self.horses:
horse.draw(screen)
# Draw race info
if not self.race_finished:
time_text = font_small.render(f"Time: {int(self.race_time)}s", True, WHITE)
screen.blit(time_text, (SCREEN_WIDTH - 150, 20))
# Draw player's bet
bet_text = font_small.render(f"Bet: ${self.bet_amount} on {self.player_horse.name}", True, WHITE)
screen.blit(bet_text, (20, 20))
money_text = font_small.render(f"Money: ${self.player_money}", True, WHITE)
screen.blit(money_text, (20, 50))
def handle_event(self, event):
if event.type == KEYDOWN:
if event.key == K_UP:
self.selected_horse = (self.selected_horse - 1) % len(self.horses)
elif event.key == K_DOWN:
self.selected_horse = (self.selected_horse + 1) % len(self.horses)
elif event.key == K_LEFT:
self.bet_amount = max(1, self.bet_amount - 1)
elif event.key == K_RIGHT:
self.bet_amount = min(self.player_money, self.bet_amount + 1)
elif event.key == K_RETURN:
if game_state == MENU:
if self.bet_amount > self.player_money:
self.bet_amount = self.player_money
self.player_money -= self.bet_amount
self.player_horse = self.horses[self.selected_horse]
self.reset()
return RACING
elif game_state == RACING and self.race_finished:
# Calculate winnings
if self.winner == self.player_horse:
self.player_money += self.bet_amount * 5
else:
self.player_money += self.bet_amount // 2 # Consolation prize
# Update high score
if self.player_money > self.high_score:
self.high_score = self.player_money
return RESULTS
elif game_state == RESULTS:
return MENU
return game_state
# Create game instance
game = Game()
# Main game loop
running = True
while running:
# Handle events
for event in pygame.event.get():
if event.type == QUIT:
running = False
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False
# Clear screen
screen.fill(BLACK)
# Game state handling
if game_state == MENU:
# Draw title
title_text = font_large.render("RETRO HORSE RACING", True, YELLOW)
screen.blit(title_text, (SCREEN_WIDTH // 2 - title_text.get_width() // 2, 50))
# Draw instructions
instructions = [
"SELECT YOUR HORSE:",
"UP/DOWN ARROWS",
"PLACE YOUR BET:",
"LEFT/RIGHT ARROWS",
"PRESS ENTER TO RACE"
]
for i, line in enumerate(instructions):
text = font_small.render(line, True, WHITE)
screen.blit(text, (SCREEN_WIDTH // 2 - text.get_width() // 2, 150 + i * 30))
# Draw horses in menu
for i, horse in enumerate(game.horses):
color_rect = pygame.Rect(SCREEN_WIDTH // 2 - 50, 250 + i * 40, 20, 20)
pygame.draw.rect(screen, horse.color, color_rect)
name_text = font_small.render(horse.name, True, WHITE)
screen.blit(name_text, (SCREEN_WIDTH // 2 - 20, 250 + i * 40))
if i == game.selected_horse:
pygame.draw.rect(screen, WHITE, (SCREEN_WIDTH // 2 - 60, 245 + i * 40, 100, 30), 2)
# Draw bet amount
bet_text = font_medium.render(f"Bet: ${game.bet_amount}", True, WHITE)
screen.blit(bet_text, (SCREEN_WIDTH // 2 - bet_text.get_width() // 2, 400))
# Draw money
money_text = font_small.render(f"Money: ${game.player_money}", True, WHITE)
screen.blit(money_text, (SCREEN_WIDTH // 2 - money_text.get_width() // 2, 450))
# Draw high score
high_score_text = font_small.render(f"High Score: ${game.high_score}", True, WHITE)
screen.blit(high_score_text, (SCREEN_WIDTH // 2 - high_score_text.get_width() // 2, 500))
elif game_state == RACING:
game.update()
game.draw(screen)
if game.race_finished:
# Draw winner announcement
winner_text = font_large.render(f"{game.winner.name} WINS!", True, YELLOW)
screen.blit(winner_text, (SCREEN_WIDTH // 2 - winner_text.get_width() // 2, 100))
time_text = font_medium.render(f"Time: {int(game.race_time)} seconds", True, WHITE)
screen.blit(time_text, (SCREEN_WIDTH // 2 - time_text.get_width() // 2, 200))
press_enter = font_small.render("PRESS ENTER TO CONTINUE", True, WHITE)
screen.blit(press_enter, (SCREEN_WIDTH // 2 - press_enter.get_width() // 2, 300))
elif game_state == RESULTS:
# Draw results
results_text = font_large.render("RACE RESULTS", True, YELLOW)
screen.blit(results_text, (SCREEN_WIDTH // 2 - results_text.get_width() // 2, 50))
# Draw winner
winner_text = font_medium.render(f"Winner: {game.winner.name}", True, WHITE)
screen.blit(winner_text, (SCREEN_WIDTH // 2 - winner_text.get_width() // 2, 150))
# Draw winnings
if game.winner == game.player_horse:
winnings_text = font_medium.render(f"You won ${game.bet_amount * 5}!", True, GREEN)
else:
winnings_text = font_medium.render(f"Consolation: ${game.bet_amount // 2}", True, RED)
screen.blit(winnings_text, (SCREEN_WIDTH // 2 - winnings_text.get_width() // 2, 200))
# Draw money
money_text = font_medium.render(f"Total Money: ${game.player_money}", True, WHITE)
screen.blit(money_text, (SCREEN_WIDTH // 2 - money_text.get_width() // 2, 250))
# Draw high score
high_score_text = font_small.render(f"High Score: ${game.high_score}", True, WHITE)
screen.blit(high_score_text, (SCREEN_WIDTH // 2 - high_score_text.get_width() // 2, 300))
press_enter = font_small.render("PRESS ENTER TO RETURN TO MENU", True, WHITE)
screen.blit(press_enter, (SCREEN_WIDTH // 2 - press_enter.get_width() // 2, 400))
# Update display
pygame.display.flip()
# Handle game state transitions
for event in pygame.event.get():
if event.type == KEYDOWN:
game_state = game.handle_event(event)
# Cap the frame rate
clock.tick(FPS)
pygame.quit()
sys.exit()
How to Play:
Menu Screen:
Use UP/DOWN arrows to select your horse
Use LEFT/RIGHT arrows to adjust your bet amount
Press ENTER to start the race
Race Screen:
Watch the horses race automatically
The race ends when any horse crosses the finish line
Press ENTER to see results
Results Screen:
See how much you won (or lost)
Press ENTER to return to the menu
Game Features:
Retro 80s arcade aesthetic with pixel art horses
Five colorful horses with different names
Betting system with money management
High score tracking
Simple controls that would work on an arcade cabinet
Randomized horse speeds for unpredictable races
Animated horse legs for that classic arcade feel
The game is completely self-contained with no external dependencies beyond Python and Pygame. All graphics are drawn programmatically to maintain that retro look.