Discord Server Red Security Twitter Donation to Red Security Red Security Youtube Channel Red Security Tumblr Profile
Login or Register to Hide ads and Accessing all features on the forum

Tutorial 

Let's Code: Making a Text-Based-Adventure Game in Python Part.1

2 Replies, 30505 Views

[Image: images?q=tbn:ANd9GcQljivNXYiG-119Ki2aVzC...n5sRRWsNmw]


                  Hello everyone, It is I, the Mad-Architect. Let's Code shall we? Right now, I am working on a personal project, and with that said, it was going to remain personal, until a high number of people on the Discord server started asking for tutorials on Python, granted we do have quite a few in the forum, I felt it was only right that I added my project to the mix, to ensure that you, the users in our community, have what they need to advance their skills. 

        So right now, lets start with a run-down of what this part will look like, once it is finished. 
   
 
        -------------------------------------------------------------------------------
               
Code:
print ("Welcome, we have been waiting for you")

Gender = input("What type of human are you?" )
male = 'male'
female = 'female'

if Gender == male:
print ("Ahh, a man of action, here here!")
elif Gender == female:
print ("A woman, we shall see what you have to bring to the table.")
else:
print ("Please choose a gender.")

                  
        ------------------------------------------------------------------------------


         So of course, at the beginning of this, I mentioned we are making a text-based adventure game. This block of code refers to a starting point in the game, where we can choose our character's gender. So obviously this is not the full program; this is merely a smaller program that we are able to "import" into the larger program when it is needed or "called". 

         Creating smaller files, that help make up the larger program, helps to organize files and assist in making the overall layout less messy. Also helps for debugging. 

         So in the first part, I use *print* to print out a string, this string is greeting the player, stating that they have been waiting for them. Right after this, the program asks for the player's character's gender. I did this, when I typed *Gender = input*.

         
          <<Gender = input("What type of human are you?" )>>


                      So the variable *gender* is equal to user input. At the same time, it is printing a string, a question that asks "What type of human are you?" <<YOUR INPUT WOULD GO HERE>>
           

           Pretty simple, now after this, its only two simple variables that are equal to themselves. These are the way they are, because of the next set of code that we are going to use. 



           male = 'male'

           female = 'female'

          Remember to include the single quotes around the values, otherwise you will spend the next ten to twenty minutes trying to figure out why they're not defined. 
            


           if Gender == male:

                 print ("Ahh, a man of action, here here!")
                 elif Gender == female:
                 print ("A woman, we shall see what you have to bring to the table.")
                 else:
                 print ("Please choose a gender.")





           Now, the *if statements* are fun, a lot can be done with them. In this statement in particular, is for when we are choosing our character's gender. Certain responses have been coded into the game, so that we receive a certain response depending on what gender we choose, also if we don't choose one. Just type everything as it is, and it should work. 
 

            I hope you all found this helpful, if there is anything you need ask to me about it, just hit me up on the Discord server. Also, what I used for this project, was Notepad++ and just the Windows Command Line. 

            Exp: Go to the Search bar in the lower left hand corner, and type in CMD, this will bring up the Windows Command Line, and from here just type [CD/cd Desktop] and it will change to the Desktop directory, from here, type [python Gen_Part_Start.py] That is how the program should be saved, including the python file extension. 




            Again, just let me know if anything goes wrong with the program, I cannot say when the next part will be out, but it is coming, so have a good week folks, and stay safe out there. 


            --Mad-Architect
01001001 00100000 01000001 01001101 00100000 01011010 01001111 01000100 01001001 01000001 01000011
(This post was last modified: 03-08-2019, 08:25 AM by Mr.Kurd.)
Nice tutorial bro, I liked it and liked the idea of explaining if statement.
Keep it up.
Rs
* Thankful to Allah *
Kurdy
Thanks Kurd, will do Smile
01001001 00100000 01000001 01001101 00100000 01011010 01001111 01000100 01001001 01000001 01000011

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tutorial Doubly Linked List in Python Covid-19 0 2,178 07-30-2022, 09:15 PM
Last Post: Covid-19
  Tutorial Linked List in Python Covid-19 2 2,535 07-30-2022, 08:25 PM
Last Post: Covid-19
  Tutorial File Handling in Python Covid-19 2 2,569 06-16-2022, 06:17 PM
Last Post: Covid-19
  Tutorial Exceptions in Python Covid-19 0 1,775 06-08-2022, 09:19 PM
Last Post: Covid-19
  Free Automate the boring stuff with Python Covid-19 0 1,541 06-07-2022, 06:58 PM
Last Post: Covid-19
  Tutorial Turtle in Python Covid-19 0 1,772 06-02-2022, 10:14 PM
Last Post: Covid-19
  Tutorial Python 3.5: Class Methods Covid-19 0 1,725 05-29-2022, 01:07 PM
Last Post: Covid-19
  Tutorial Python 3.2: Inheritance in Python Covid-19 2 2,737 05-27-2022, 06:47 PM
Last Post: Covid-19
  Tutorial Python 3.4: Encapsulation and Abstraction Covid-19 0 1,757 05-27-2022, 06:45 PM
Last Post: Covid-19
  Tutorial Python 3.3: Operator Overloading Covid-19 2 2,728 05-26-2022, 08:50 PM
Last Post: Covid-19



Users browsing this thread: 1 Guest(s)