Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 7: Wizard Battle App
Lecture: Introduction to the Wizard Battle App

Login or purchase this course to watch this video and the rest of the course contents.
0:00 It's time for app number 7, and this time we are going to build a really fun wizard game
0:06 it's kind of a role playing dungeons and dragons sort of thing. So what is that going to look like? Well, it's going to be a text based game
0:15 and here you can see a standard ground of game play. Of course, like all of our apps we start with a little header that says what the app is,
0:20 and then right off bat we have our hero in the game, the wizard Gandolf. And he sees an Evil Wizard. It turn out that one is super strong
0:28 and so he is like... I am not going to battle this, he could attack it, he could look around, but he is just going to run away as quick as he can.
0:34 So he does, and then next he finds a Bat, and decides hey, I can probably attack and kill this Bat, so he does,
0:41 but just barely he roles a 22, the bat roles at 22 and I guess because the element of surprise the wizard was triumphant over the Bat.
0:49 After that, the wizard Gandolf decides to have a look around and he sees that there is a wimpy toad, a tiger, a dragon
0:56 and that very strong evil wizard hanging around. The game goes around and around like this,
1:01 until either all the creatures are defeated or the wizard is gone. While building this game we are going to learn
1:07 one of the most important concepts in all of computer programming and that is the concept of object oriented programming.
1:15 This starts with defining classes and classes defined how data and behavior are bundled into one concept in programming
1:22 maybe this is a wizard or a dragon or the general concept of a creature or even the concept of a game itself.
1:30 When we create these classes, these are called objects, we want to initialize them, have them come into existence immediately with the data they need,
1:36 we'll do that through initializers and when we are talking about inheritance we have to chain those initializers through the inheritance tree,
1:42 so we are going to talk about initializer chaining. Speaking of inheritance, that lets us model our concepts
1:48 in our program with different levels of specialization. So we can model all of the actors, the dragon, the toad, the wizard
1:56 as something maybe we'll call the creature in the game and then we have a specialized version of the creature
2:01 that has other data and other features called the wizard and it knows how to battle creatures and then we can also have different types of creatures
2:08 that may themselves have special features like a dragon that has a special attack or something like that.
2:13 So this is called inheritance and it's a very powerful feature, when use judiciously. When we talk about inheritance,
2:19 we are also going to talk about polymorphism and duck typing. Some languages have very strict rules
2:24 about how you can use the more general what you call a base class or the specialized derived class,
2:30 like how you can use a creature versus how to use a wizard, the compiler checks all these things and so on,
2:35 Python doesn't have compiling or this concept of strong typing instead we are going to use something called duck typing
2:41 we'll talk about that near the end of our app. Let's get onto build a super fun dungeons and dragon style wizard game.


Talk Python's Mastodon Michael Kennedy's Mastodon