[Tutor] Coding for a Secret Message in a Game

Sky blaze skyblaze101 at gmail.com
Fri Dec 13 05:10:31 CET 2013


Hi, I'm a newbie Python programmer. I was introduced to Python via the Hour
of Code, and after completing all three of Grok Learning's tutorials, I was
inspired to create a text-based RPG adventure. I composed this e-mail after
searching for a forum for Python, and this address showed up in one of the
results.

Due to my inexperience with Python, I'm having trouble creating a code for
one of the things I wanted to do for the game. The game starts out on a
"title screen" with a message saying, "Type 'start' to begin!" I thought
it'd be amusing to have the message change after the player types something
other than "start" at least 10 times. I've attempted numerous times to code
this, but all of them have failed. Could you help me with the coding? It
should look something like this in the end:

>Type "start" to begin!
>No
>Type "start" to begin!
>Maybe
>Type "start" to begin!
>Perhaps
>Type "start" to begin!
>Nope
>Type "start" to begin!
>Why?
>Type "start" to begin!
>Are you sure?
>Type "start" to begin!
>You can't tell me what to do.
>Type "start" to begin!
>I'll start if I want to.
>Type "start" to begin!
>End
>Y U NO TYPE "start"?!
>Woah
>Y U NO TYPE "start"?!
>Okay, okay, I'll type it!
>Y U NO TYPE "start"?!
>start

Here's the code I currently have so far:
print("===INSTRUCTIONS===")
input(">> ")
print("When you see a \'>>\', hit Enter to advance the text.")
print("When you see a \'> \', type in a command.")
print("Commands are displayed in quotations.")
print("Type them exactly as how they appear in quotations.")
print("For example. Type \"hi\" to wave!")
print("You would type hi next to the \'> \' prompt.")
print("Now that the basics are out of the way, enjoy the game!")
input(">> ")
print("***SUPER GENERIC SHORT TEXT RPG ADVENTURE***")
start = False #This is the start screen check
print("Type \"start\" to begin.") #Command message to start the game
start_prompt = input("> ") #Command prompt to start the game
while start != True: #Infinite loop that doesn't end until "start" is typed
    if start_prompt == "start":
        start = True #Continues from the title screen
    else:
        #This is where I'm stuck. I can loop it so it always returns the
command message when
        #"start" isn't typed, but changing the message upon having that
occur at least 10 times is
        #what's giving me trouble.

Thank you for taking the time to read this e-mail!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131212/2575a125/attachment-0001.html>


More information about the Tutor mailing list