Jump to content
  • Advertisement
Sign in to follow this  
Enahs

Need help with Python text game

This topic is 3127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am new to making games so I think I will start out small. At first I thought I would make a game like Zelda using pygame, but thats to much work for me (now). So I will now start out smaller. My plan is to tell a detective story in a text based game. The player starts out by typing in their name, and then the story starts, and all that works fine, but now we come to my first problem. I want the player to have an option between 2 things, example "go to the crime seen" or "Talk to the victims wife", but I don't know how to give the player the option of choosing one or the other, and I also want to avoid the player typing in "The murderer is X" in the beginning of the game. Any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Look up python if/else statements on the documentation site. What you will want to do is show the options to the player as a number, i.e.


Where would you like to go?
1) The crime scene.
2) The fair.
3) Back to the office.




Then get input from the player using the "raw_input" function. He or she will have to input the number that corresponds to where they want to go.

You would then compare what you got from the "raw_input" function with the range of possible numbers. If it is in-rage, then go the the next function in your program that is the result of the users choice. If not, prompt the user that his/hers input was invalid.

This should get you started,
http://www.penzilla.net/tutorials/python/consoleio/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!