I'm very new to programming. I'm trying to make a simple adventure game but I'm already stuck on trying to get past the first function. Here is my code so far:
def find_shelter():
print "Your crew needs to find shelter for the first night.\n"
print "Do you choose....\n"
print "The cave, it is near the water. You will be safe from wind, but there may be animals inside the cave.\n"
print "The beach, it is very comfortable. You can see boats, but we will be exposed to weather.\n"
print "The jungle, it has many trees. You will be safe from storms. However, there are many animals.\n"
print "The mountain, it is very high. You will be safe from the jungle animals, but you may fall off the mountain.\n"
choice = raw_input("Select A for cave, B for beach, C for jungle, or D for mountain. ")
return choice
def oh_no_cave():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "There was a flood in the cave, one person drowned and is dead."
crew = crew - 1
print "There are now %s people left in your crew.", crew
return crew
def oh_no_beach():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "The storm rained on you. One person was struck by lightening and is dead."
crew = crew - 1
print "There are now %s people left in your crew.", crew
return crew
def oh_no_jungle():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "But, you were safe in the jungle from the storm. Everyone is ok."
print "There are still %s people left in your crew.", crew
def oh_no_mountain():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "You all get very wet on the mountain, but everyone is ok."
print "There are still %s people left in your crew.", crew
choice = []
print "You are going on a cruise with your family and friends.\n"
crew = raw_input("Enter the number of people on the cruise, must be at least four: \n")
print "Oh no! Your crew has just shipwrecked on a desolate island."
print "All food and supplies were lost at sea, and the captain has died too. :( "
print "On the island there is a beach, a river, a jungle, a mountain, and a cave."
if crew != 0:
find_shelter()
if choice == "a":
oh_no_cave()
elif choice == "b":
oh_no_beach()
elif choice == "c":
oh_no_jungle()
elif choice == "d":
oh_no_mountain()
else:
print "OH NO! Everyone in your crew has died! It's all over...."
print "Completely over."
After the prompt is given for the user to choose a, b, c, d, nothing happens after the user makes a choice. Please let me know what I could do to fix this and any other tips are also welcome. I later plan to check to make sure the user inputted at least 4 crew members but not sure how to do that yet.
Aucun commentaire:
Enregistrer un commentaire