Hidden error in my program? and are there any easy-to-use Debuggers?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Boyyini
    New Member
    • Apr 2010
    • 5

    Hidden error in my program? and are there any easy-to-use Debuggers?

    Its me again : )
    I added a fight with a zombie to my text-based RPG game using 'while' as well as a Retry option. (I was experimenting with the 'while' function)

    And now, when I save and try to run my program, it opens and closes before I can see anything. I think there is an error in my code, but when I Run Module with IDLE, it runs fine and I do not encounter any error throughout the whole program.

    So I would like someone to either post a reliable and easy-to-use Debugger/Error Checker, or look through my code to find the error.
    A debugger would make me less dependent on asking for help : p

    Here is my code if you want to try to find the error.

    Code:
    #Boyyini's Dungeon Game
    #This is a short text-based dungeon-adventure game. Enjoy!
    
    import time
    import random
    
    health = 100
    zombie = 100
    
    #Welcomes user and explains game
    print("Welcome to Boyyini's first program. \nThis is my first attempt at making a program from scratch.")
    time.sleep(5)
    print("In this program I will be taking you through a text-based mini-adventure.")
    time.sleep(4)
    print("\nWhen a question is asked, type one of the resposes that are in single quotes.")
    time.sleep(4)
    print("\nOnly valid responses will have single quotes around them. ")
    raw_input("\nWhen you want to continue, Press Enter.")
    raw_input("\n\nNow I will ask a few questions about you, just cause I can.")
    print("First, I will ask you your name.")
    name = raw_input("Please enter your name: ")
    raw_input("Hello, " + name + ". Thanks for playing my game.")
    gender = raw_input("Are you a guy or girl? ")
    print ("\nYou're a " + gender + "? Okay, cool.")
    age = raw_input("How old are you? ")
    print "Alright. That\'s old enough to play this game."
    raw_input("Last question, do you have extensive liability insurance?")
    raw_input("Ha ha ha, just kidding! ... Press Enter to start your adventure!")
    
    print("\n\nOkay! Now you\'re at the entrance of the cave!")
    a = raw_input("Do you want to \'run in\' or \'walk in\'? ")
    if a == "run in":
        raw_input("\nYou burn a few calories. Exersise freak...")
        raw_input("You enter a large cavern, there is a small hole in the ceiling that lets a small amount of light in.")
    if a == "walk in":
        raw_input("\nYou slowly walk in.\nYou enter a large cavern, there is a small hole in the ceiling that lets a small amount of light in")
    zombies = "yes"
    while zombies == "yes":
        print("\nYou see about 20 zombies lumbering around 30 feet away. How do you want to kill them?")
        b = raw_input("Kill zombies with: \'double barrel\', \'chainsaw\', or \'teeth?\' ")
        if b == "double barrel":
            raw_input("You pull out your double barrel shotgun and kill 3 zombies with the first blast.")
            raw_input("The remaining 17 zombies start to lumber towards you as you reload.")
            raw_input("You fire again and kill 5 more zombies. The zombies are only 10 feet away.")
            raw_input("As you reload again, the zombies get to you and eat your brains.")
            print("""\n\n\n
                  ________      _____       _________    _
                 |   _____|    /  _  \     |___   ___|  | |
                 |  |____     /  /_\  \        | |      | |
                 |   ____|   /  _____  \       | |      | |
                 |  |       /  /     \  \   ___| |___   | |____
                 |__|      /__/       \__\ |_________|  |______|""")
            time.sleep(1)
            zombies = raw_input("\nRetry? yes or no?")
            print("\n\n")
        if b == "teeth":
            print("You quickly floss.")
            time.sleep(1)
            raw_input("You charge the zombies, teeth shining, even in the dim light.")
            raw_input("You jump on the closest zombie and take a chunk out of its neck. Eww...")
            raw_input("You are then swarmed by the other 19 zombies and they eat your brains.")
            raw_input("Were you really thinking to kill 20 zombies with your teeth?")
            print("""\n\n\n
                  ________      _____       _________    _
                 |   _____|    /  _  \     |___   ___|  | |
                 |  |____     /  /_\  \        | |      | |
                 |   ____|   /  _____  \       | |      | |
                 |  |       /  /     \  \   ___| |___   | |____
                 |__|      /__/       \__\ |_________|  |______|""")
            time.sleep(1)
            zombies = raw_input("\nRetry? yes or no?")
            print("\n\n")
                  
        if b == "chainsaw":
            raw_input("You pull out your chainsaw and start it.")
            raw_input("The zombies hear the chainsaw and start lumbering towards you.")
            raw_input("With your chainsaw raised, you charge the zombies, screaming.")
            raw_input("You kill zombie after zombie with the chainsaw.")
            raw_input("You kill the last zombie and toss your chainsaw aside.")
            zombies = "no"
            
            tunnel = "yes"
            while tunnel == "yes":
                raw_input("\nYou see two tunnels.")
                c = raw_input("\nWhich tunnel do you want to go into?\n\'left\' or \'right\'? ")
                if c == "left":
                    raw_input("You walk along the tunnel. The warm air turns into steam.")
                    raw_input("You see a yellow light ahead.")
                    raw_input("You enter a large room with a molten lava river in the middle.")
                    raw_input("You step near the lava")
                    print("*bubble* *bubble* *bubble*")
                    raw_input("A bubble of lava pops and splatters lava on your head.")
                    print("\n YOU ARE DEAD!")
                    time.sleep(1)
                    print("""\n\n\n
                      ________      _____       _________    _
                     |   _____|    /  _  \     |___   ___|  | |
                     |  |____     /  /_\  \        | |      | |
                     |   ____|   /  _____  \       | |      | |
                     |  |       /  /     \  \   ___| |___   | |____
                     |__|      /__/       \__\ |_________|  |______|""")
                    time.sleep(1)
                    tunnel = raw_input("\nRetry? yes or no? ")
                    print("\n\n")
                if c == "right":
                    tunnel = "no"
                    raw_input("You walk down the right tunnel.")
                    raw_input("You hear a mumbling, grumbling noise.")
                    raw_input("You see another zombie ahead. This one is about 7 feet tall.")
                    big_zombie = raw_input("Do you want to fight it? \'yes\' or \'no\'? ")
                    if "es" in big_zombie:
                        while health >= 0 and zombie >= 0:
                            human_damage = random.randint(30, 50)
                            zombie_damage = random.randint(15, 30)
                            health -= zombie_damage
                            zombie -= human_damage
                            raw_input("The zombie hits you and you take " + str(zombie_damage) + " damage.\nYou have " + str(health) + " health left.")
                            raw_input("You hit the zombie and it takes " + str(human_damage) + " damage.\nIt has " + str(zombie) + " health left.")
                            if health <= 0:
                                raw_input("Your character is dead.")
                            if zombie <= 0:
                                raw_input("You kill the zombie, but you are injured.")
                                raw_input("You beat the boss! Congratulations!")
                    if "o" in big_zombie:
                        tunnel = "yes"
                        raw_input("You turn around and head back out of the tunnel, the zombie not seeing you.")
                        raw_input("You are back at the entrance of the two tunnels.")
                    
                    
        
    print("\n\n\nThanks for playing \'Boyyini\'s Dungeon Game\'")
    time.sleep(3)
    print("\nAll coding done by Boyyini using Python.")
    time.sleep(3)
    print("""\n
      ____                    _       _   _____           _           _        _           
     |  _ \                  (_)     (_) |_   _|         | |         | |      (_)          
     | |_) | ___  _   _ _   _ _ _ __  _    | |  _ __   __| |_   _ ___| |_ _ __ _  ___  ___ 
     |  _ < / _ \| | | | | | | | '_ \| |   | | | '_ \ / _` | | | / __| __| '__| |/ _ \/ __|
     | |_) | (_) | |_| | |_| | | | | | |  _| |_| | | | (_| | |_| \__ \ |_| |  | |  __/\__ \
     
     |____/ \___/ \__, |\__, |_|_| |_|_| |_____|_| |_|\__,_|\__,_|___/\__|_|  |_|\___||___/
                   __/ | __/ |                                                             
                  |___/ |___/""")
    
    raw_input("\n\nPress the enter key to exit.\n")
    raw_input("")
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    I was able to run your program without error from the command prompt.

    Comment

    Working...