Python Text RPG (Part 3) - Making the Map - Beginner-friendly nested dictionaries trick!

preview_player
Показать описание
Welcome to part 3 of our Python Text RPG tutorial! We'll be implementing map in this video - going over dictionaries, nested dictionaries, key-value pairs, grid-based systems, and more!

n this Python Text RPG series, programmer and software engineer Bryan Tong walks you through a beginner-friendly tutorial on building your personalized command-line-based text role playing game in Python. He walks you through concepts such as for loops, while loops, data structures, dictionaries, maps, and even tricky functions like system sleep for text effects.

If you found this helpful or informative at all, please drop a like, subscribe, and/or a comment letting me know what you'd like to see in the future, how I can improve, or how I can help you fill in gaps or expand on this tutorial! Thank you all so much for the constant support and fast growth.

Stay tuned for part 4 in the next few days! (It turned into a 6 part tutorial btw..)
Рекомендации по теме
Комментарии
Автор

These Tutorials Should have way more views than they do. So informative free and easy + super easy to follow along!






The edit was Should and not Ahould lol.
Edit 2 was folllow -> Follow

erikfloyd
Автор

I'm a dungeon master and a world builder, so when I saw the part where you started making the areas, I immediately began worldbuilding all 16 of them. Principles, see.

viktord
Автор

Thank you for this tutorial! I am leaning Python and our project is to create a text based game where we need to collect items from 8 different rooms to defeat a 'Boss' after collecting all the items. This is super helpful in making me understand the concepts better, Thank you!

louispereira
Автор

You are my saviour! I'm writing a text-based adventure currently and this is EXACTLY what I needed to know! Thank you so much for making this, you explain everything so clearly too, which is wonderful. You get a like and a sub from me :)

luisatierney
Автор

Thank you for actually getting into technical stuff! Would rather not be "baby"'d like other tutorial writers do.

notcseliot
Автор

Hi, great tutorial so far! I'm having issues with the zone_map. When I create the
zone_map = {
'a1' : {

}
}
The closing parenthesis are not registering.
I have semi-colons at the end of each ZONENAME, DESCRIPTION etc. (vsc told me I had to use semi-colons)
I have the comma at the end of the room dictionary.
My code look just like yours and I followed very attentively so I am unsure what has gone wrong.
If you have any ideas, please let me know
Thanks!

karlmoody
Автор

Hey Bryan, thanks for this! I've been working on my version of this and trying to expand on the template you provided as a way to practice and learn.

I wanted to allow more flexible user input so I used
If(any ele in user_input for ele in acceptable_actions[0]:
player_examine(user_input)

I used nested lists to separate actions by type [['examine', 'look', etc], ['item', 'inv', etc], ['talk', 'interact']]
This way the player can type> 'look at the desk' instead of going through multiple prompts. > Look. What do you want to examine? > Desk

I understand that any() returns a Boolean and maybe not the best way design this.

My issue is when I pass the user_input to the player examine function.

I've tested the player_examine function separately and know that it works:

#items & descriptions are nested in list under EXAMINATION e.g., [bed, you sit on the bed..., Desk, it's messy, chest, oo shiny gold, closet, uhhhh...]
If any(ele in user_input for ele in

elif any(ele in u_i for ele in zm[myP.loc][EX][2]
print(zm[mp.loc][EX][3] etc. #def not the best way, but I'm still learning

Just using the above I can retrieve the correct list index.
But when it gets passed from the prompt() it only gives me the item1 description (e.g. you sit on the bed) even though the user_input is examine the desk.

Oh, then if I say 'look' (acceptible_actions[0][1]) it gives me the description for item2

Anyway, all that to say, I'd appreciate any help pointing me in the right direction. Or suggestions for better structure!

sco_otr
Автор

Thx to you I finnaly got the concept and uses of a dictcionare!!

Thank you so much!!!

leonardopavaoborges
Автор

What I have done to generate the solved_places dictionary was something like this:

def solved_places_generator(size_x, size_y):
output = {}
for i in range(1, size_x + 1):
for j in range(1, size_y + 1):
output[int_to_unicode(i + 96) + str(j)] = False

return output

def int_to_unicode(num):
return chr(num)

This way I dont have to painstakingly write it all down.

MyriadColorsCM
Автор

On PC VS Code the refactoring trick is alt select

brandonmorningstar
Автор

What have i done wrong? When i try putting the Zone name etc. into the dictionary inside another dictionary Visual Studio just gives me squiggly lines, saying "Can't assign to dictionary display" and unexpected token on basically everything...

JonVonBasslake
Автор

How come in the dictionary, he uses a colon for the first line (ZONENAME), but then can use equal signs for the rest? It shows up as an error for me.

nicholassong
Автор

Awesome tutorial, but I'm wondering if you could refer me to any tutorial that could help me do the "fancy code" at 10:53. I'm planning on making a bigger map and this would be SOOO tedious. Thanks!

TomationuJaDarkx
Автор

You should leave the .py file in the description... 2:55 it toke me more time to make the map then to type all the code from start to end

LemunDesigns
Автор

File "C:/Users/C/PycharmProjects/untitled1/First.py", line 41
def title_screen():
^
IndentationError: expected an indented block


I get this error even though my indentations are the same as yours :(

jodo
Автор

This tutorial is awsome. Thankyou for taking the time to make it. I'm slowly learning Python. Just curious, what are the 3 characters that you typed on line 70 at the 2:07 mark? Are those characters necessary or can they be left out?

aurthurdent
Автор

Hi, thanks for this awesome tutorial ... Its can be nice to have it in pdf too cause for me with my ADHD is hard to follow hehe ... But I hope you gonna make another video with an another style game

atrik
Автор

im having a name error it says "ZONENAME"is not defined

AntsandDogs
Автор

I like your tutorials but when I type in my script on Sublime Text 3, how come some of your words are different colors and my words are just white?

tufx
Автор

I liked this video really much!! It helped me a lot!!

mmjfryf