[Tutor] RPG game.
. ,
administrata at hotmail.com
Fri May 20 17:41:29 CEST 2005
It works fine but, at the end of the program total damage has to be shown.
Only single damage is shown. How can i change it?
-------------------------------------------------------------------------------------------------------------------------------------------
import random
print \
"""
Warrior - damage: 10~60
Archer - damage: 0~100
HP of Player: 100
HP of the monster: 300"""
wp = raw_input("\n\nSelect between warrior and archer: ")
mob = 300
hit = 0
hp = 100
dmg = 0
atk = 0
run = ""
while (mob > 0):
hit += 1
mob = mob - dmg
hp = hp - atk
if wp == "warrior":
dmg = random.randrange(50) + 10
atk = random.randrange(10)
elif wp == "archer":
dmg = random.randrange(100)
atk = random.randrange(5)
else:
print "\nError"
print "\n", hit, "hits"
print "HP of", wp,":", hp,"/100"
print "HP of the monster:", mob,"/300"
print "\nYou defeated the monster by", hit,"hits,", dmg,"damage" #HERE
raw_input("")
-------------------------------------------------------------------------------------------------------------------------------------------
And I tired to add a while loop to make the program able to run again. But,
it doesn't work..
-------------------------------------------------------------------------------------------------------------------------------------------
import random
print \
"""
Warrior - damage: 10~60
Archer - damage: 0~100
HP of Player: 100
HP of the monster: 300"""
wp = raw_input("\n\nSelect between warrior and archer: ")
mob = 300
hit = 0
hp = 100
dmg = 0
atk = 0
run = ""
while True:
while (mob > 0):
hit += 1
mob = mob - dmg
hp = hp - atk
if wp == "warrior":
dmg = random.randrange(50) + 10
atk = random.randrange(10)
elif wp == "archer":
dmg = random.randrange(100)
atk = random.randrange(5)
else:
print "\nError"
print "\n", hit, "hits"
print "HP of", wp,":", hp,"/100"
print "HP of the monster:", mob,"/300"
print "\nYou defeated the monster by", hit,"hits,", dmg,"damage"
run = raw_input("\n\nrun or exit ") #This Part
if run == "exit":
break
elif run == "run":
continue
else:
raw_input("\nError")
break
-------------------------------------------------------------------------------------------------------------------------------------------
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
More information about the Tutor
mailing list