# Title: Text Game # Description: A text based adventure game # Author: Neel(s) # Version: 1.0 def startmenu(): START = False print "Welcome, frail mortal, to Text Game. I shall be your guide through lands of mystery and adventure. Oh, and my name is Hal." print "All commands must be said as they are displayed. For instance, if I say 'Quit', you reply with the same, not 'quit'." print "Please say 'Continue' to continue, and 'Quit' to end the game. 'Quit' will work throughout the game." while not START: menuinput = raw_input() if menuinput == "Continue": START = True town1() elif menuinput == "Quit": START = True quitgame() else: print "That is no valid command, fool of a Took. I demand that you retry." def quitgame(): quit() def town1(): print "You are in the middle of the town in which you dwell. The main road is dirt, and the only horse is owned by Old Farmer Maggot." print "You can go to the inn, commonly known as The Mos Eisley, where you can get a manner of quests; or the stables, where you can buy a steed." print "Say 'Inn' to go to the inn, or 'Stables' to go to the stables. You may also say 'Leave' to leave the town." TRY = False while not TRY: choice = raw_input() if choice == "Inn": TRY = True inn() elif choice == "Stables": TRY = True stables() elif choice == "Leave": TRY = True leave_town1() elif choice == "Quit": TRY = True quitgame() else: print "That is an unknown command. Please, follow simple instructions!" def inn(): print "You enter the inn. The hustle and bustle of the small town's inn smacks you in the face like yo angry mama." print "You may talk to Juan Solo, enter the back room, or leave the inn." print "Say 'Talk', 'Back Room', or 'Leave'." TRY = False while not TRY: choice = raw_input() if choice == "Talk": print "Hello, I am Juan Solo. I am a trader from the next town over." elif choice == "Back Room": TRY = True inn_back_room() elif choice == "Leave": TRY = True town1() elif choice == "Quit": TRY = True quitgame() else: print "Ok, you should know by now how to answer these prompts. Are you, like, 4?" def inn_back_room(): print "As you enter the smokefilled back room, you get stabbed through the throat by an angry goblin." quitgame() def stables(): print "You enter the stables. The owner of the stables, an ancient man worn with age, greets you with a friendly wave and a crooked grin." print "He says, 'Hey there, young man. Take a gander over at yonder horses, and tell me how do you like em.'" print "To examine the horses, say 'Horses'; To leave stables, say 'Leave'." TRY = False while not TRY: choice = raw_input() if choice == "Horses": print "You examine the horses. There is a small sare, which is medium speed but grants medium defense and attack." print "There is a thoroughbred, which is extremly fast but grants low defense and attack." print "There is a warhorse, which is slow, but grants high defense and attack." elif choice == "Leave": TRY = True town1() elif choice == "Quit": TRY = True quitgame() else: print "English! Do you speak it?" def leave_town1(): print "As you leave town, the dark forest surrounding it oppresses you on all sides. You experience a falling sensation, and the forest is instantaneously" print "replaced by a scene so horrible that I cannot begin to describe it. I wouldn't if I could anyway, because you wouldn't read it, as you are now dead." quitgame() startmenu()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question