Python Tutorial v3.2.5 Project 4 - Adventure, The Game

preview_player
Показать описание
1:42 Skip the introduction and watch the program execute.
8:48 Skip to the sample code of the quest generation system.

Project 4 centers on the creative use of if/elif/else statements and a while loop to create a more in depth text adventure game. Based on the same concept of In The Realm of the Dragon (Project 2), this game will keep track of variables such as gold, experience, and a rudimentary inventory. In addition, a random quest generator makes each game slightly different than the one before.

Keep in mind this tutorial is using an older version of Python, v3.2.5. You will need to click on the "View Older Releases" button to use this specific version. Using the newer versions will not be an issue at this point, but when the lesson proceeds to basic graphics, the Pygame Module we'll use does not support v3.3+ at this time.
Рекомендации по теме
Комментарии
Автор

@Michael_Thomas, as a beginning programmer, I think it's important to build a wide skill set at the beginning. There's nothing wrong with specializing in web development, but it will take a while before you should start to 'specialize' in my opinion. 

At the start, almost all programming skills are transferable. For example, let's say I write a game where the user can pick up a backback. That backpack lowers the total weight in their inventory by 40%. That same skill can be used to make an Android app that calculates a tip by adding 18% to a bill. While they're two totally different programs, the skills are the same. I may write a GPS app that tracks the quickest route to a gas station, then use that logic to help an elf track down an ogre in a forest. The point is, at the start, it's more important to learn the programming language than it is to learn it in a specific context.

When I work will my students, I try to emphasize that when you start, you want to get to the point where you can write programs from your head without looking up tutorial and bits of code from the web. I know that sounds a bit strange from a guy who posts those very materials. I remember when I first tried to learn programming, I used a book to learn to program "Hangman". I followed along, wrote the code, and it didn't quite work right. Worse, I couldn't figure out why it wasn't working and the programming logic made almost zero sense to me. Frustrated, I gave up. Over the next year, I kept learning by writing hundreds of programs (both games and practical applications, most of which were terrible) but I learned a lot. When I tried to write Hangman again, I didn't even crack open the book I used the first time and it worked flawlessly. The point is developing real, useful programs doesn't start until syntax, keywords, and programming logic are second nature. If you can't look at a 'for' loop and instinctively know what it's doing, you need to keep practicing. When you first learn to program, you'll end up looking at examples of simple code over and over and over until something 'clicks' and it finally makes sense (to this day, that's one of my favorite feelings).

If I were to give one piece of advice, it would be that the type of program you write as a beginner is completely irrelevant. The ONLY thing that matters is if you can explain why a program does or doesn't work. One student a year ago in my beginning Python class copied and pasted a full Space Invaders game from the web and proudly showed me the result of his work. It didn't matter to him that he couldn't write "Guess the Number, " because he had the code for Space Invaders. The problem was while the code worked, he had no idea why. Furthermore, if I asked him to do something simple, like change the color of the laser, there'd be no way for him to do it. If you're using tutorials, books, or websites, it is FAR more important to know WHY the programs work than it is to actually get the programs working. 

When you can look at the code for complex programs (for me, consider Hangman) and say "Oh, is that all they're doing? I can do that better" you'll be in a good spot. That's about when you'll start trying to specialize in a particular genre of program. But really, the more you learn about programming in general, the better you'll be at your specialty. That may be a longer answer to your questions than you wanted, but there's my thoughts :). Thanks for watching and best of luck.

xnavysteve
Автор

I loved the video. But it would have been better if you showed or linked the rest of the code.

ERKEK
Автор

Hey Steve, I'm interested in learning Python, I'm open to the possibility of working on game development but my focus really is in building web applications. My question is, if I learn Python in terms of programming games, do those skills transfer over to web development. I hope that question makes sense.. what I mean is should I only learn from web specific python tutorials. Side note, I'm a complete programming beginner. Looking forward to learning python and following along with you  and your videos if you think it would be advisable.

MichaelThomasDev
Автор

Firstly, thank you so much for these videos and projects. They're really helpful :)
Now, I'm trying to create my own game, based on this tutorial, and I would like to print the user's character profile at some point.
Right now I have this variable:

character_profile = {"Type": "Rabbit", "Name": "Sam", "Inventory": ["Axe", "Sword"]}

and this for loop to display it in a 'pretty' way:

for key, value in
print key + ":", value

However, when it prints the 'Inventory' key, which has two values, it also shows the [ ] like this:
Type: Rabbit
Name: Sam
Inventory: [Axe, Sword]

How can I remove them? I tried to do a nested for loop, to print the values differently (using the [2] index) but it didn't work..

Could you give me a hint, please?

ACLAproductions
Автор

if i want to be a software developer what should i do? like how do i learn 

Haidderispro
Автор

Can i have the source code of your game? please?

Josh-wvdn
Автор

stuck on this bit of code i know the lessons are passed this point but i would really like to learn what im doing wrong and i cant seem to find it in the video 

import time
import random

sword = False
armour = False
gold = 30
exp = 0

def intro ():
    print
           "Adventure: The Game\n"
         
intro ()
time.sleep (1)


def adventure_town(gold, exp):
    print ("You arrive in Adventure Town!\n\n"
           "Things around town that you can do.\n\n"
           "(B)lacksmith Shop\n"
           "(A)rmour Shop\n"
           "(C)heck for jobs around town\n"
           "(E)valuate the situation\n"
           "(S)lay the Dragon\n\n"
         
    print ("You have %s gold" % gold)
    print ("You have %s experience" % exp)
    print
    qr = input("What would you like to do?\n")
    if qr == "B":
        blacksmith_shop()
    elif qr == "A":
        armour_shop()
    elif qr == "C":
        check_for_jobs()
    elif qr == "E":
        evaluate_status()
    elif qr == "S":
        slay_dragon()
    
def blacksmith_shop():
    print ("Welcome to ProZacK's Smithing\n")
    print ("You can take a look around the shop, but the only thing I have at the moment is this Sword\n\n\n")
    time.sleep (3)
    qr = input ("Would you like to buy the sword for 30 gold?\n")
    if qr == "Y":
        global sword, gold
        if gold != 30
        print ("You do not have enough gold come back later")
        if gold = 30
        print ("You have bought the Sword for 30 gold\n")
        price = 30
        sword = True
        gold -= price
        


adventure_town(gold, exp)

ProZacKmg