Jan-01-2017, 08:19 PM
So im working on a small little game but its becoming a pain in the ass to have to run through every line just to test one thing so i wanted to create a way to basically skip around from level to level.
I feel like i got close but not close enough for it to work.
heres the code.
and you can see that i tried to create an almost goto simulator with the skipmod part but it wont work. Any suggestions? I also am not dedicated to making the while goto work so if you have any suggestions please list them.
I feel like i got close but not close enough for it to work.
heres the code.
and you can see that i tried to create an almost goto simulator with the skipmod part but it wont work. Any suggestions? I also am not dedicated to making the while goto work so if you have any suggestions please list them.
import time playerclass = "0" playerhealth = 0 playerdamage = 0 playerspeed = 0 playerdefense = 0 playerrange = 0 op1 = 1 op2 = 1 op3 = 1 op4 = 1 level = 0 skip = 0 print("Hello player!") print("Welcome to The Last Calling") while (level == 0): print("Type start to begin") command1 = input("") if (command1.lower() == "start"): print("") print("Which Charcter Would you Like to Be?") level = "select" print (level) continue elif (command1.lower() == "skipmod"): print("") print("Where to?") skip = input("") if (skip == "2"): level = "2" continue while (level == "select"): print(" ________________________________________________") print("|Classes| Survivor | Brute | Assassin | Sniper |") print("|Health | 90 | 120 | 80 | 95 |") print("|Damage | 12 | 20 | 15 | 10 |") print("|Speed | 3 | 2 | 4 | 2 |") print("|Defense| 7 | 10 | 5 | 5 |") print("|Range | 2 | 1 | 3 | 5 |") print(" ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") print("1. Survivor") print("2. Brute") print("3. Assassin") print("4. Sniper") print("") charclass = input("") if (charclass == "1" or charclass == "2" or charclass == "3" or charclass == "4" ): if (charclass == "1"): playerclass = "Survivor" elif (charclass == "2"): playerclass = "Brute" elif (charclass == "3"): playerclass = "Assassin" elif (charclass == "4"): playerclass = "Sniper" print("") print("Are you sure?") print("Yes") print("No") print("") sure = input("") else: print("Select a valid option") print("") continue if (sure.lower() == "yes"): level = "2" while (level == "2"): print("") print("Select a name") print("") name = input("") print("") print(name + " Is that right?") print("Yes") print("No") print("") nameright = input("") if (nameright.lower() == "yes"): print("") print("hello " + name + " the " + playerclass) print("") print("Would you like to start the game?") startgame = input("") if (startgame.lower() == "yes"): print("A few pointers before you start your adventure.") print("1. Permadeath is on (meaning if your health reaches 0 your dead.)") print("2. To see your stats type in \"Hud\" when you finish the prologue") print("3. You choose where you shoot but the more damage it does the less chance you have of hitting that shot") print("so if you aim for the head it will do alot more damage than a shot to the arm or leg") time.sleep(15) print("Game loading") print(".") time.sleep(3) print(".") time.sleep(3) print(".") print("You wake up with hazy vision in a unfimiliar bed, you're vision isn't clear enough to see much but you see a figure across the room") print(name + ": Where am I?") input("Press enter") print("Mysterious Voice: You've been sleeping for a while now. Good to see your well enough to talk after what you went through") if (playerclass == "Survivor"): playerhealth = 90 playerdamage = 12 playerspeed = 3 playerdefense = 7 level = "3" elif (playerclass == "Brute"): playerhealth = 120 playerdamage = 20 playerspeed = 2 playerdefense = 10 level = "3" elif (playerclass == "Assassin"): playerhealth = 80 playerdamage = 14 playerspeed = 4 playerdefense = 5 level = "3" elif (playerclass == "Sniper"): playerhealth = 95 playerdamage = 10 playerspeed = 2 playerdefense = 5 level = "3" while (level == "3"): print("") print("Select an option") if (op1 != 0): print("1. Reach for your pistol") if (op2 != 0): print("2. Ask who they are") if (op3 != 0): print("3. Ask where you are") if (op4 != 0): print("4. Stay silent") print("") choice = input() if (choice == "1"): print("you reach for the holster you were wearing last you could remember but only feel flesh as you grab for your gun that is not there") input("Press Enter") print("Mysterious Voice: Had to make sure that you wouldn't try anything so I took your gun while you were knocked out") op1 = 0 elif (choice == "2"): print(name + ": Who are you?") input("Press Enter") print("Mysterious Voice: Just a good person or so it seems.") op2 = 0 elif (choice == "3"): print(name + ": You didn't answer my first question. Where am I?") input("Press Enter") print("Mysterious Voice: Somewhere safe") op3 = 0 elif (choice == "4"): op1 = 1 op2 = 2 op3 = 3 op4 = 4 print(name + ":...") input("Press Enter") print("Mysterious Voice: I didnt take you for the silent type but i guess you can't judge a book by its cover. Whatever, I'll leave you be. Ill be back later to check on you") input("Press Enter") print("") print("He left the room. What are you going to do?") level = "4" else: print("Select a valid option") continue while (level == "4"): print("1. Look for a weapon") print("2. Hide") print("3. Try to escape") print("4. Stay in bed") choice = input() else: print("Reselect your character") continue else: print("Im afraid that is not a command") continue