Below is a complete, self-contained Python implementation of a retro-themed horse-racing arcade game. The game is designed to evoke the feel of an 80's arcade game, using ASCII art for visuals and simple console-based animation. Since external files are not allowed, all assets (like the title screen, horse representations, and track) are created directly in the code using strings and ASCII characters.
The game flow is as follows:
- Title Screen: Displays a retro ASCII art title.
- Betting Phase: The player selects a horse to bet on from a list of 4 horses.
- Race Simulation: The race is animated in the console, with horses moving across a progress bar. The movement is random to simulate unpredictability.
- Result Announcement: The winner is revealed, and the player is told if they won their bet.
The game uses basic Python modules (os, time, and random) for console clearing, animation timing, and random horse movements. The animation works by clearing the console and redrawing the race state in each frame, which gives a simple "flicker" effect reminiscent of old arcade games.
To run the game, save this code in a file (e.g., horse_racing_arcade.py) and execute it in a terminal or command prompt. Note that the console-clearing function may behave differently in some IDEs; for best results, run it in a standard terminal.
import os
import time
import random
# Function to clear the console (cross-platform)
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
# Function to display the title screen with retro ASCII art
def display_title():
print(r"""
_____ _ _ _
|_ _| | | | | | |
| | _ __ ___ _ __ | |_| |__ ___ | |_
| | | '_ \/ __|| '_ \ | __| '_ \ / _ \ | __|
_| |_| | | \__ \| |_) | | |_| | | | (_) | | |_
|_____|_| |_|___/| .__/ \__|_| |_|\___/ \__|
| |
|_|
=== HORSE RACING ARCADE ===
1985 EDITION
===========================
""")
# Function for the betting phase
def betting_phase():
horses = ["Thunder", "Lightning", "Storm", "Gale"] # List of horse names
print("Place your bet on a horse! Choose wisely...")
for i, horse in enumerate(horses, 1):
print(f"{i}. {horse}")
while True:
choice = input("Enter the number of the horse you want to bet on: ")
try:
choice_idx = int(choice) - 1
if 0 <= choice_idx < len(horses):
return horses[choice_idx] # Return the name of the chosen horse
else:
print("Invalid number. Please enter a number between 1 and 4.")
except ValueError:
print("That's not a number! Try again.")
# Function to simulate the race with ASCII animation
def simulate_race():
horses = ["Thunder", "Lightning", "Storm", "Gale"] # Horse names
positions = {horse: 0 for horse in horses} # Initialize positions to 0
max_position = 50 # Track length (finish line at 50)
# Simple ASCII art for the starting gate (displayed once)
clear_screen()
print("The horses are lining up at the starting gate!")
print(r"""
_____
/ \ __
/ O O \ / \
| --- | / \
| \___/ | / \
\_______/ ---------
Get ready for the race!
""")
time.sleep(2) # Pause for dramatic effect
while True:
clear_screen() # Clear the console for animation
print("Race in progress! Watch the horses thunder to the finish!")
# Draw each horse's progress bar
for horse in horses:
pos = positions[horse]
bar_length = 20 # Length of the progress bar
filled_length = int((pos / max_position) * bar_length) # Calculate filled portion
bar = '[' + '=' * filled_length + ' ' * (bar_length - filled_length) + ']'
print(f"{horse}: {bar} {pos}/{max_position}")
# Move each horse a random distance (1 to 5 positions)
for horse in horses:
move = random.randint(1, 5)
positions[horse] += move
# Check if any horse has reached or exceeded the finish line
if any(pos >= max_position for pos in positions.values()):
break
time.sleep(0.5) # Pause to control animation speed (0.5 seconds per frame)
# Determine the winner(s) – could be a tie if multiple finish at once
max_pos_reached = max(positions.values())
winners = [horse for horse, pos in positions.items() if pos >= max_position]
return winners
# Function to announce the race result
def announce_result(winners, player_horse):
clear_screen()
if len(winners) == 1:
winner = winners[0]
print(f"The winner crosses the finish line! It's {winner}!")
else:
print(f"It's a photo finish! It's a tie between {', '.join(winners)}!")
# Check if the player won their bet
if player_horse in winners:
print(r"""
Congratulations! You picked a winner!
___
/ \
| O O | You're a betting genius!
\___/
Keep the change, ya filthy animal!
""")
else:
print(r"""
Oh no! Better luck next time.
___
/ \
| X X | Your horse tripped over its own hooves!
\___/
Try again, arcade champ!
""")
# Main game function
def main():
display_title()
input("Press Enter to start the race...") # Wait for player to press Enter
player_choice = betting_phase() # Get the player's bet
winners = simulate_race() # Run the race simulation
announce_result(winners, player_choice) # Announce the result
input("Press Enter to exit the arcade...") # Wait before closing
# Run the game if this script is executed directly
if __name__ == "__main__":
main()
How to Play:
- Save the code in a file and run it in a terminal (e.g.,
python horse_racing_arcade.py).
- The title screen will appear. Press Enter to continue.
- Choose a horse by entering a number (1-4) during the betting phase.
- Watch the race animate in the console. The horses move randomly, and the progress bars update in real-time.
- After the race, the result is shown, including whether you won your bet.
- Press Enter to exit.
Retro Design Notes:
- ASCII Art: The title, starting gate, and result screens use simple ASCII art to mimic 80's arcade aesthetics. I created these directly in the code without external assets.
- Animation: The race uses a progress bar for each horse, updated in a loop with
time.sleep() for a frame-by-frame effect. This gives a nostalgic "flickering" feel.
- Randomness: Horse movements are random to ensure replayability, simulating the unpredictability of real horse racing.
- Simplicity: The game is kept concise and fun, fitting the arcade style. No complex graphics or sound are used, as we're limited to console output. If your terminal supports it, you might hear a system beep on win/lose (from the ASCII art), but this is optional.
This game should run on most systems with Python installed. If you encounter issues with console clearing, you can comment out the clear_screen() calls and the animation will still work, though it won't be as polished. Enjoy your trip back to the 80's! 🎮🐎