I love that you just Zork'ed me for this tutorial! "You are standing in an open field west of a white house, with a boarded front door. There is a small mailbox here." The grandpappy of all text adventure opening lines!
@azhardarmawan3416
Жыл бұрын
Sir, thank you so much for your video! It helps me so much for my understanding of how OOP works ! and, I love it when you try to fix your code with print function to see where the error is, very natural, and I think it's applicable to general mistakes made when writing code
@brookestephen
Жыл бұрын
Command design pattern might be helpful here. You wouldn't need a big "if-else" or "switch-case" statement. You create a command object for each verb, and pass the rest of the user's text to the command for processing. You can log command objects, even save them as you proceed through the game, save and even load, to begin later exactly where you left off.
@NealHoltschulte
Жыл бұрын
Thanks! I must confess I am not familiar with command design patters, but that does seem useful for this application.
@brookestephen
Жыл бұрын
@@NealHoltschulte take a look on Wikipedia! en.wikipedia.org/wiki/Command_pattern
@supermalavox
Жыл бұрын
Is structured programming worse than object-oriented programming to create text adventures? I am still learning Python and found your explanation of oop great, but thought it was better to use structured programming before this video because of the many uses you have of text itself to keep record of where you are and what items are there in a room. By the way, I like text-adventures for their accessibility for blind people using screen readers. My favorite game is Colossal Cave Adventure! I am enjoying the escape room games they made for Alexa, like Christmas Escape, for example, because they are similar to text-based ones so that Alexa can narrate them out loud!
@NealHoltschulte
Жыл бұрын
I'm not sure what data structures would be best to use for making one with structured programming. One of my main reasons for making this video was to teach my students about object oriented programming. Text adventures might be easier with structured, I'm just not sure.
@supermalavox
Жыл бұрын
@@NealHoltschulte I understand. I just imagine it is better to use structured programming because even today there are people who build parsers to run games like Colossal Cave Adventure instead of rebuilding the game in oop, and it was made in a time when oop was not available, so that is why my question came to be, since I am not sure if they still maintain those games as structured for simplicity or because having external .dat files is better even today.
@d4ltn786
Жыл бұрын
how do you remove an item from the room once picked up?
@NealHoltschulte
Жыл бұрын
Each room has a pickups list and Python lists all implement a remove method so your_room.pickups.remove(x) where x is the item picked up. www.programiz.com/python-programming/methods/list/remove
@d4ltn786
Жыл бұрын
@@NealHoltschulte sorry I wasn’t specific enough, I meant from the actual room description itself
@NealHoltschulte
Жыл бұрын
@@d4ltn786 Oh, for that you might need some pattern matching and string parsing. I haven't done that in a long time in Python, but you might want to look into regular expressions and what Python String functions are available.
@dileepreddydillu9711
3 жыл бұрын
Hi can you please share the code for the above video Unable to find it in github
@NealHoltschulte
3 жыл бұрын
There should now be some python code for this in the following folder: drive.google.com/drive/folders/1V_gJ-7nZFihBYz98E90nZCnY8aOhEQor?usp=sharing
Пікірлер: 15