#100DaysOfCode in Python Transcripts
Chapter: Days 13-15: Text-based games (and classes)
Lecture: Demo: Initial project structure

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright, let's write some code. So, we're going to begin this first part of our demo by simply creating the general skeleton and flow
0:08 of our application. We're not going to actually do anything with classes at all, but we're going to get it ready to.
0:14 So, let's come over here and add a new Python file. I noticed there were none at all, and I'll just have this called program.
0:21 In here we're going to define a main method, oh, I've got to configure this, hold on. Alright, now Python is happy. So, what we're going to do is
0:33 we're going to do a little print the header and that's just going to show these methods don't exist yet, but just think about the ideas.
0:40 Then we're going to run the game loop, okay, and it's going to go around and around and run. This concept of a game loop you'll find out in a second,
0:48 but let's put this print header here first. Now maybe we'll put something more interesting here later, but for now, we'll just do like a little line
0:58 and something like, wizard game. Or, something like that, that should look pretty decent and maybe a little divider there, as well.
1:07 Then, for our game loop we're going to come in and we're basically going to create the various concepts in the game.
1:17 We'll create a number of creatures, we'll create our hero, then we'll just say while true, we'll sort of like ask the user for action.
1:27 Then we'll say like if win or exit, and we'll just brake out of this loop and then we'll just say print, goodbye.
1:36 Alright, so we just go around and around, and keep asking the user to sort of control the hero. Do you want to attack? Do you want to look around?
1:43 Things like that. Now, there's a bunch of writing here that is actually not super interesting for you to watch me type it out.
1:50 So, let me just paste a little bit of code here to a more full featured version of what I just described. There we go. So, now we're going to come in
1:57 and we're going to create our creatures. We don't have any creaturs yet, remember we have to model those
2:02 with classes and that's one of our primary goals. We're going to create a hero. We're going to go around and around, we're going to grab randomly,
2:10 choose one of the creatures to appear. We're going to print out details about the creature that has appeared. Here's the input asking the user
2:19 do you attack, run away, or look around. Like what is your hero going to do, and then we just check. Do they type A? Do they type R? And so on.
2:28 So, this not super interesting yet. I'll put a little pass here to show it's not upset with that section there. It's not super interesting yet,
2:36 because we don't really have a hero. As you can see right here, and we have no creatures. So, let's go and model that next.

Talk Python's Mastodon Michael Kennedy's Mastodon