Dinosaur Test Game

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import random

def survive_dinosaur_game():
health = 100
distance = 0

while health > 0 and distance < 50:


print(f"Distance traveled: {distance} miles | Health: {health}%")
action = input("Choose an action (1: Hunt, 2: Rest, 3: Continue): ")

if action == '1':
damage = random.randint(10, 20)
health -= damage
print(f"You hunted a dinosaur but took {damage} damage.")

elif action == '2':


rest_amount = random.randint(10, 15)
health = min(100, health + rest_amount)
print(f"You rested and gained {rest_amount} health.")

elif action == '3':


distance += random.randint(5, 15)
print("You continue your journey.")

else:
print("Invalid action. Try again.")

if health <= 0:
print("Game over. You were defeated by dinosaurs.")
else:
print(f"Congratulations! You survived and traveled {distance} miles.")

# Run the game


survive_dinosaur_game()

You might also like