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
Thread Rating:
  • 6 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial Let's Code: Making a Text-Based-Adventure Game in Python Part.1
[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. 
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.")
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[font=Courier New]("What type of human are you?" )>>[/font]

                      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. 

           [font=Courier New]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.")
[font=Courier New]                 print ("Please choose a gender.")[/font]

[font=Courier New]           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. [/font]
[font=Courier New] [/font]

[font=Courier New]            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. [/font]

[font=Courier New]            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. [/font]

[font=Courier New]            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. [/font]

[font=Courier New]            --Mad-Architect[/font]
01001001 00100000 01000001 01001101 00100000 01011010 01001111 01000100 01001001 01000001 01000011
Reply The following 1 user Likes Mad-Architect's post:Mad-Architect's post
Nice tutorial bro, I liked it and liked the idea of explaining if statement.
Keep it up.
* Thankful to Allah *
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 Penetration testing course with Python Backdoor 0 1,154 09-12-2020, 04:22 AM
Last Post: Backdoor
  Python basics in simple language Mr. Nobody 2 1,748 06-08-2018, 09:34 PM
Last Post: Blindedjourneyman
  GUI PROGRAMMING WITH PYTHON Mr. Nobody 1 1,530 02-23-2018, 07:37 PM
Last Post: Mr.Kurd
  Python - Intro for beginers Mr. Nobody 1 1,661 11-12-2017, 11:14 AM
Last Post: Mr.Kurd
Wink Learn Python the Hard Way 3rd Edition Mr.Kurd 1 1,975 10-22-2017, 12:22 PM
Last Post: Miss4ulove
  Black Hat Python Mr.Kurd 4 9,822 08-29-2017, 09:03 PM
Last Post: Mr.Kurd

Users browsing this thread: 1 Guest(s)