Skip to content

Instantly share code, notes, and snippets.

@dougmcnally
Created November 5, 2016 18:09
Show Gist options
  • Save dougmcnally/06fa0533a893b6e85222bb4f4645940f to your computer and use it in GitHub Desktop.
Save dougmcnally/06fa0533a893b6e85222bb4f4645940f to your computer and use it in GitHub Desktop.
# name: Mr. McNally
# date: 2016-04-25
# description: Text-based space adventure game
import random
import time
def displayIntro():
print("It is the end of a long year of fighting space criminals")
print("you come to crossroads on your trip home, one path leads home")
print("where you will be handsomly rewarded for a job well done")
print("and the other leads through a gamma ray burst that will disentigrate you")
print()
def choosePath():
path = ""
while path != "1" and path != "2": # input validation
path = input("Which path will you choose? (1 or 2): ")
return path
def checkPath(chosenPath):
print("You head down the path")
time.sleep(2)
print("there's an asteroid nearby that looks familiar, that must be a good sign...")
time.sleep(2)
print("But your skin begins to tingle...")
print()
time.sleep(2)
correctPath = random.randint(1, 2)
if chosenPath == str(correctPath):
print("That tingling was just the feeling of admiration from the citizens of the galaxy!")
print("Welcome home!")
else:
print("An extremely energetic burst of gamma rays pass through you")
print("causing all of the atoms in your body to dissociate")
print("there is no record left of your existence.")
playAgain = "yes"
while playAgain == "yes" or playAgain == "y":
displayIntro()
choice = choosePath()
checkPath(choice) # choice is equal to "1" or "2"
playAgain = input("Do you want to play again? (yes or y to continue playing): ")
@conradbkay
Copy link

Nice code

@lemun
Copy link

lemun commented Mar 8, 2018

Thank you for the code! i got a little confused at the end 👍

@Solo158
Copy link

Solo158 commented Jun 30, 2021

cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment