Python Adventure game











up vote
7
down vote

favorite












I'm a beginner Python coder and this is the first program that I have ever programmed.
Please suggest improvements/bugs. Here's the link to the code.



global hp
hp = 20
global dice
import random
dice = random.randint(3,5)
global beardamage
import random
beardamage = random.randint(1,9)
global hunger
hunger = 5
global spiderhp
spiderhp = 5
global bearhp
bearhp = 10
global potion
potion = 0
global xp
xp = 0
# |Data storage for part 1|
#_______________________________________________________________________________
#
x = ("attack")
passwordcode = ("5665598")
road =("left")
key = ("key")
choicekey = ("yes")
hutchoice = ("gotoit")
menucheat = ("cheat menu")
menureadme = ("readme")
menustart = ("start game")
death = 1
menuhelp = ("help")
potionadd = 1
examinationyes = ("examine")
SmallHealing = random.randint(8,15)
cheat01 = ("cheat_01")
cheat02 = ("shutdown")
bearxp = 100
spiderxp = 350
bow = random.randint(5,10)
passwordcheat = ("password")
# |End of data storage for adventure part 1.|
#_______________________________________________________________________________
text = ("Loading files....")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.5)
time.sleep(0.01)
text = ("-1%||||||||||||||||100%-")
print("")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.01)
time.sleep(0.01)
print("")
import time
time.sleep(1)
import os
import sys
os.system("CLS")
print("")
print("")
print(" ")
print(" _ _ _ _ _ ")
print(" / __| |_ _____ _ __ | |_ _ _ _ __ ___ _ __ _ _| |_| |__ ___ _ __ ")
print(" / _ / _` / / _ '_ | __| | | | '__/ _ | '_ | | | | __| '_ / _ | '_ ")
print(" / ___ (_| | V / __/ | | | |_| |_| | | | __/ | |_) | |_| | |_| | | | (_) | | | |")
print("/_/ ___,_| _/ ___|_| |_|__|__,_|_| ___| | .__/ __, |__|_| |_|___/|_| |_|")
print(" |_| |___/ ")

print(" //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\")
print(" // || Main menu || \")
print("||______________________________||_____________||________________________||")
print("|| || HELP || ||")
print("||______________________________||_____________||________________________||")
print("|| || README || ||")
print("||______________________________||_____________||________________________||")
print("|| || START GAME || ||")
print("||______________________________||_____________||________________________||")
print(" \ || CHEAT MENU || //")
print(" \|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||//")
thing = 2
thini = 1
print(" Enter the selected command")
commandprompt = input("")
while thing > thini:
if commandprompt == menucheat:
print("Enter the password")
commandprompt = input("")
if commandprompt == passwordcheat:
print("Access granted")
print("")
print("Cheat list")
print("",(cheat01)," - Walkthrough")
print("",(cheat02)," - You should know what that one does")
commandprompt = input("")
if commandprompt == cheat01:
print("Cheat activated")
print("")
print("")
import time
time.sleep(2)
print("WALKTHROUGH")
print("HIT/RUN")
print("Examine")
print("Left")
print("yes")
print("go")
print("5665598")
print("HIT/RUN")
elif commandprompt == cheat02:
yes = ("yes")
no = ("no")
print("Are you sure?")
commandprompt = input("")
if commandprompt == yes:
print("Shut down in 10 seconds")
import os
os.system("shutdown -r -t 10 ")
elif commandprompt == no:
print("Terminated")
break
else:
print("Unknown command!")





if commandprompt == menustart:
print("Press enter to start")
input("")
break
commandprompt = input("")
if commandprompt == menureadme:
print("_________________________________")
print("Made by AO")
print("Version 1.8")
print("Dice system inplemented")
print("Global system")
print("Part 2 done")
print("900+ lines of coding")
print("_________________________________")
import time
time.sleep(5)
if commandprompt == menuhelp:
print("Help")
print("Type commands exactly, no caps")




else:
print("Invalid command!")
import time
time.sleep(5)
import os
import sys
os.system("CLS")

import time
import sys
from random import randrange

text = ("This is a story which set's back long before golden age...")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
text = ("In a time of witchcraft, mysteries and myths.")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
import time
time.sleep(1)
print("")
text = ("!||SLENDER THE GAME||!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You have 20 hitpoints.")
print("You have 5 hunger bars.")
import time
time.sleep(3)
print("")
import time
time.sleep(1)
text = ("You - Where I'm i?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You stand up")
import time
time.sleep(1)
text = ("You - Hmm.")
import os
import sys
os.system("CLS")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You approach the door")
print("But you hear a growling noise.")
import time
time.sleep(2)
print("The door is smashed in half as a monster sees you.")
import time
time.sleep(2)
print("It's a giant bear!")
import time
time.sleep(2)
text = ("You - Ahhhh! Wait, It's so small!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
text = ("You - What could possibly go wrong?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("The bear looks agressive. The bear has",(bearhp)," hp. Type attack or run")
y =input("")
if (y) == (x):
while (bearhp > death):
print("You hit the bear")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
import os
import sys
os.system("CLS")
bearhp = bearhp - dice
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
import os
import sys
os.system("CLS")
break
import time
time.sleep(3)
print("The bear does ",(beardamage),"damage")
hp = hp - beardamage
import time
time.sleep(2)
import os
import sys
os.system("CLS")
print("")
if hp < death:
print("OW! The bear does final blow against you!")
print("You have died")
import time
time.sleep(2)
print("Game over")
import time
time.sleep(99999)
break
import time
time.sleep(3)
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
break
import time
print("You have",(hp),"left")
print("")
import time
time.sleep(1)
print("The bear has",(bearhp),"left")
import time
time.sleep(1)
import os
import sys
os.system("CLS")

else:
print("You run away.")
import time
time.sleep(2)
print("You have wasted your hunger bar")
hungerbar = 1
hunger = hunger - hunger
print("Hunger is",(hungerbar)," ")
import time
time.sleep(3)



time.sleep(2)
import time
import sys
from random import randrange
text = ("You are in a strange room")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You see a shelf")
import time
time.sleep(2)
print("Hint - try examining it.","examine")
examination = input("")
if (examination) == (examinationyes):
print("You find a small vial")
import time
time.sleep(2)
print("It's a potion of healing!")
import time
time.sleep(2)
print("You take the potion")
potion = potion + potionadd
import time
time.sleep(2)
print("You have",(potion),"in your inventury")
import time
time.sleep(2)
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
else:
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
print("You see a road which splits into 2 paths.")
print("Do you wish to go left or right?")
roadchoice = input("")
if (roadchoice) == (road):
print("You go left")
else:
print("You go right")
import time
time.sleep(5)

print("You are walking slowly down the road.")
import time
time.sleep(3)
print("You see a slender man.")
import time
time.sleep(3)
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
print("GAME OVER")
time.sleep(3)
print("SLENDER MAN HAS GOT YOU")
import time
time.sleep(5)
print("END OF GAME! SLENDER TEXT. THE GAME")
import time
time.sleep(60)
print("As you are walking down the misty road...")
import time
time.sleep(3)
print("You see a small, old note.")
print("Do you want to look at it?")
keychoices = input("")
if (keychoices) == (choicekey):
print("Note - To open the ancient door, you must say 5665598")
import time
time.sleep(5)
print("Remember not to forget it, otherwise you will die!")
import time
time.sleep(2)
print("SteveXI - If you are reading this, then i am dead.")
import time
time.sleep(2)
print("SteveXI - Good luck!")
import time
time.sleep(10)
import os
import sys
os.system("CLS")

else:
print("You leave the note alone.")

import os
import sys
os.system("CLS")

import time
time.sleep(3)
print("In the distance, you see a small hut. It stands on a small hill.")
import time
time.sleep(3)
print("You make a camp")
import time
time.sleep(2)
print("What do you want to do now?")
print(" 1) go 2) or do nothing")
hutchoices = input("")
something = 10
somethings = 1
hutchoiceyes = ("go")
while something > somethings:
if (hutchoices) == (hutchoiceyes):
print("You walk to the hut.")
import time
time.sleep(5)
break


else:
print("You do nothing.")
hutchoices = input("")


import time
time.sleep(3)
import time
time.sleep(5)
print("You find an ancient sandstone door.")
import time
time.sleep(5)
print("Say the inscription, if you know it.")
password = input("")
if (password) == (passwordcode):
print("The door slides slowly out of the way.")
print("You go down a cobweb filled passage")
import time
time.sleep(3)
print(" You have completed the game, Welldone!")
else:
print("A trapdoor opens beneath you!")
print("You fall down to your doom.")
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
import time
time.sleep(5)
print("You die, End of game.")
import time
time.sleep(5)
print("SLENDERTEXT THE GAME")
import time
time.sleep(60)
def clearscreen():
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system('CLS')
print("Adventure part 2")
import time
time.sleep(4)
print("Adventure start's now!")
import time
time.sleep(2)

#This is part 2 of the adventure. All data must be below.
#All data will be stored and loaded below.
#_____________________________________________________________________________
spiderchoiseyes = ("hit")
spiderchoiseno = ("no")
reservespace = ("")
roadchoice1exec = ("1")
roadchoice2exec = ("2")
villager = ("yes")
hammerchoiceexec = ("yes")
hungertakeaway = 1
spiderdamage = random.randint(1,8)
global acid
acid = 0
global portion
potion = 0
global queenhp
queenhp = 30
queendamage = random.randint(3,6)
#_____________________________________________________________________________

print("You start the adventure")
print("As you walk to the entrance, you see a giant spider!")
import time
time.sleep(3)
print("You need to hit it")
import time
time.sleep(3)
print("Hit it as many times as it takes to kill it.")
import time
time.sleep(2)
spider = input("")
if (spider) == (spiderchoiseyes):
while (spiderhp > death):
print("You hit the spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
spiderhp = spiderhp - dice
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
time.sleep(3)
print("The spider does ",(spiderdamage),"damage")
print("")
if hp < death:
print("OW! The spider does final blow against you!")
print("You have died")
import time
time.sleep(120)
break
hp = hp - spiderdamage


import time
time.sleep(3)
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
print("You have",(hp),"left")
import time
time.sleep(1)
print("The spider ",(spiderhp),"left")


else:
print("You run away!")
import time
time.sleep(2)
print("As you walk down the read slowly.")
import time
time.sleep(2)
print("You see 2 roads again.")
import time
time.sleep(2)
print("There's two roads.")
import time
time.sleep(2)
#Road choices start's from here!
print("There's 2 choises")
print("Press enter to see the roads")
input("")
print("2 There's a road leading to a cave")
input("")
print("1 There's second road, it's leading to a dark forest")
import time
time.sleep(2)
print("Which road do you want to go to? 1 or 2.")
roadchoice2 = input("")
if (roadchoice2) == (roadchoice2exec):
print("You have gone left")
import time
time.sleep(3)
print("You are walking to the cave")
import time
time.sleep(2)
print("You see a muddy footsteps leading to a massive cave.")
import time
time.sleep("1")
print("You see a pickaxe, do you want to examine and add it to your inventury?")
hammerchoice = input("")
if (hammerchoice) == (hammerchoiceexec):
print("You examine the pickaxe")
import time
time.sleep(2)
print("The axe looks a bit rusty")
import time
time.sleep(2)
print("It might have a use later on.")
else:
print("You walk past it")
import time
time.sleep(2)
print("You continue to walk towards the cave")

import time
time.sleep
print("Your hunger level",hunger)
import time
time.sleep(1)
print("You - You feel hungry, try seaching for a food source")

elif (roadchoice2) == (roadchoice1exec):
print("You have gone right")
import time
time.sleep(3)
print("As are walking to the dark forest.")
import time
time.sleep(2)
print("Mist slowly decends down to the forest floor")
import time
time.sleep(3)
print("You are a bit lost")
import time
time.sleep(3)
print("There's a full moon, but the mist is blinding your view.")
import time
time.sleep(3)
print("There's a villager")
import time
time.sleep(3)
print("Do you wish to talk to him?")
villagertalk = input("")
else:
print("Slenderman killed you")
print("End of the game")
import time
time.sleep(60)


if (villagertalk) == (villager):
print("You start a conversation with him")
import time
time.sleep(3)
print("Villagersteve - Watch out for those woods")
import time
time.sleep(3)
print("Villagersteve - These woods contain the most brutal undead.")
import time
time.sleep(2)
print("Villagersteve - Here, Take this bow.")
import time
time.sleep(3)
print("You - Item aquired.")
import time
time.sleep(2)
print("Villagersteve - Wait, I must tell you...")
import time
time.sleep(3)
print("You - You hear a screeching noise.")
import time
time.sleep(3)
print("Villagerbob - I must runnnnnn.......THEY ARE COMING FOR ME!")
import time
time.sleep(3)
print("Villagersteve runs away.")
import time
time.sleep(3)
value = 0
print("Suddenly, You blacked out")
time.sleep(2)
print("You find yourself in a strange cave...")
import time
time.sleep(2)
if value < potion:
print("You think, you need to use a portion now.")
import time
time.sleep(2)
print("Do you want to use potion now?")
rawinput = input("")
boolean = ("yes")
if rawinput == boolean:
decreasevalue = 1
print("You have used the potion!")
potion = potion - decreasevalue
import time
time.sleep(2)
print("You have",(potion),"left")
import time
time.sleep(2)
print("You gain",(SmallHealing),"hp")
hp = hp + SmallHealing
import time
time.sleep(2)
print("You have now",(hp),"left")


import time
time.sleep(2)
print("Suddenly, you see a gigantic spider!")
import time
time.sleep(2)
print("The queen has",(queenhp),"hp")
import time
time.sleep(2)
print("The battle beggins!")
while queenhp > death:
print("You hit queen spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
print("Spider queen has",(queenhp),"left")
print("")
queenhp = queenhp - dice
if queenhp == death:
print("You do a final blow against the queen!")
print("")
print("The queen spider has died")
import time
time.sleep(2)
print("You finish the game!")
import time
time.sleep(2)
print("To be continued....")
break
import time
time.sleep(3)
print("The spider does ",(queendamage),"damage")
queendamage = queendamage - hp
print("You have",(hp),"left")
hp = hp - queendamage
print("")
if hp == death:
print("OW! The spider rips you in half.")
print("You have died")
import time
time.sleep(120)
break









share|improve this question




















  • 1




    For a start, please put all the import at the beginning of your file.
    – Josay
    Jan 16 '13 at 23:54















up vote
7
down vote

favorite












I'm a beginner Python coder and this is the first program that I have ever programmed.
Please suggest improvements/bugs. Here's the link to the code.



global hp
hp = 20
global dice
import random
dice = random.randint(3,5)
global beardamage
import random
beardamage = random.randint(1,9)
global hunger
hunger = 5
global spiderhp
spiderhp = 5
global bearhp
bearhp = 10
global potion
potion = 0
global xp
xp = 0
# |Data storage for part 1|
#_______________________________________________________________________________
#
x = ("attack")
passwordcode = ("5665598")
road =("left")
key = ("key")
choicekey = ("yes")
hutchoice = ("gotoit")
menucheat = ("cheat menu")
menureadme = ("readme")
menustart = ("start game")
death = 1
menuhelp = ("help")
potionadd = 1
examinationyes = ("examine")
SmallHealing = random.randint(8,15)
cheat01 = ("cheat_01")
cheat02 = ("shutdown")
bearxp = 100
spiderxp = 350
bow = random.randint(5,10)
passwordcheat = ("password")
# |End of data storage for adventure part 1.|
#_______________________________________________________________________________
text = ("Loading files....")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.5)
time.sleep(0.01)
text = ("-1%||||||||||||||||100%-")
print("")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.01)
time.sleep(0.01)
print("")
import time
time.sleep(1)
import os
import sys
os.system("CLS")
print("")
print("")
print(" ")
print(" _ _ _ _ _ ")
print(" / __| |_ _____ _ __ | |_ _ _ _ __ ___ _ __ _ _| |_| |__ ___ _ __ ")
print(" / _ / _` / / _ '_ | __| | | | '__/ _ | '_ | | | | __| '_ / _ | '_ ")
print(" / ___ (_| | V / __/ | | | |_| |_| | | | __/ | |_) | |_| | |_| | | | (_) | | | |")
print("/_/ ___,_| _/ ___|_| |_|__|__,_|_| ___| | .__/ __, |__|_| |_|___/|_| |_|")
print(" |_| |___/ ")

print(" //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\")
print(" // || Main menu || \")
print("||______________________________||_____________||________________________||")
print("|| || HELP || ||")
print("||______________________________||_____________||________________________||")
print("|| || README || ||")
print("||______________________________||_____________||________________________||")
print("|| || START GAME || ||")
print("||______________________________||_____________||________________________||")
print(" \ || CHEAT MENU || //")
print(" \|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||//")
thing = 2
thini = 1
print(" Enter the selected command")
commandprompt = input("")
while thing > thini:
if commandprompt == menucheat:
print("Enter the password")
commandprompt = input("")
if commandprompt == passwordcheat:
print("Access granted")
print("")
print("Cheat list")
print("",(cheat01)," - Walkthrough")
print("",(cheat02)," - You should know what that one does")
commandprompt = input("")
if commandprompt == cheat01:
print("Cheat activated")
print("")
print("")
import time
time.sleep(2)
print("WALKTHROUGH")
print("HIT/RUN")
print("Examine")
print("Left")
print("yes")
print("go")
print("5665598")
print("HIT/RUN")
elif commandprompt == cheat02:
yes = ("yes")
no = ("no")
print("Are you sure?")
commandprompt = input("")
if commandprompt == yes:
print("Shut down in 10 seconds")
import os
os.system("shutdown -r -t 10 ")
elif commandprompt == no:
print("Terminated")
break
else:
print("Unknown command!")





if commandprompt == menustart:
print("Press enter to start")
input("")
break
commandprompt = input("")
if commandprompt == menureadme:
print("_________________________________")
print("Made by AO")
print("Version 1.8")
print("Dice system inplemented")
print("Global system")
print("Part 2 done")
print("900+ lines of coding")
print("_________________________________")
import time
time.sleep(5)
if commandprompt == menuhelp:
print("Help")
print("Type commands exactly, no caps")




else:
print("Invalid command!")
import time
time.sleep(5)
import os
import sys
os.system("CLS")

import time
import sys
from random import randrange

text = ("This is a story which set's back long before golden age...")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
text = ("In a time of witchcraft, mysteries and myths.")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
import time
time.sleep(1)
print("")
text = ("!||SLENDER THE GAME||!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You have 20 hitpoints.")
print("You have 5 hunger bars.")
import time
time.sleep(3)
print("")
import time
time.sleep(1)
text = ("You - Where I'm i?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You stand up")
import time
time.sleep(1)
text = ("You - Hmm.")
import os
import sys
os.system("CLS")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You approach the door")
print("But you hear a growling noise.")
import time
time.sleep(2)
print("The door is smashed in half as a monster sees you.")
import time
time.sleep(2)
print("It's a giant bear!")
import time
time.sleep(2)
text = ("You - Ahhhh! Wait, It's so small!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
text = ("You - What could possibly go wrong?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("The bear looks agressive. The bear has",(bearhp)," hp. Type attack or run")
y =input("")
if (y) == (x):
while (bearhp > death):
print("You hit the bear")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
import os
import sys
os.system("CLS")
bearhp = bearhp - dice
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
import os
import sys
os.system("CLS")
break
import time
time.sleep(3)
print("The bear does ",(beardamage),"damage")
hp = hp - beardamage
import time
time.sleep(2)
import os
import sys
os.system("CLS")
print("")
if hp < death:
print("OW! The bear does final blow against you!")
print("You have died")
import time
time.sleep(2)
print("Game over")
import time
time.sleep(99999)
break
import time
time.sleep(3)
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
break
import time
print("You have",(hp),"left")
print("")
import time
time.sleep(1)
print("The bear has",(bearhp),"left")
import time
time.sleep(1)
import os
import sys
os.system("CLS")

else:
print("You run away.")
import time
time.sleep(2)
print("You have wasted your hunger bar")
hungerbar = 1
hunger = hunger - hunger
print("Hunger is",(hungerbar)," ")
import time
time.sleep(3)



time.sleep(2)
import time
import sys
from random import randrange
text = ("You are in a strange room")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You see a shelf")
import time
time.sleep(2)
print("Hint - try examining it.","examine")
examination = input("")
if (examination) == (examinationyes):
print("You find a small vial")
import time
time.sleep(2)
print("It's a potion of healing!")
import time
time.sleep(2)
print("You take the potion")
potion = potion + potionadd
import time
time.sleep(2)
print("You have",(potion),"in your inventury")
import time
time.sleep(2)
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
else:
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
print("You see a road which splits into 2 paths.")
print("Do you wish to go left or right?")
roadchoice = input("")
if (roadchoice) == (road):
print("You go left")
else:
print("You go right")
import time
time.sleep(5)

print("You are walking slowly down the road.")
import time
time.sleep(3)
print("You see a slender man.")
import time
time.sleep(3)
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
print("GAME OVER")
time.sleep(3)
print("SLENDER MAN HAS GOT YOU")
import time
time.sleep(5)
print("END OF GAME! SLENDER TEXT. THE GAME")
import time
time.sleep(60)
print("As you are walking down the misty road...")
import time
time.sleep(3)
print("You see a small, old note.")
print("Do you want to look at it?")
keychoices = input("")
if (keychoices) == (choicekey):
print("Note - To open the ancient door, you must say 5665598")
import time
time.sleep(5)
print("Remember not to forget it, otherwise you will die!")
import time
time.sleep(2)
print("SteveXI - If you are reading this, then i am dead.")
import time
time.sleep(2)
print("SteveXI - Good luck!")
import time
time.sleep(10)
import os
import sys
os.system("CLS")

else:
print("You leave the note alone.")

import os
import sys
os.system("CLS")

import time
time.sleep(3)
print("In the distance, you see a small hut. It stands on a small hill.")
import time
time.sleep(3)
print("You make a camp")
import time
time.sleep(2)
print("What do you want to do now?")
print(" 1) go 2) or do nothing")
hutchoices = input("")
something = 10
somethings = 1
hutchoiceyes = ("go")
while something > somethings:
if (hutchoices) == (hutchoiceyes):
print("You walk to the hut.")
import time
time.sleep(5)
break


else:
print("You do nothing.")
hutchoices = input("")


import time
time.sleep(3)
import time
time.sleep(5)
print("You find an ancient sandstone door.")
import time
time.sleep(5)
print("Say the inscription, if you know it.")
password = input("")
if (password) == (passwordcode):
print("The door slides slowly out of the way.")
print("You go down a cobweb filled passage")
import time
time.sleep(3)
print(" You have completed the game, Welldone!")
else:
print("A trapdoor opens beneath you!")
print("You fall down to your doom.")
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
import time
time.sleep(5)
print("You die, End of game.")
import time
time.sleep(5)
print("SLENDERTEXT THE GAME")
import time
time.sleep(60)
def clearscreen():
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system('CLS')
print("Adventure part 2")
import time
time.sleep(4)
print("Adventure start's now!")
import time
time.sleep(2)

#This is part 2 of the adventure. All data must be below.
#All data will be stored and loaded below.
#_____________________________________________________________________________
spiderchoiseyes = ("hit")
spiderchoiseno = ("no")
reservespace = ("")
roadchoice1exec = ("1")
roadchoice2exec = ("2")
villager = ("yes")
hammerchoiceexec = ("yes")
hungertakeaway = 1
spiderdamage = random.randint(1,8)
global acid
acid = 0
global portion
potion = 0
global queenhp
queenhp = 30
queendamage = random.randint(3,6)
#_____________________________________________________________________________

print("You start the adventure")
print("As you walk to the entrance, you see a giant spider!")
import time
time.sleep(3)
print("You need to hit it")
import time
time.sleep(3)
print("Hit it as many times as it takes to kill it.")
import time
time.sleep(2)
spider = input("")
if (spider) == (spiderchoiseyes):
while (spiderhp > death):
print("You hit the spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
spiderhp = spiderhp - dice
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
time.sleep(3)
print("The spider does ",(spiderdamage),"damage")
print("")
if hp < death:
print("OW! The spider does final blow against you!")
print("You have died")
import time
time.sleep(120)
break
hp = hp - spiderdamage


import time
time.sleep(3)
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
print("You have",(hp),"left")
import time
time.sleep(1)
print("The spider ",(spiderhp),"left")


else:
print("You run away!")
import time
time.sleep(2)
print("As you walk down the read slowly.")
import time
time.sleep(2)
print("You see 2 roads again.")
import time
time.sleep(2)
print("There's two roads.")
import time
time.sleep(2)
#Road choices start's from here!
print("There's 2 choises")
print("Press enter to see the roads")
input("")
print("2 There's a road leading to a cave")
input("")
print("1 There's second road, it's leading to a dark forest")
import time
time.sleep(2)
print("Which road do you want to go to? 1 or 2.")
roadchoice2 = input("")
if (roadchoice2) == (roadchoice2exec):
print("You have gone left")
import time
time.sleep(3)
print("You are walking to the cave")
import time
time.sleep(2)
print("You see a muddy footsteps leading to a massive cave.")
import time
time.sleep("1")
print("You see a pickaxe, do you want to examine and add it to your inventury?")
hammerchoice = input("")
if (hammerchoice) == (hammerchoiceexec):
print("You examine the pickaxe")
import time
time.sleep(2)
print("The axe looks a bit rusty")
import time
time.sleep(2)
print("It might have a use later on.")
else:
print("You walk past it")
import time
time.sleep(2)
print("You continue to walk towards the cave")

import time
time.sleep
print("Your hunger level",hunger)
import time
time.sleep(1)
print("You - You feel hungry, try seaching for a food source")

elif (roadchoice2) == (roadchoice1exec):
print("You have gone right")
import time
time.sleep(3)
print("As are walking to the dark forest.")
import time
time.sleep(2)
print("Mist slowly decends down to the forest floor")
import time
time.sleep(3)
print("You are a bit lost")
import time
time.sleep(3)
print("There's a full moon, but the mist is blinding your view.")
import time
time.sleep(3)
print("There's a villager")
import time
time.sleep(3)
print("Do you wish to talk to him?")
villagertalk = input("")
else:
print("Slenderman killed you")
print("End of the game")
import time
time.sleep(60)


if (villagertalk) == (villager):
print("You start a conversation with him")
import time
time.sleep(3)
print("Villagersteve - Watch out for those woods")
import time
time.sleep(3)
print("Villagersteve - These woods contain the most brutal undead.")
import time
time.sleep(2)
print("Villagersteve - Here, Take this bow.")
import time
time.sleep(3)
print("You - Item aquired.")
import time
time.sleep(2)
print("Villagersteve - Wait, I must tell you...")
import time
time.sleep(3)
print("You - You hear a screeching noise.")
import time
time.sleep(3)
print("Villagerbob - I must runnnnnn.......THEY ARE COMING FOR ME!")
import time
time.sleep(3)
print("Villagersteve runs away.")
import time
time.sleep(3)
value = 0
print("Suddenly, You blacked out")
time.sleep(2)
print("You find yourself in a strange cave...")
import time
time.sleep(2)
if value < potion:
print("You think, you need to use a portion now.")
import time
time.sleep(2)
print("Do you want to use potion now?")
rawinput = input("")
boolean = ("yes")
if rawinput == boolean:
decreasevalue = 1
print("You have used the potion!")
potion = potion - decreasevalue
import time
time.sleep(2)
print("You have",(potion),"left")
import time
time.sleep(2)
print("You gain",(SmallHealing),"hp")
hp = hp + SmallHealing
import time
time.sleep(2)
print("You have now",(hp),"left")


import time
time.sleep(2)
print("Suddenly, you see a gigantic spider!")
import time
time.sleep(2)
print("The queen has",(queenhp),"hp")
import time
time.sleep(2)
print("The battle beggins!")
while queenhp > death:
print("You hit queen spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
print("Spider queen has",(queenhp),"left")
print("")
queenhp = queenhp - dice
if queenhp == death:
print("You do a final blow against the queen!")
print("")
print("The queen spider has died")
import time
time.sleep(2)
print("You finish the game!")
import time
time.sleep(2)
print("To be continued....")
break
import time
time.sleep(3)
print("The spider does ",(queendamage),"damage")
queendamage = queendamage - hp
print("You have",(hp),"left")
hp = hp - queendamage
print("")
if hp == death:
print("OW! The spider rips you in half.")
print("You have died")
import time
time.sleep(120)
break









share|improve this question




















  • 1




    For a start, please put all the import at the beginning of your file.
    – Josay
    Jan 16 '13 at 23:54













up vote
7
down vote

favorite









up vote
7
down vote

favorite











I'm a beginner Python coder and this is the first program that I have ever programmed.
Please suggest improvements/bugs. Here's the link to the code.



global hp
hp = 20
global dice
import random
dice = random.randint(3,5)
global beardamage
import random
beardamage = random.randint(1,9)
global hunger
hunger = 5
global spiderhp
spiderhp = 5
global bearhp
bearhp = 10
global potion
potion = 0
global xp
xp = 0
# |Data storage for part 1|
#_______________________________________________________________________________
#
x = ("attack")
passwordcode = ("5665598")
road =("left")
key = ("key")
choicekey = ("yes")
hutchoice = ("gotoit")
menucheat = ("cheat menu")
menureadme = ("readme")
menustart = ("start game")
death = 1
menuhelp = ("help")
potionadd = 1
examinationyes = ("examine")
SmallHealing = random.randint(8,15)
cheat01 = ("cheat_01")
cheat02 = ("shutdown")
bearxp = 100
spiderxp = 350
bow = random.randint(5,10)
passwordcheat = ("password")
# |End of data storage for adventure part 1.|
#_______________________________________________________________________________
text = ("Loading files....")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.5)
time.sleep(0.01)
text = ("-1%||||||||||||||||100%-")
print("")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.01)
time.sleep(0.01)
print("")
import time
time.sleep(1)
import os
import sys
os.system("CLS")
print("")
print("")
print(" ")
print(" _ _ _ _ _ ")
print(" / __| |_ _____ _ __ | |_ _ _ _ __ ___ _ __ _ _| |_| |__ ___ _ __ ")
print(" / _ / _` / / _ '_ | __| | | | '__/ _ | '_ | | | | __| '_ / _ | '_ ")
print(" / ___ (_| | V / __/ | | | |_| |_| | | | __/ | |_) | |_| | |_| | | | (_) | | | |")
print("/_/ ___,_| _/ ___|_| |_|__|__,_|_| ___| | .__/ __, |__|_| |_|___/|_| |_|")
print(" |_| |___/ ")

print(" //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\")
print(" // || Main menu || \")
print("||______________________________||_____________||________________________||")
print("|| || HELP || ||")
print("||______________________________||_____________||________________________||")
print("|| || README || ||")
print("||______________________________||_____________||________________________||")
print("|| || START GAME || ||")
print("||______________________________||_____________||________________________||")
print(" \ || CHEAT MENU || //")
print(" \|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||//")
thing = 2
thini = 1
print(" Enter the selected command")
commandprompt = input("")
while thing > thini:
if commandprompt == menucheat:
print("Enter the password")
commandprompt = input("")
if commandprompt == passwordcheat:
print("Access granted")
print("")
print("Cheat list")
print("",(cheat01)," - Walkthrough")
print("",(cheat02)," - You should know what that one does")
commandprompt = input("")
if commandprompt == cheat01:
print("Cheat activated")
print("")
print("")
import time
time.sleep(2)
print("WALKTHROUGH")
print("HIT/RUN")
print("Examine")
print("Left")
print("yes")
print("go")
print("5665598")
print("HIT/RUN")
elif commandprompt == cheat02:
yes = ("yes")
no = ("no")
print("Are you sure?")
commandprompt = input("")
if commandprompt == yes:
print("Shut down in 10 seconds")
import os
os.system("shutdown -r -t 10 ")
elif commandprompt == no:
print("Terminated")
break
else:
print("Unknown command!")





if commandprompt == menustart:
print("Press enter to start")
input("")
break
commandprompt = input("")
if commandprompt == menureadme:
print("_________________________________")
print("Made by AO")
print("Version 1.8")
print("Dice system inplemented")
print("Global system")
print("Part 2 done")
print("900+ lines of coding")
print("_________________________________")
import time
time.sleep(5)
if commandprompt == menuhelp:
print("Help")
print("Type commands exactly, no caps")




else:
print("Invalid command!")
import time
time.sleep(5)
import os
import sys
os.system("CLS")

import time
import sys
from random import randrange

text = ("This is a story which set's back long before golden age...")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
text = ("In a time of witchcraft, mysteries and myths.")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
import time
time.sleep(1)
print("")
text = ("!||SLENDER THE GAME||!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You have 20 hitpoints.")
print("You have 5 hunger bars.")
import time
time.sleep(3)
print("")
import time
time.sleep(1)
text = ("You - Where I'm i?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You stand up")
import time
time.sleep(1)
text = ("You - Hmm.")
import os
import sys
os.system("CLS")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You approach the door")
print("But you hear a growling noise.")
import time
time.sleep(2)
print("The door is smashed in half as a monster sees you.")
import time
time.sleep(2)
print("It's a giant bear!")
import time
time.sleep(2)
text = ("You - Ahhhh! Wait, It's so small!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
text = ("You - What could possibly go wrong?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("The bear looks agressive. The bear has",(bearhp)," hp. Type attack or run")
y =input("")
if (y) == (x):
while (bearhp > death):
print("You hit the bear")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
import os
import sys
os.system("CLS")
bearhp = bearhp - dice
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
import os
import sys
os.system("CLS")
break
import time
time.sleep(3)
print("The bear does ",(beardamage),"damage")
hp = hp - beardamage
import time
time.sleep(2)
import os
import sys
os.system("CLS")
print("")
if hp < death:
print("OW! The bear does final blow against you!")
print("You have died")
import time
time.sleep(2)
print("Game over")
import time
time.sleep(99999)
break
import time
time.sleep(3)
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
break
import time
print("You have",(hp),"left")
print("")
import time
time.sleep(1)
print("The bear has",(bearhp),"left")
import time
time.sleep(1)
import os
import sys
os.system("CLS")

else:
print("You run away.")
import time
time.sleep(2)
print("You have wasted your hunger bar")
hungerbar = 1
hunger = hunger - hunger
print("Hunger is",(hungerbar)," ")
import time
time.sleep(3)



time.sleep(2)
import time
import sys
from random import randrange
text = ("You are in a strange room")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You see a shelf")
import time
time.sleep(2)
print("Hint - try examining it.","examine")
examination = input("")
if (examination) == (examinationyes):
print("You find a small vial")
import time
time.sleep(2)
print("It's a potion of healing!")
import time
time.sleep(2)
print("You take the potion")
potion = potion + potionadd
import time
time.sleep(2)
print("You have",(potion),"in your inventury")
import time
time.sleep(2)
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
else:
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
print("You see a road which splits into 2 paths.")
print("Do you wish to go left or right?")
roadchoice = input("")
if (roadchoice) == (road):
print("You go left")
else:
print("You go right")
import time
time.sleep(5)

print("You are walking slowly down the road.")
import time
time.sleep(3)
print("You see a slender man.")
import time
time.sleep(3)
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
print("GAME OVER")
time.sleep(3)
print("SLENDER MAN HAS GOT YOU")
import time
time.sleep(5)
print("END OF GAME! SLENDER TEXT. THE GAME")
import time
time.sleep(60)
print("As you are walking down the misty road...")
import time
time.sleep(3)
print("You see a small, old note.")
print("Do you want to look at it?")
keychoices = input("")
if (keychoices) == (choicekey):
print("Note - To open the ancient door, you must say 5665598")
import time
time.sleep(5)
print("Remember not to forget it, otherwise you will die!")
import time
time.sleep(2)
print("SteveXI - If you are reading this, then i am dead.")
import time
time.sleep(2)
print("SteveXI - Good luck!")
import time
time.sleep(10)
import os
import sys
os.system("CLS")

else:
print("You leave the note alone.")

import os
import sys
os.system("CLS")

import time
time.sleep(3)
print("In the distance, you see a small hut. It stands on a small hill.")
import time
time.sleep(3)
print("You make a camp")
import time
time.sleep(2)
print("What do you want to do now?")
print(" 1) go 2) or do nothing")
hutchoices = input("")
something = 10
somethings = 1
hutchoiceyes = ("go")
while something > somethings:
if (hutchoices) == (hutchoiceyes):
print("You walk to the hut.")
import time
time.sleep(5)
break


else:
print("You do nothing.")
hutchoices = input("")


import time
time.sleep(3)
import time
time.sleep(5)
print("You find an ancient sandstone door.")
import time
time.sleep(5)
print("Say the inscription, if you know it.")
password = input("")
if (password) == (passwordcode):
print("The door slides slowly out of the way.")
print("You go down a cobweb filled passage")
import time
time.sleep(3)
print(" You have completed the game, Welldone!")
else:
print("A trapdoor opens beneath you!")
print("You fall down to your doom.")
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
import time
time.sleep(5)
print("You die, End of game.")
import time
time.sleep(5)
print("SLENDERTEXT THE GAME")
import time
time.sleep(60)
def clearscreen():
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system('CLS')
print("Adventure part 2")
import time
time.sleep(4)
print("Adventure start's now!")
import time
time.sleep(2)

#This is part 2 of the adventure. All data must be below.
#All data will be stored and loaded below.
#_____________________________________________________________________________
spiderchoiseyes = ("hit")
spiderchoiseno = ("no")
reservespace = ("")
roadchoice1exec = ("1")
roadchoice2exec = ("2")
villager = ("yes")
hammerchoiceexec = ("yes")
hungertakeaway = 1
spiderdamage = random.randint(1,8)
global acid
acid = 0
global portion
potion = 0
global queenhp
queenhp = 30
queendamage = random.randint(3,6)
#_____________________________________________________________________________

print("You start the adventure")
print("As you walk to the entrance, you see a giant spider!")
import time
time.sleep(3)
print("You need to hit it")
import time
time.sleep(3)
print("Hit it as many times as it takes to kill it.")
import time
time.sleep(2)
spider = input("")
if (spider) == (spiderchoiseyes):
while (spiderhp > death):
print("You hit the spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
spiderhp = spiderhp - dice
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
time.sleep(3)
print("The spider does ",(spiderdamage),"damage")
print("")
if hp < death:
print("OW! The spider does final blow against you!")
print("You have died")
import time
time.sleep(120)
break
hp = hp - spiderdamage


import time
time.sleep(3)
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
print("You have",(hp),"left")
import time
time.sleep(1)
print("The spider ",(spiderhp),"left")


else:
print("You run away!")
import time
time.sleep(2)
print("As you walk down the read slowly.")
import time
time.sleep(2)
print("You see 2 roads again.")
import time
time.sleep(2)
print("There's two roads.")
import time
time.sleep(2)
#Road choices start's from here!
print("There's 2 choises")
print("Press enter to see the roads")
input("")
print("2 There's a road leading to a cave")
input("")
print("1 There's second road, it's leading to a dark forest")
import time
time.sleep(2)
print("Which road do you want to go to? 1 or 2.")
roadchoice2 = input("")
if (roadchoice2) == (roadchoice2exec):
print("You have gone left")
import time
time.sleep(3)
print("You are walking to the cave")
import time
time.sleep(2)
print("You see a muddy footsteps leading to a massive cave.")
import time
time.sleep("1")
print("You see a pickaxe, do you want to examine and add it to your inventury?")
hammerchoice = input("")
if (hammerchoice) == (hammerchoiceexec):
print("You examine the pickaxe")
import time
time.sleep(2)
print("The axe looks a bit rusty")
import time
time.sleep(2)
print("It might have a use later on.")
else:
print("You walk past it")
import time
time.sleep(2)
print("You continue to walk towards the cave")

import time
time.sleep
print("Your hunger level",hunger)
import time
time.sleep(1)
print("You - You feel hungry, try seaching for a food source")

elif (roadchoice2) == (roadchoice1exec):
print("You have gone right")
import time
time.sleep(3)
print("As are walking to the dark forest.")
import time
time.sleep(2)
print("Mist slowly decends down to the forest floor")
import time
time.sleep(3)
print("You are a bit lost")
import time
time.sleep(3)
print("There's a full moon, but the mist is blinding your view.")
import time
time.sleep(3)
print("There's a villager")
import time
time.sleep(3)
print("Do you wish to talk to him?")
villagertalk = input("")
else:
print("Slenderman killed you")
print("End of the game")
import time
time.sleep(60)


if (villagertalk) == (villager):
print("You start a conversation with him")
import time
time.sleep(3)
print("Villagersteve - Watch out for those woods")
import time
time.sleep(3)
print("Villagersteve - These woods contain the most brutal undead.")
import time
time.sleep(2)
print("Villagersteve - Here, Take this bow.")
import time
time.sleep(3)
print("You - Item aquired.")
import time
time.sleep(2)
print("Villagersteve - Wait, I must tell you...")
import time
time.sleep(3)
print("You - You hear a screeching noise.")
import time
time.sleep(3)
print("Villagerbob - I must runnnnnn.......THEY ARE COMING FOR ME!")
import time
time.sleep(3)
print("Villagersteve runs away.")
import time
time.sleep(3)
value = 0
print("Suddenly, You blacked out")
time.sleep(2)
print("You find yourself in a strange cave...")
import time
time.sleep(2)
if value < potion:
print("You think, you need to use a portion now.")
import time
time.sleep(2)
print("Do you want to use potion now?")
rawinput = input("")
boolean = ("yes")
if rawinput == boolean:
decreasevalue = 1
print("You have used the potion!")
potion = potion - decreasevalue
import time
time.sleep(2)
print("You have",(potion),"left")
import time
time.sleep(2)
print("You gain",(SmallHealing),"hp")
hp = hp + SmallHealing
import time
time.sleep(2)
print("You have now",(hp),"left")


import time
time.sleep(2)
print("Suddenly, you see a gigantic spider!")
import time
time.sleep(2)
print("The queen has",(queenhp),"hp")
import time
time.sleep(2)
print("The battle beggins!")
while queenhp > death:
print("You hit queen spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
print("Spider queen has",(queenhp),"left")
print("")
queenhp = queenhp - dice
if queenhp == death:
print("You do a final blow against the queen!")
print("")
print("The queen spider has died")
import time
time.sleep(2)
print("You finish the game!")
import time
time.sleep(2)
print("To be continued....")
break
import time
time.sleep(3)
print("The spider does ",(queendamage),"damage")
queendamage = queendamage - hp
print("You have",(hp),"left")
hp = hp - queendamage
print("")
if hp == death:
print("OW! The spider rips you in half.")
print("You have died")
import time
time.sleep(120)
break









share|improve this question















I'm a beginner Python coder and this is the first program that I have ever programmed.
Please suggest improvements/bugs. Here's the link to the code.



global hp
hp = 20
global dice
import random
dice = random.randint(3,5)
global beardamage
import random
beardamage = random.randint(1,9)
global hunger
hunger = 5
global spiderhp
spiderhp = 5
global bearhp
bearhp = 10
global potion
potion = 0
global xp
xp = 0
# |Data storage for part 1|
#_______________________________________________________________________________
#
x = ("attack")
passwordcode = ("5665598")
road =("left")
key = ("key")
choicekey = ("yes")
hutchoice = ("gotoit")
menucheat = ("cheat menu")
menureadme = ("readme")
menustart = ("start game")
death = 1
menuhelp = ("help")
potionadd = 1
examinationyes = ("examine")
SmallHealing = random.randint(8,15)
cheat01 = ("cheat_01")
cheat02 = ("shutdown")
bearxp = 100
spiderxp = 350
bow = random.randint(5,10)
passwordcheat = ("password")
# |End of data storage for adventure part 1.|
#_______________________________________________________________________________
text = ("Loading files....")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.5)
time.sleep(0.01)
text = ("-1%||||||||||||||||100%-")
print("")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.01)
time.sleep(0.01)
print("")
import time
time.sleep(1)
import os
import sys
os.system("CLS")
print("")
print("")
print(" ")
print(" _ _ _ _ _ ")
print(" / __| |_ _____ _ __ | |_ _ _ _ __ ___ _ __ _ _| |_| |__ ___ _ __ ")
print(" / _ / _` / / _ '_ | __| | | | '__/ _ | '_ | | | | __| '_ / _ | '_ ")
print(" / ___ (_| | V / __/ | | | |_| |_| | | | __/ | |_) | |_| | |_| | | | (_) | | | |")
print("/_/ ___,_| _/ ___|_| |_|__|__,_|_| ___| | .__/ __, |__|_| |_|___/|_| |_|")
print(" |_| |___/ ")

print(" //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\")
print(" // || Main menu || \")
print("||______________________________||_____________||________________________||")
print("|| || HELP || ||")
print("||______________________________||_____________||________________________||")
print("|| || README || ||")
print("||______________________________||_____________||________________________||")
print("|| || START GAME || ||")
print("||______________________________||_____________||________________________||")
print(" \ || CHEAT MENU || //")
print(" \|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||//")
thing = 2
thini = 1
print(" Enter the selected command")
commandprompt = input("")
while thing > thini:
if commandprompt == menucheat:
print("Enter the password")
commandprompt = input("")
if commandprompt == passwordcheat:
print("Access granted")
print("")
print("Cheat list")
print("",(cheat01)," - Walkthrough")
print("",(cheat02)," - You should know what that one does")
commandprompt = input("")
if commandprompt == cheat01:
print("Cheat activated")
print("")
print("")
import time
time.sleep(2)
print("WALKTHROUGH")
print("HIT/RUN")
print("Examine")
print("Left")
print("yes")
print("go")
print("5665598")
print("HIT/RUN")
elif commandprompt == cheat02:
yes = ("yes")
no = ("no")
print("Are you sure?")
commandprompt = input("")
if commandprompt == yes:
print("Shut down in 10 seconds")
import os
os.system("shutdown -r -t 10 ")
elif commandprompt == no:
print("Terminated")
break
else:
print("Unknown command!")





if commandprompt == menustart:
print("Press enter to start")
input("")
break
commandprompt = input("")
if commandprompt == menureadme:
print("_________________________________")
print("Made by AO")
print("Version 1.8")
print("Dice system inplemented")
print("Global system")
print("Part 2 done")
print("900+ lines of coding")
print("_________________________________")
import time
time.sleep(5)
if commandprompt == menuhelp:
print("Help")
print("Type commands exactly, no caps")




else:
print("Invalid command!")
import time
time.sleep(5)
import os
import sys
os.system("CLS")

import time
import sys
from random import randrange

text = ("This is a story which set's back long before golden age...")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
text = ("In a time of witchcraft, mysteries and myths.")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
import time
time.sleep(1)
print("")
import time
time.sleep(1)
print("")
text = ("!||SLENDER THE GAME||!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You have 20 hitpoints.")
print("You have 5 hunger bars.")
import time
time.sleep(3)
print("")
import time
time.sleep(1)
text = ("You - Where I'm i?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You stand up")
import time
time.sleep(1)
text = ("You - Hmm.")
import os
import sys
os.system("CLS")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)

print("")
print("You approach the door")
print("But you hear a growling noise.")
import time
time.sleep(2)
print("The door is smashed in half as a monster sees you.")
import time
time.sleep(2)
print("It's a giant bear!")
import time
time.sleep(2)
text = ("You - Ahhhh! Wait, It's so small!")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
text = ("You - What could possibly go wrong?")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("The bear looks agressive. The bear has",(bearhp)," hp. Type attack or run")
y =input("")
if (y) == (x):
while (bearhp > death):
print("You hit the bear")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
import os
import sys
os.system("CLS")
bearhp = bearhp - dice
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
import os
import sys
os.system("CLS")
break
import time
time.sleep(3)
print("The bear does ",(beardamage),"damage")
hp = hp - beardamage
import time
time.sleep(2)
import os
import sys
os.system("CLS")
print("")
if hp < death:
print("OW! The bear does final blow against you!")
print("You have died")
import time
time.sleep(2)
print("Game over")
import time
time.sleep(99999)
break
import time
time.sleep(3)
if bearhp < death:
print("You do a final blow against the bear")
print("")
print("The bear has died")
break
import time
print("You have",(hp),"left")
print("")
import time
time.sleep(1)
print("The bear has",(bearhp),"left")
import time
time.sleep(1)
import os
import sys
os.system("CLS")

else:
print("You run away.")
import time
time.sleep(2)
print("You have wasted your hunger bar")
hungerbar = 1
hunger = hunger - hunger
print("Hunger is",(hungerbar)," ")
import time
time.sleep(3)



time.sleep(2)
import time
import sys
from random import randrange
text = ("You are in a strange room")

for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.1)
time.sleep(0.1)
print("")
print("You see a shelf")
import time
time.sleep(2)
print("Hint - try examining it.","examine")
examination = input("")
if (examination) == (examinationyes):
print("You find a small vial")
import time
time.sleep(2)
print("It's a potion of healing!")
import time
time.sleep(2)
print("You take the potion")
potion = potion + potionadd
import time
time.sleep(2)
print("You have",(potion),"in your inventury")
import time
time.sleep(2)
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
else:
print("You walk out of the door and you see a path")
import time
time.sleep(2)
print("You go down the road")
print("You see a road which splits into 2 paths.")
print("Do you wish to go left or right?")
roadchoice = input("")
if (roadchoice) == (road):
print("You go left")
else:
print("You go right")
import time
time.sleep(5)

print("You are walking slowly down the road.")
import time
time.sleep(3)
print("You see a slender man.")
import time
time.sleep(3)
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
print("GAME OVER")
time.sleep(3)
print("SLENDER MAN HAS GOT YOU")
import time
time.sleep(5)
print("END OF GAME! SLENDER TEXT. THE GAME")
import time
time.sleep(60)
print("As you are walking down the misty road...")
import time
time.sleep(3)
print("You see a small, old note.")
print("Do you want to look at it?")
keychoices = input("")
if (keychoices) == (choicekey):
print("Note - To open the ancient door, you must say 5665598")
import time
time.sleep(5)
print("Remember not to forget it, otherwise you will die!")
import time
time.sleep(2)
print("SteveXI - If you are reading this, then i am dead.")
import time
time.sleep(2)
print("SteveXI - Good luck!")
import time
time.sleep(10)
import os
import sys
os.system("CLS")

else:
print("You leave the note alone.")

import os
import sys
os.system("CLS")

import time
time.sleep(3)
print("In the distance, you see a small hut. It stands on a small hill.")
import time
time.sleep(3)
print("You make a camp")
import time
time.sleep(2)
print("What do you want to do now?")
print(" 1) go 2) or do nothing")
hutchoices = input("")
something = 10
somethings = 1
hutchoiceyes = ("go")
while something > somethings:
if (hutchoices) == (hutchoiceyes):
print("You walk to the hut.")
import time
time.sleep(5)
break


else:
print("You do nothing.")
hutchoices = input("")


import time
time.sleep(3)
import time
time.sleep(5)
print("You find an ancient sandstone door.")
import time
time.sleep(5)
print("Say the inscription, if you know it.")
password = input("")
if (password) == (passwordcode):
print("The door slides slowly out of the way.")
print("You go down a cobweb filled passage")
import time
time.sleep(3)
print(" You have completed the game, Welldone!")
else:
print("A trapdoor opens beneath you!")
print("You fall down to your doom.")
import webbrowser
webbrowser.open('http://www.google.co.uk/imgres?q=slender+screen&um=1&hl=en&safe=active&sa=N&tbo=d&tbm=isch&tbnid=evaUdI26IM5C9M:&imgrefurl=http://templardigital.blogspot.com/2012/07/video-game-review-slender.html&docid=gV0cU5I4FRgbLM&imgurl=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc6zNsop69fLfQ9JgeiiqriKJW4fA-w1WG-P5H5NUPadNygqsaSWI0efAgWuZtvJMe89JNTTlhd1ZnvMI8OBxn_cSKWFn2qa6B-iQ06Vfb1Cne1HTDmh5sTp4PIIVtjDo8CATBO6OYRqGM/s1600/Slender%252B2.png&w=474&h=348&ei=wpy0UNv_IsWy0QXKvoD4CA&zoom=1&iact=rc&dur=1&sig=117123526119168881900&page=1&tbnh=145&tbnw=202&start=0&ndsp=26&ved=1t:429,r:17,s:0,i:135&tx=140&ty=96&biw=1280&bih=876')
import time
time.sleep(5)
print("You die, End of game.")
import time
time.sleep(5)
print("SLENDERTEXT THE GAME")
import time
time.sleep(60)
def clearscreen():
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system('CLS')
print("Adventure part 2")
import time
time.sleep(4)
print("Adventure start's now!")
import time
time.sleep(2)

#This is part 2 of the adventure. All data must be below.
#All data will be stored and loaded below.
#_____________________________________________________________________________
spiderchoiseyes = ("hit")
spiderchoiseno = ("no")
reservespace = ("")
roadchoice1exec = ("1")
roadchoice2exec = ("2")
villager = ("yes")
hammerchoiceexec = ("yes")
hungertakeaway = 1
spiderdamage = random.randint(1,8)
global acid
acid = 0
global portion
potion = 0
global queenhp
queenhp = 30
queendamage = random.randint(3,6)
#_____________________________________________________________________________

print("You start the adventure")
print("As you walk to the entrance, you see a giant spider!")
import time
time.sleep(3)
print("You need to hit it")
import time
time.sleep(3)
print("Hit it as many times as it takes to kill it.")
import time
time.sleep(2)
spider = input("")
if (spider) == (spiderchoiseyes):
while (spiderhp > death):
print("You hit the spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
spiderhp = spiderhp - dice
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
time.sleep(3)
print("The spider does ",(spiderdamage),"damage")
print("")
if hp < death:
print("OW! The spider does final blow against you!")
print("You have died")
import time
time.sleep(120)
break
hp = hp - spiderdamage


import time
time.sleep(3)
if spiderhp < death:
print("You do a final blow against the spider")
print("")
print("The spider has died")
break
import time
print("You have",(hp),"left")
import time
time.sleep(1)
print("The spider ",(spiderhp),"left")


else:
print("You run away!")
import time
time.sleep(2)
print("As you walk down the read slowly.")
import time
time.sleep(2)
print("You see 2 roads again.")
import time
time.sleep(2)
print("There's two roads.")
import time
time.sleep(2)
#Road choices start's from here!
print("There's 2 choises")
print("Press enter to see the roads")
input("")
print("2 There's a road leading to a cave")
input("")
print("1 There's second road, it's leading to a dark forest")
import time
time.sleep(2)
print("Which road do you want to go to? 1 or 2.")
roadchoice2 = input("")
if (roadchoice2) == (roadchoice2exec):
print("You have gone left")
import time
time.sleep(3)
print("You are walking to the cave")
import time
time.sleep(2)
print("You see a muddy footsteps leading to a massive cave.")
import time
time.sleep("1")
print("You see a pickaxe, do you want to examine and add it to your inventury?")
hammerchoice = input("")
if (hammerchoice) == (hammerchoiceexec):
print("You examine the pickaxe")
import time
time.sleep(2)
print("The axe looks a bit rusty")
import time
time.sleep(2)
print("It might have a use later on.")
else:
print("You walk past it")
import time
time.sleep(2)
print("You continue to walk towards the cave")

import time
time.sleep
print("Your hunger level",hunger)
import time
time.sleep(1)
print("You - You feel hungry, try seaching for a food source")

elif (roadchoice2) == (roadchoice1exec):
print("You have gone right")
import time
time.sleep(3)
print("As are walking to the dark forest.")
import time
time.sleep(2)
print("Mist slowly decends down to the forest floor")
import time
time.sleep(3)
print("You are a bit lost")
import time
time.sleep(3)
print("There's a full moon, but the mist is blinding your view.")
import time
time.sleep(3)
print("There's a villager")
import time
time.sleep(3)
print("Do you wish to talk to him?")
villagertalk = input("")
else:
print("Slenderman killed you")
print("End of the game")
import time
time.sleep(60)


if (villagertalk) == (villager):
print("You start a conversation with him")
import time
time.sleep(3)
print("Villagersteve - Watch out for those woods")
import time
time.sleep(3)
print("Villagersteve - These woods contain the most brutal undead.")
import time
time.sleep(2)
print("Villagersteve - Here, Take this bow.")
import time
time.sleep(3)
print("You - Item aquired.")
import time
time.sleep(2)
print("Villagersteve - Wait, I must tell you...")
import time
time.sleep(3)
print("You - You hear a screeching noise.")
import time
time.sleep(3)
print("Villagerbob - I must runnnnnn.......THEY ARE COMING FOR ME!")
import time
time.sleep(3)
print("Villagersteve runs away.")
import time
time.sleep(3)
value = 0
print("Suddenly, You blacked out")
time.sleep(2)
print("You find yourself in a strange cave...")
import time
time.sleep(2)
if value < potion:
print("You think, you need to use a portion now.")
import time
time.sleep(2)
print("Do you want to use potion now?")
rawinput = input("")
boolean = ("yes")
if rawinput == boolean:
decreasevalue = 1
print("You have used the potion!")
potion = potion - decreasevalue
import time
time.sleep(2)
print("You have",(potion),"left")
import time
time.sleep(2)
print("You gain",(SmallHealing),"hp")
hp = hp + SmallHealing
import time
time.sleep(2)
print("You have now",(hp),"left")


import time
time.sleep(2)
print("Suddenly, you see a gigantic spider!")
import time
time.sleep(2)
print("The queen has",(queenhp),"hp")
import time
time.sleep(2)
print("The battle beggins!")
while queenhp > death:
print("You hit queen spider")
print("")
import time
time.sleep(3)
print("You do",(dice),"damage")
print("")
import time
time.sleep(2)
print("Spider queen has",(queenhp),"left")
print("")
queenhp = queenhp - dice
if queenhp == death:
print("You do a final blow against the queen!")
print("")
print("The queen spider has died")
import time
time.sleep(2)
print("You finish the game!")
import time
time.sleep(2)
print("To be continued....")
break
import time
time.sleep(3)
print("The spider does ",(queendamage),"damage")
queendamage = queendamage - hp
print("You have",(hp),"left")
hp = hp - queendamage
print("")
if hp == death:
print("OW! The spider rips you in half.")
print("You have died")
import time
time.sleep(120)
break






python beginner game dice adventure-game






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '15 at 14:22









RubberDuck

27.1k454158




27.1k454158










asked Jan 16 '13 at 22:30









user1983877

362




362








  • 1




    For a start, please put all the import at the beginning of your file.
    – Josay
    Jan 16 '13 at 23:54














  • 1




    For a start, please put all the import at the beginning of your file.
    – Josay
    Jan 16 '13 at 23:54








1




1




For a start, please put all the import at the beginning of your file.
– Josay
Jan 16 '13 at 23:54




For a start, please put all the import at the beginning of your file.
– Josay
Jan 16 '13 at 23:54










2 Answers
2






active

oldest

votes

















up vote
12
down vote













global hp
hp = 20


Global only has an effect inside a function. It does absolutely nothing here. At any rate you should avoid using global.



global dice
import random
dice = random.randint(3,5)
global beardamage
import random
beardamage = random.randint(1,9)


You only need to import things once. Here you have imported random twice, the second time doesn't do anything. Instead, just import everything that you need at the beginning.



x = ("attack")
passwordcode = ("5665598")
road =("left")
key = ("key")


The parentheses do nothing here. Also, if these are global constants, they should be named in ALL_CAPS.



text = ("Loading files....")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.5)
time.sleep(0.01)
text = ("-1%||||||||||||||||100%-")
print("")
import time
import sys
from random import randrange
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
seconds = "0." + str(randrange(1, 4, 1))
seconds = float(0.01)
time.sleep(0.01)


See you've done the exact same thing twice. This means you should write a function like this:



def slow_print(text):
for character in text:
sys.stdout.write(character)
time.sleep(0.01)

slow_print("Loading Files...")
slow_print("-1%||||||||||||||||100%-")


That way you only need one copy of the actual logic.



def clearscreen():
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
# DOS/Windows
os.system('CLS')


You define this, but don't actually use it above.






share|improve this answer






























    up vote
    0
    down vote













    y =input("")
    if (y) == (x):


    That part, among others, is unclear. Here's my version that's also backward compatible with Python 2. I've only done the bear part.



    # Imports
    from __future__ import print_function # Makes Python 2 support Python 3 print().
    import os
    import sys
    from random import randint
    from time import sleep

    # Definitions

    # Use raw input in Python 2. Pass for Python 3.
    try: input = raw_input
    except: pass

    DEATH = 0

    def clear_screen():
    if os.name == "posix":
    # Unix/Linux/MacOS/BSD/etc
    os.system('clear')
    elif os.name in ("nt", "dos", "ce"):
    # DOS/Windows
    os.system('cls')


    # Other code

    # Player stats
    hp = 20
    hunger = 0
    food_bars = 5

    # Bear stats
    bear_hp = 10

    print("The bear looks aggressive. The bear has", bear_hp, "hp. Type attack or run")
    command = input()
    if command == "attack":
    while bear_hp > DEATH:
    print("You hit the bear")
    print()
    sleep(3)
    damage = randint(3, 5)
    print("You do", damage, "damage")
    print()
    sleep(2)
    clear_screen()
    bear_hp -= damage
    if bear_hp <= DEATH:
    print("You do a final blow against the bear")
    print()
    print("The bear has died")
    break

    sleep(3)
    bear_dmg = randint(1, 9)
    print("The bear does", bear_dmg, "damage")
    hp -= bear_dmg
    sleep(2)
    clear_screen()
    print()
    if hp <= DEATH:
    print("OW! The bear does final blow against you!")
    print("You have died")
    sleep(2)
    print("Game over")
    sleep(5)
    sys.exit()

    sleep(3)
    print("You have", hp, "hp left")
    print()
    sleep(1)
    print("The bear has", bear_hp, "hp left")
    sleep(1)
    clear_screen()
    elif command == "run":
    print("You run away.")
    sleep(2)
    if food_bars > 0:
    print("You have wasted a food bar")
    food_bars -= 1
    else:
    print("You grow hungry")
    hunger += 1
    print("Hunger is", hunger)
    sleep(3)
    else:
    print(command, "is not an option.")


    The Python Style Guide has more tips. If you're on Windows, i recommend using Notepad++ to write Python.



    Since Python 3.6, you can use formatted string literals (a.k.a. "f-strings"), like so:



    >>> name = 'Fred'
    >>> seven = 7
    >>> f'''He said his name is {name.upper()}
    ... and he is {6 * seven} years old.'''
    'He said his name is FREDn and he is 42 years old.'


    That snippet also demonstrates Python's triple-quoted strings that can span multiple lines, which can clean up parts like this:



            print(f"""Access granted

    Cheat list
    {cheat01} - Walkthrough
    {cheat02} - You should know what that one does""")


    Tested via the REPL:



    >>> cheat01 = 1
    >>> cheat02 = "two"
    >>>
    >>> print(f"""Access granted
    ...
    ... Cheat list
    ... {cheat01} - Walkthrough
    ... {cheat02} - You should know what that one does""")
    Access granted

    Cheat list
    1 - Walkthrough
    two - You should know what that one does
    >>>





    share|improve this answer























      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "196"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f20601%2fpython-adventure-game%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      12
      down vote













      global hp
      hp = 20


      Global only has an effect inside a function. It does absolutely nothing here. At any rate you should avoid using global.



      global dice
      import random
      dice = random.randint(3,5)
      global beardamage
      import random
      beardamage = random.randint(1,9)


      You only need to import things once. Here you have imported random twice, the second time doesn't do anything. Instead, just import everything that you need at the beginning.



      x = ("attack")
      passwordcode = ("5665598")
      road =("left")
      key = ("key")


      The parentheses do nothing here. Also, if these are global constants, they should be named in ALL_CAPS.



      text = ("Loading files....")
      import time
      import sys
      from random import randrange
      for c in text:
      sys.stdout.write(c)
      sys.stdout.flush()
      seconds = "0." + str(randrange(1, 4, 1))
      seconds = float(0.5)
      time.sleep(0.01)
      text = ("-1%||||||||||||||||100%-")
      print("")
      import time
      import sys
      from random import randrange
      for c in text:
      sys.stdout.write(c)
      sys.stdout.flush()
      seconds = "0." + str(randrange(1, 4, 1))
      seconds = float(0.01)
      time.sleep(0.01)


      See you've done the exact same thing twice. This means you should write a function like this:



      def slow_print(text):
      for character in text:
      sys.stdout.write(character)
      time.sleep(0.01)

      slow_print("Loading Files...")
      slow_print("-1%||||||||||||||||100%-")


      That way you only need one copy of the actual logic.



      def clearscreen():
      if os.name == "posix":
      # Unix/Linux/MacOS/BSD/etc
      os.system('clear')
      elif os.name in ("nt", "dos", "ce"):
      # DOS/Windows
      os.system('CLS')


      You define this, but don't actually use it above.






      share|improve this answer



























        up vote
        12
        down vote













        global hp
        hp = 20


        Global only has an effect inside a function. It does absolutely nothing here. At any rate you should avoid using global.



        global dice
        import random
        dice = random.randint(3,5)
        global beardamage
        import random
        beardamage = random.randint(1,9)


        You only need to import things once. Here you have imported random twice, the second time doesn't do anything. Instead, just import everything that you need at the beginning.



        x = ("attack")
        passwordcode = ("5665598")
        road =("left")
        key = ("key")


        The parentheses do nothing here. Also, if these are global constants, they should be named in ALL_CAPS.



        text = ("Loading files....")
        import time
        import sys
        from random import randrange
        for c in text:
        sys.stdout.write(c)
        sys.stdout.flush()
        seconds = "0." + str(randrange(1, 4, 1))
        seconds = float(0.5)
        time.sleep(0.01)
        text = ("-1%||||||||||||||||100%-")
        print("")
        import time
        import sys
        from random import randrange
        for c in text:
        sys.stdout.write(c)
        sys.stdout.flush()
        seconds = "0." + str(randrange(1, 4, 1))
        seconds = float(0.01)
        time.sleep(0.01)


        See you've done the exact same thing twice. This means you should write a function like this:



        def slow_print(text):
        for character in text:
        sys.stdout.write(character)
        time.sleep(0.01)

        slow_print("Loading Files...")
        slow_print("-1%||||||||||||||||100%-")


        That way you only need one copy of the actual logic.



        def clearscreen():
        if os.name == "posix":
        # Unix/Linux/MacOS/BSD/etc
        os.system('clear')
        elif os.name in ("nt", "dos", "ce"):
        # DOS/Windows
        os.system('CLS')


        You define this, but don't actually use it above.






        share|improve this answer

























          up vote
          12
          down vote










          up vote
          12
          down vote









          global hp
          hp = 20


          Global only has an effect inside a function. It does absolutely nothing here. At any rate you should avoid using global.



          global dice
          import random
          dice = random.randint(3,5)
          global beardamage
          import random
          beardamage = random.randint(1,9)


          You only need to import things once. Here you have imported random twice, the second time doesn't do anything. Instead, just import everything that you need at the beginning.



          x = ("attack")
          passwordcode = ("5665598")
          road =("left")
          key = ("key")


          The parentheses do nothing here. Also, if these are global constants, they should be named in ALL_CAPS.



          text = ("Loading files....")
          import time
          import sys
          from random import randrange
          for c in text:
          sys.stdout.write(c)
          sys.stdout.flush()
          seconds = "0." + str(randrange(1, 4, 1))
          seconds = float(0.5)
          time.sleep(0.01)
          text = ("-1%||||||||||||||||100%-")
          print("")
          import time
          import sys
          from random import randrange
          for c in text:
          sys.stdout.write(c)
          sys.stdout.flush()
          seconds = "0." + str(randrange(1, 4, 1))
          seconds = float(0.01)
          time.sleep(0.01)


          See you've done the exact same thing twice. This means you should write a function like this:



          def slow_print(text):
          for character in text:
          sys.stdout.write(character)
          time.sleep(0.01)

          slow_print("Loading Files...")
          slow_print("-1%||||||||||||||||100%-")


          That way you only need one copy of the actual logic.



          def clearscreen():
          if os.name == "posix":
          # Unix/Linux/MacOS/BSD/etc
          os.system('clear')
          elif os.name in ("nt", "dos", "ce"):
          # DOS/Windows
          os.system('CLS')


          You define this, but don't actually use it above.






          share|improve this answer














          global hp
          hp = 20


          Global only has an effect inside a function. It does absolutely nothing here. At any rate you should avoid using global.



          global dice
          import random
          dice = random.randint(3,5)
          global beardamage
          import random
          beardamage = random.randint(1,9)


          You only need to import things once. Here you have imported random twice, the second time doesn't do anything. Instead, just import everything that you need at the beginning.



          x = ("attack")
          passwordcode = ("5665598")
          road =("left")
          key = ("key")


          The parentheses do nothing here. Also, if these are global constants, they should be named in ALL_CAPS.



          text = ("Loading files....")
          import time
          import sys
          from random import randrange
          for c in text:
          sys.stdout.write(c)
          sys.stdout.flush()
          seconds = "0." + str(randrange(1, 4, 1))
          seconds = float(0.5)
          time.sleep(0.01)
          text = ("-1%||||||||||||||||100%-")
          print("")
          import time
          import sys
          from random import randrange
          for c in text:
          sys.stdout.write(c)
          sys.stdout.flush()
          seconds = "0." + str(randrange(1, 4, 1))
          seconds = float(0.01)
          time.sleep(0.01)


          See you've done the exact same thing twice. This means you should write a function like this:



          def slow_print(text):
          for character in text:
          sys.stdout.write(character)
          time.sleep(0.01)

          slow_print("Loading Files...")
          slow_print("-1%||||||||||||||||100%-")


          That way you only need one copy of the actual logic.



          def clearscreen():
          if os.name == "posix":
          # Unix/Linux/MacOS/BSD/etc
          os.system('clear')
          elif os.name in ("nt", "dos", "ce"):
          # DOS/Windows
          os.system('CLS')


          You define this, but don't actually use it above.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 7 '15 at 13:35









          Cees Timmerman

          258312




          258312










          answered Jan 17 '13 at 0:12









          Winston Ewert

          26.4k44474




          26.4k44474
























              up vote
              0
              down vote













              y =input("")
              if (y) == (x):


              That part, among others, is unclear. Here's my version that's also backward compatible with Python 2. I've only done the bear part.



              # Imports
              from __future__ import print_function # Makes Python 2 support Python 3 print().
              import os
              import sys
              from random import randint
              from time import sleep

              # Definitions

              # Use raw input in Python 2. Pass for Python 3.
              try: input = raw_input
              except: pass

              DEATH = 0

              def clear_screen():
              if os.name == "posix":
              # Unix/Linux/MacOS/BSD/etc
              os.system('clear')
              elif os.name in ("nt", "dos", "ce"):
              # DOS/Windows
              os.system('cls')


              # Other code

              # Player stats
              hp = 20
              hunger = 0
              food_bars = 5

              # Bear stats
              bear_hp = 10

              print("The bear looks aggressive. The bear has", bear_hp, "hp. Type attack or run")
              command = input()
              if command == "attack":
              while bear_hp > DEATH:
              print("You hit the bear")
              print()
              sleep(3)
              damage = randint(3, 5)
              print("You do", damage, "damage")
              print()
              sleep(2)
              clear_screen()
              bear_hp -= damage
              if bear_hp <= DEATH:
              print("You do a final blow against the bear")
              print()
              print("The bear has died")
              break

              sleep(3)
              bear_dmg = randint(1, 9)
              print("The bear does", bear_dmg, "damage")
              hp -= bear_dmg
              sleep(2)
              clear_screen()
              print()
              if hp <= DEATH:
              print("OW! The bear does final blow against you!")
              print("You have died")
              sleep(2)
              print("Game over")
              sleep(5)
              sys.exit()

              sleep(3)
              print("You have", hp, "hp left")
              print()
              sleep(1)
              print("The bear has", bear_hp, "hp left")
              sleep(1)
              clear_screen()
              elif command == "run":
              print("You run away.")
              sleep(2)
              if food_bars > 0:
              print("You have wasted a food bar")
              food_bars -= 1
              else:
              print("You grow hungry")
              hunger += 1
              print("Hunger is", hunger)
              sleep(3)
              else:
              print(command, "is not an option.")


              The Python Style Guide has more tips. If you're on Windows, i recommend using Notepad++ to write Python.



              Since Python 3.6, you can use formatted string literals (a.k.a. "f-strings"), like so:



              >>> name = 'Fred'
              >>> seven = 7
              >>> f'''He said his name is {name.upper()}
              ... and he is {6 * seven} years old.'''
              'He said his name is FREDn and he is 42 years old.'


              That snippet also demonstrates Python's triple-quoted strings that can span multiple lines, which can clean up parts like this:



                      print(f"""Access granted

              Cheat list
              {cheat01} - Walkthrough
              {cheat02} - You should know what that one does""")


              Tested via the REPL:



              >>> cheat01 = 1
              >>> cheat02 = "two"
              >>>
              >>> print(f"""Access granted
              ...
              ... Cheat list
              ... {cheat01} - Walkthrough
              ... {cheat02} - You should know what that one does""")
              Access granted

              Cheat list
              1 - Walkthrough
              two - You should know what that one does
              >>>





              share|improve this answer



























                up vote
                0
                down vote













                y =input("")
                if (y) == (x):


                That part, among others, is unclear. Here's my version that's also backward compatible with Python 2. I've only done the bear part.



                # Imports
                from __future__ import print_function # Makes Python 2 support Python 3 print().
                import os
                import sys
                from random import randint
                from time import sleep

                # Definitions

                # Use raw input in Python 2. Pass for Python 3.
                try: input = raw_input
                except: pass

                DEATH = 0

                def clear_screen():
                if os.name == "posix":
                # Unix/Linux/MacOS/BSD/etc
                os.system('clear')
                elif os.name in ("nt", "dos", "ce"):
                # DOS/Windows
                os.system('cls')


                # Other code

                # Player stats
                hp = 20
                hunger = 0
                food_bars = 5

                # Bear stats
                bear_hp = 10

                print("The bear looks aggressive. The bear has", bear_hp, "hp. Type attack or run")
                command = input()
                if command == "attack":
                while bear_hp > DEATH:
                print("You hit the bear")
                print()
                sleep(3)
                damage = randint(3, 5)
                print("You do", damage, "damage")
                print()
                sleep(2)
                clear_screen()
                bear_hp -= damage
                if bear_hp <= DEATH:
                print("You do a final blow against the bear")
                print()
                print("The bear has died")
                break

                sleep(3)
                bear_dmg = randint(1, 9)
                print("The bear does", bear_dmg, "damage")
                hp -= bear_dmg
                sleep(2)
                clear_screen()
                print()
                if hp <= DEATH:
                print("OW! The bear does final blow against you!")
                print("You have died")
                sleep(2)
                print("Game over")
                sleep(5)
                sys.exit()

                sleep(3)
                print("You have", hp, "hp left")
                print()
                sleep(1)
                print("The bear has", bear_hp, "hp left")
                sleep(1)
                clear_screen()
                elif command == "run":
                print("You run away.")
                sleep(2)
                if food_bars > 0:
                print("You have wasted a food bar")
                food_bars -= 1
                else:
                print("You grow hungry")
                hunger += 1
                print("Hunger is", hunger)
                sleep(3)
                else:
                print(command, "is not an option.")


                The Python Style Guide has more tips. If you're on Windows, i recommend using Notepad++ to write Python.



                Since Python 3.6, you can use formatted string literals (a.k.a. "f-strings"), like so:



                >>> name = 'Fred'
                >>> seven = 7
                >>> f'''He said his name is {name.upper()}
                ... and he is {6 * seven} years old.'''
                'He said his name is FREDn and he is 42 years old.'


                That snippet also demonstrates Python's triple-quoted strings that can span multiple lines, which can clean up parts like this:



                        print(f"""Access granted

                Cheat list
                {cheat01} - Walkthrough
                {cheat02} - You should know what that one does""")


                Tested via the REPL:



                >>> cheat01 = 1
                >>> cheat02 = "two"
                >>>
                >>> print(f"""Access granted
                ...
                ... Cheat list
                ... {cheat01} - Walkthrough
                ... {cheat02} - You should know what that one does""")
                Access granted

                Cheat list
                1 - Walkthrough
                two - You should know what that one does
                >>>





                share|improve this answer

























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  y =input("")
                  if (y) == (x):


                  That part, among others, is unclear. Here's my version that's also backward compatible with Python 2. I've only done the bear part.



                  # Imports
                  from __future__ import print_function # Makes Python 2 support Python 3 print().
                  import os
                  import sys
                  from random import randint
                  from time import sleep

                  # Definitions

                  # Use raw input in Python 2. Pass for Python 3.
                  try: input = raw_input
                  except: pass

                  DEATH = 0

                  def clear_screen():
                  if os.name == "posix":
                  # Unix/Linux/MacOS/BSD/etc
                  os.system('clear')
                  elif os.name in ("nt", "dos", "ce"):
                  # DOS/Windows
                  os.system('cls')


                  # Other code

                  # Player stats
                  hp = 20
                  hunger = 0
                  food_bars = 5

                  # Bear stats
                  bear_hp = 10

                  print("The bear looks aggressive. The bear has", bear_hp, "hp. Type attack or run")
                  command = input()
                  if command == "attack":
                  while bear_hp > DEATH:
                  print("You hit the bear")
                  print()
                  sleep(3)
                  damage = randint(3, 5)
                  print("You do", damage, "damage")
                  print()
                  sleep(2)
                  clear_screen()
                  bear_hp -= damage
                  if bear_hp <= DEATH:
                  print("You do a final blow against the bear")
                  print()
                  print("The bear has died")
                  break

                  sleep(3)
                  bear_dmg = randint(1, 9)
                  print("The bear does", bear_dmg, "damage")
                  hp -= bear_dmg
                  sleep(2)
                  clear_screen()
                  print()
                  if hp <= DEATH:
                  print("OW! The bear does final blow against you!")
                  print("You have died")
                  sleep(2)
                  print("Game over")
                  sleep(5)
                  sys.exit()

                  sleep(3)
                  print("You have", hp, "hp left")
                  print()
                  sleep(1)
                  print("The bear has", bear_hp, "hp left")
                  sleep(1)
                  clear_screen()
                  elif command == "run":
                  print("You run away.")
                  sleep(2)
                  if food_bars > 0:
                  print("You have wasted a food bar")
                  food_bars -= 1
                  else:
                  print("You grow hungry")
                  hunger += 1
                  print("Hunger is", hunger)
                  sleep(3)
                  else:
                  print(command, "is not an option.")


                  The Python Style Guide has more tips. If you're on Windows, i recommend using Notepad++ to write Python.



                  Since Python 3.6, you can use formatted string literals (a.k.a. "f-strings"), like so:



                  >>> name = 'Fred'
                  >>> seven = 7
                  >>> f'''He said his name is {name.upper()}
                  ... and he is {6 * seven} years old.'''
                  'He said his name is FREDn and he is 42 years old.'


                  That snippet also demonstrates Python's triple-quoted strings that can span multiple lines, which can clean up parts like this:



                          print(f"""Access granted

                  Cheat list
                  {cheat01} - Walkthrough
                  {cheat02} - You should know what that one does""")


                  Tested via the REPL:



                  >>> cheat01 = 1
                  >>> cheat02 = "two"
                  >>>
                  >>> print(f"""Access granted
                  ...
                  ... Cheat list
                  ... {cheat01} - Walkthrough
                  ... {cheat02} - You should know what that one does""")
                  Access granted

                  Cheat list
                  1 - Walkthrough
                  two - You should know what that one does
                  >>>





                  share|improve this answer














                  y =input("")
                  if (y) == (x):


                  That part, among others, is unclear. Here's my version that's also backward compatible with Python 2. I've only done the bear part.



                  # Imports
                  from __future__ import print_function # Makes Python 2 support Python 3 print().
                  import os
                  import sys
                  from random import randint
                  from time import sleep

                  # Definitions

                  # Use raw input in Python 2. Pass for Python 3.
                  try: input = raw_input
                  except: pass

                  DEATH = 0

                  def clear_screen():
                  if os.name == "posix":
                  # Unix/Linux/MacOS/BSD/etc
                  os.system('clear')
                  elif os.name in ("nt", "dos", "ce"):
                  # DOS/Windows
                  os.system('cls')


                  # Other code

                  # Player stats
                  hp = 20
                  hunger = 0
                  food_bars = 5

                  # Bear stats
                  bear_hp = 10

                  print("The bear looks aggressive. The bear has", bear_hp, "hp. Type attack or run")
                  command = input()
                  if command == "attack":
                  while bear_hp > DEATH:
                  print("You hit the bear")
                  print()
                  sleep(3)
                  damage = randint(3, 5)
                  print("You do", damage, "damage")
                  print()
                  sleep(2)
                  clear_screen()
                  bear_hp -= damage
                  if bear_hp <= DEATH:
                  print("You do a final blow against the bear")
                  print()
                  print("The bear has died")
                  break

                  sleep(3)
                  bear_dmg = randint(1, 9)
                  print("The bear does", bear_dmg, "damage")
                  hp -= bear_dmg
                  sleep(2)
                  clear_screen()
                  print()
                  if hp <= DEATH:
                  print("OW! The bear does final blow against you!")
                  print("You have died")
                  sleep(2)
                  print("Game over")
                  sleep(5)
                  sys.exit()

                  sleep(3)
                  print("You have", hp, "hp left")
                  print()
                  sleep(1)
                  print("The bear has", bear_hp, "hp left")
                  sleep(1)
                  clear_screen()
                  elif command == "run":
                  print("You run away.")
                  sleep(2)
                  if food_bars > 0:
                  print("You have wasted a food bar")
                  food_bars -= 1
                  else:
                  print("You grow hungry")
                  hunger += 1
                  print("Hunger is", hunger)
                  sleep(3)
                  else:
                  print(command, "is not an option.")


                  The Python Style Guide has more tips. If you're on Windows, i recommend using Notepad++ to write Python.



                  Since Python 3.6, you can use formatted string literals (a.k.a. "f-strings"), like so:



                  >>> name = 'Fred'
                  >>> seven = 7
                  >>> f'''He said his name is {name.upper()}
                  ... and he is {6 * seven} years old.'''
                  'He said his name is FREDn and he is 42 years old.'


                  That snippet also demonstrates Python's triple-quoted strings that can span multiple lines, which can clean up parts like this:



                          print(f"""Access granted

                  Cheat list
                  {cheat01} - Walkthrough
                  {cheat02} - You should know what that one does""")


                  Tested via the REPL:



                  >>> cheat01 = 1
                  >>> cheat02 = "two"
                  >>>
                  >>> print(f"""Access granted
                  ...
                  ... Cheat list
                  ... {cheat01} - Walkthrough
                  ... {cheat02} - You should know what that one does""")
                  Access granted

                  Cheat list
                  1 - Walkthrough
                  two - You should know what that one does
                  >>>






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago

























                  answered Jul 7 '15 at 16:39









                  Cees Timmerman

                  258312




                  258312






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f20601%2fpython-adventure-game%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Quarter-circle Tiles

                      build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                      Mont Emei