Skip to content

Instantly share code, notes, and snippets.

@varjmes
Last active December 18, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save varjmes/5694839 to your computer and use it in GitHub Desktop.
Save varjmes/5694839 to your computer and use it in GitHub Desktop.
Tiny text-based adventure game written in Ruby.
def prompt
print("> ")
end
puts("You enter a dark room with two doors. Do you go through door #1 or #2?")
prompt; door = gets.chomp
if door == "1"
puts("You walk towards door #1")
puts("Opening the door; you see a giant bear eating a cheesecake...")
puts("Do you:")
puts("\t1. Take the cake.")
puts("\t2. Scream at the bear")
prompt; bear = gets.chomp
if bear == "1"
puts("Congratulations, the bear has eaten your face off!")
elsif bear == "2"
puts("Well done! The Bear has eaten your genitalia!")
else
puts("Pressing #{bear} was probably a better idea. The bear runs away.")
end
elsif door == "2"
puts("You stare into the endless abyss at Cthulu's retina.")
puts("Do you:")
puts("\t1. Poke its eye with a stick.")
puts("\t2. Try and beat it in a staring competition.")
puts("\t3. Run away.")
prompt; insanity = gets.chomp
if insanity == "1" || insanity == "2"
puts("Having two eyes is an unfair advantage. Your left eye is taken and then you die.")
else
puts("Running away is cowardly. You die.")
end
else
puts("Those who can't play the game, die. You die.")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment