![]() |
loop doesn't advance-py3 text game - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: loop doesn't advance-py3 text game (/thread-3595.html) |
loop doesn't advance-py3 text game - foxtreat - Jun-06-2017 Making a simple fighting text based game where you can fight turn based and gain xp with which you can buy more hp.armour and etc.however it needs to have a menu .curently making the shop but i made the whole thing loop so the game doesn't end after you fight or buy things.but no matter what input i enter it keeps looping main menu and i dont get errors.im really new to python .please help.thanks in advance print ("\n"*100) name = input("whats your name?:") maxhp = 100 armor = 0 maxdmg = 20 mindmg = 5 xp = 0 hp = maxhp play = 1 while (play == 1): print ("\n" *100) print ("health:"+str(hp)) print ("max health:"+str(maxhp)) print (" 1 to fight.2 to heal or upgrade.3 to exit") choice=input(":") if (choice == 3): play = 0 choice = 0 while (choice == 2): print ("\n" * 100) print ("your XP:" + str(xp)) print ("1 to heal to max health: 10 XP") print ("2 to add 1 armour:2 XP") print ("3 to add 3 to max and min damage") print ("4 to add 10 maxhp,needs hepal:20xp") print ("5 to go back") shop=input(":") if (shop==5): print ("exiting") choice = 0 break if (shop==1): if (hp == maxhp): print ("you are already on max HP") choice = 0 else: if (xp >= 10): hp = maxhp xp = xp - 10 choice = 0 else: print ("you don\'t have enough xp") else: exit RE: loop doesn't advance-py3 text game - volcano63 - Jun-06-2017 input returns string value - convert it to integerchoice = int(choice)Same goes for shop
RE: loop doesn't advance-py3 text game - foxtreat - Jun-08-2017 (Jun-06-2017, 02:14 PM)volcano63 Wrote: I didn't know it worked that way but instead of changing the input to a integer i changed the if a=1 to a string as if a="1" |