How To Code A Python Text-Based Adventure Game In 11 Minutes | Programming Tutorial For Beginners

  Рет қаралды 67,163

Shaun Halverson

Shaun Halverson

Күн бұрын

Пікірлер: 64
@kineticcTM
@kineticcTM Ай бұрын
For anyone wanting to make more randomised games like this instead of going from one room to another, you can use the "def" command to make a room and then call the room later. Here's a quick example: Defining the room: def monster_room(): print() print("You enter a large open room with a monster.") choice = input("Do you fight, or do you flee?").lower() Then later say you have to choose between a door to the left or to the right, you can get a random number from 1-2: print("You wake up in a dark room, there is a door both to your left and right.") choice = input("Which door do you choose?").lower() if choice == "right": print("You open the door to the right, and step through.") rand_val = random.randint(1,2) if rand_val == 1: monster_room() rand_val = random.randint(1,2) if rand_val == 2: corridor() Here you will call the "monster_room" if the random number is 1 and "corridor" if it's 2. This is pretty much a very simple randomised room concept and can be modified to your liking. This also makes it so you can have the game go on forever because you can make more rooms and randomly pick rooms all the time, or make a room which causes you to win. In addition, doing it this way you can make the game restart if you want the player to die. And if the player makes an invalid choice you can call the room again, for example in the monster room if the player types anything that isnt fight or flee (else:) then you can just do it like this: else: print("You can't do that") monster_room() With this the player will just get asked the question again.
@mod2725
@mod2725 17 күн бұрын
😇
@damelon9783
@damelon9783 Жыл бұрын
Bro has Minecraft in his Hot Bar what a legend..
@Aaryanaustralia
@Aaryanaustralia Жыл бұрын
👏👏👏👏🗿🗿🗿🗿🗿🗿🗿🦸‍♂🦸‍♂🦸‍♂
@edgarplayz1021
@edgarplayz1021 9 ай бұрын
no he’s not a legend because its bedrock edition
@jbomb11
@jbomb11 4 ай бұрын
@@edgarplayz1021it doesn’t matter
@edgarplayz1021
@edgarplayz1021 4 ай бұрын
@@jbomb11 It does 💀
@edgarplayz1021
@edgarplayz1021 4 ай бұрын
Bro really called it a hotbar its a taskbar
@Bjorofficial
@Bjorofficial Жыл бұрын
Thank you, Shuan. I was able to break off of your code really quickly, but I learned a lot. I even added an Easter egg for the shiny vase
@catthatisarat
@catthatisarat Жыл бұрын
thanks! i was absolutely stuck on what to make for my first real project!
@ChimpanzéDo38
@ChimpanzéDo38 Жыл бұрын
I was actualy searching about how to make a text based game, like a phone game. Not necessarily a mobile game but a game that's like a smartphone
@spanailos
@spanailos Жыл бұрын
Very helpful Video for a beginner like me. I have one question. How can you make the if/else clause repeat, in case the user enters an invalid option, so he can choose again right away?
@dolfinw4179
@dolfinw4179 Жыл бұрын
I would use a while loop. For example while choice != "yes" or choice != "no": choice = input("No such option, please enter yes or no: ")
@nervnichtmitalias
@nervnichtmitalias 10 ай бұрын
@dolfinw4179 Absolute legend, tried figure it own on my own for days
@Johzenji
@Johzenji 8 ай бұрын
@@dolfinw4179 ur goated for this
@AlexandersVideoCorner
@AlexandersVideoCorner Жыл бұрын
How can I get the player back to first set of options after choosing a particular choice route?
@PAFBEAST
@PAFBEAST 7 ай бұрын
While loop
@likezoinks2739
@likezoinks2739 Жыл бұрын
Good content as always! I love your vids
@devinegamingtv3427
@devinegamingtv3427 Ай бұрын
I used like 3 days to code a Dungeon Adventurer game. Basically has no story, but I tried to create a robust turn based combat system with a Passive skill tree and a Combat skill tree. The passive tree has 75 nodes and consists of Offensive boosts, Defensive, Resistances, Health, Health gain per turn. etc.. Combat skill has a skill tree in Diablo 4's manner, but it looks a lot uglier (More windows like). You can spec your character into melee, mage or ranged. The combat is turn based like in pokemon. There are 12 monsters, but each individual monster can be different. Skeleton can be Skeleton Mage, ranged or melee. There are 2 bosses so fare, but they're pretty lackluster because of balancing issues. The player can farm gear, I have a basic, magic, rare and unique system. Greater rarity gives armor more affixes per gear, but the Unique set of items have kinda lackluster "unique" bonuses like "For each % of health missing, you deal 0,3% more dmg" kinda of thing. What puts me off is I don't know how I should make the game loop more interesting. It's a Up, down, left, right system with random encounters at the moment. And the balancing issues, the player becomes so strong after a while that the normal enemies don't matter. Fun concept, hard to make alone yet alone balance.
@StonyComet
@StonyComet Жыл бұрын
I got stuck on how to make the "carrot symbol" on my keyboard. I am from norway so couldn't find it. Had to copy it from some text
@daryllee7471
@daryllee7471 Жыл бұрын
caret. He said caret (^) but did "greater than" > shift-dot, between comma and slash. A caret is shift-6.
@karenbourgeois7957
@karenbourgeois7957 2 ай бұрын
I have so many ideas. RPGs are my favorite! Thanks a bunch 😊
@scarloss474
@scarloss474 6 ай бұрын
If anyone sees this please answer; What code do I use to return it back to the input/question I ask the player if put in an invalid choice? Or perhaps revert the game back to the beginning if they die without starting the game over themselves?
@kineticcTM
@kineticcTM Ай бұрын
To do that you would need to change the code quite a bit but it is possible.
@Kayne-zk4xi
@Kayne-zk4xi Ай бұрын
Thanks so much you helped me complete the school work
@magicwordxyzzy
@magicwordxyzzy 2 ай бұрын
I feel like using lower() to make the input not case sensitive would be an easy addition to improve this...but then, if we did every little thing to improve on the idea of a text adventure in Python, the video would be considerably longer, lol. I just wish that Python had some sort of getch command built in so every input didn't need to end with the press of the enter key.
@elvisdavidfenny8446
@elvisdavidfenny8446 Жыл бұрын
how to set the game asking like " Do you wanna play again ?" yes or no, Y/N
@elvisdavidfenny8446
@elvisdavidfenny8446 Жыл бұрын
@@summerlovinxx thank you my friend.
@aaronjenkins223
@aaronjenkins223 Жыл бұрын
Throw in a continue after the catch statement so they can redo the input without having to start over :)
@dontmindme3740
@dontmindme3740 Жыл бұрын
What is the code on how to do this, I’ve been trying to find out how for a while?
@aaronjenkins223
@aaronjenkins223 Жыл бұрын
@dontmindme3740 Make sure that the try section is inside a loop or else it won't work. try: Code except: Error message continue
@griswoldthegoblin9420
@griswoldthegoblin9420 Жыл бұрын
@@dontmindme3740Id like to know too
@hedgehogsmarbleruns3705
@hedgehogsmarbleruns3705 Жыл бұрын
That was very good keep it up! :D
@Centiaa
@Centiaa 7 ай бұрын
Your tutorial is a lifesaver. Thank you!
@megazoned3973
@megazoned3973 3 ай бұрын
If you make an invalid choice, how to you make it prompt you to answer the last question again instead of having to re run the game from the start?
@QuizMaster-w6c
@QuizMaster-w6c 3 ай бұрын
that is one way to solve this problem, hope it helps ### choice print("do you want to enter the room?") choicebool = True while choicebool == True: choice = input("> ") if choice == "yes": print("you entered the room") choicebool = False elif choice == "no": print("you did not enter the room") choicebool = False else: print("invalid input, please enter yes or no.") print("end")
@MetalHeadRed954
@MetalHeadRed954 6 ай бұрын
I really like this one very informative
@FindusFiskekaker
@FindusFiskekaker 7 ай бұрын
Tusen takk!
@7archaslayer763
@7archaslayer763 Жыл бұрын
Thank you so much is very helpful ❤
@jamaalHailey
@jamaalHailey 9 ай бұрын
the fan part killed me lmao
@ompathak3384
@ompathak3384 10 ай бұрын
can we made this using tkinter and how??
@Daz30
@Daz30 Жыл бұрын
What about continuing this game with another episode, you could have a drawing of location layouts of the mansion (not ingame but as an example of designing our map on paper) and how you add a navigate around the game world, where the player can navigate with n or e as traditionally with interactive fiction games. Or you could do a new setting where the player is walking through a forest where there are several paths to follow. This would be a great addition to learning how to make basic gameworld maps. I guess the very simple method would be giving several direction choices at the end of the location desc.." To the west is a swamp." And I guess, match input keyword of west or w to the current location the player is at. You could do a simple method for one half of the video and a more advanced version which might involve functions that handle the map system, on the other half of the video using the same adventure game setting.
@thevalkyrie8
@thevalkyrie8 Жыл бұрын
It is a ‘text’ adventure
@midnightgamer217
@midnightgamer217 8 ай бұрын
Can you make it with less nesting?
@PAFBEAST
@PAFBEAST 7 ай бұрын
No
@magicwordxyzzy
@magicwordxyzzy 2 ай бұрын
Maybe? I've started thinking about doing a project like this, and I'm considering using a variable to set the current location, and based on the location call a function for that location. I'm also thinking about how I would implement an inventory system, which would need to include character inventory as well as inventory for each location, with the ability to move things between the current location and the character inventory.
@farming4521
@farming4521 Жыл бұрын
Yo can someone tell me why; roomChoice = ("> ") if(roomChoice == "blue"): Doesn’t work?
@Bjorofficial
@Bjorofficial Жыл бұрын
Are they on the same part, for example hideChoice = input("> ") if(hideChoice == "yes"): print("You hide and you see the horrifying demons rush past you") print("Before you know it your running out the door") print("You win") elif(hideChoice == "no"): print("The demons catch up with you and your eaten") print("You Lose")
@dylansachdev1559
@dylansachdev1559 Жыл бұрын
Do you have a pastebin?
@gameu2sleep
@gameu2sleep Жыл бұрын
this is great! ty
@GeekRedux
@GeekRedux 4 ай бұрын
caret: ^ greater than sign: >
@mqasim.chandio1
@mqasim.chandio1 Жыл бұрын
Good content as always. But why is he stealing from his own house???
@Teach-at-HomeDad
@Teach-at-HomeDad 10 ай бұрын
Good question!
@marcossalcedo5498
@marcossalcedo5498 Жыл бұрын
that was so helpful I would like to ask you a question.
@Lonewander
@Lonewander 2 ай бұрын
if i see a pitbull im gonna pet da baby bc teddy bear dog
@Qu0thTheRaven
@Qu0thTheRaven Жыл бұрын
meme break? how mature of you.
@grigoldvali4124
@grigoldvali4124 Жыл бұрын
Hi my friend, can you help me. it says that pitbull is not defined can you fix it for me? print("Welcome to the hounted mansion!") print("You are a distant family member of a rich millionaire who has been passed away living this / mansion to you ") print("as a new found owner, you decide to pay a visit to the mansion") print("the hause isdated, creaky, and a falling appart. you walk in the front door.") print("do you want to enter the living room or dinning room?") roomChoice = input ("> ") if(roomChoice == "living room"): print("you enter the living room") print("as you walk in you see a sleeping pitbull guarding some gold jewerly") print(" do you want to steal the jeverly from the pitbul?") pitBullchoice = input (" > ") if(pitBullChoice == "yes"): print("you attempt to stela jewelry, but it wakes up and rips you shreds") print("you are now dead") elif(pitBullChoice == "No"): Print("You decide to not to steal dog's jewerly") print("you decide to turn and leave the house safely") else: print("invalid choice. Please enter yes or no") elif(roomChoice == "dinning room"): print("you chose to go into the dinning room") print("as you walk in, you see a shiny vase on the table") print("do you want to open the vase") vasechoice = input ("> ") if (vasechoice == "yes"): print("you open the vase and find a pile of bones") elif(vasechoice == "no"): print("you decide not to open the shiny vase") print("as you turn to leave,you heare a ckacking sound comming from the corner") print("a dark figure with glowind red eyes launches at you, knockin you unconcious") print("you wake up in your bad.it was all a dream") else: print("invalid choice.please enter yes or no.") else: print("invalid choice. please enter living room or dinning room")
@griswoldthegoblin9420
@griswoldthegoblin9420 Жыл бұрын
Probably a spelling error, you first typed pitBullchoice with small c and then if(pitBullChoice) with capitalized c. Not sure tho just a thought.
Text Based Dungeon Game in Python | Coding Tutorial
11:21
Dante Lee
Рет қаралды 39 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 37 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 40 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 21 МЛН
I made Games with Python for 10 Years...
28:52
DaFluffyPotato
Рет қаралды 377 М.
How Two People Created Gaming’s Most Complex Simulation System
38:54
ThatGuyGlen
Рет қаралды 1,5 МЛН
2 YEARS of PYTHON Game Development in 5 Minutes!
4:54
Coding With Russ
Рет қаралды 984 М.
Build A Text Adventure Game With JavaScript
17:18
Web Dev Simplified
Рет қаралды 132 М.
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,7 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 37 МЛН