Hey all,
Thanks to a few guys on the forums I finally got around to starting on my text-based adventure called "a knights quest." It features a knight played by the player that is sent by his king to wipe out a cave full of foul creatures. However I am a bit stuck on how to simulate player movement in Python. I looked around the internet for movement logic specifically in Python, but so far I have had no luck. So I come to you guys, the experts. Does anyone have a good method of simulating player movement? In case anyone is interested I am 51% of the way through the CodeAcademy Python track so I haven't completely learned the basics of Python yet. Should I write a function? Or I heard of something called a class which I have yet to learn about yet. Here's my code below if anyone is interested in giving me tips on what I already have.
Thanks in advance,
Michael
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 2 17:29:40 2013
@author: Michael
"""
epicfailure = "Since you failed to type your own name you lose"
def printresponse(r):
if len(r) > 0:
return True
else:
return False
name = raw_input("What is your name?")
if printresponse(name) == True:
hometown = raw_input("Where are you from?")
else:
print epicfailure
def help(input):
helpint = "typable options: north, south, east, west, hit creature, run away, use torch"
if input == "help":
print helpint
yournameintro = "<Your name is %s , a wearied traveler>" % (name)
yourhometownintro = "<You've been sent to a cave outside of %s by your king>" % (hometown)
yourquestintro = "<Wipe out all of the foul creatures that dwell there>"
caveentrance = "<As you enter the cave, you check your supplies. You have a sword, and a torch. You think to yourself 'My king is such a cheapskate'>"
thequestion = "<What do you do?>"
if printresponse(hometown) == True:
print yournameintro
print yourhometownintro
print yourquestintro
else:
print epicfailure
print "======================="
print caveentrance
print "======================="
print thequestion
help("help")
response = raw_input(thequestion)