[Tutor] Running RPG game again.

R. Alan Monroe amonroe at columbus.rr.com
Sat May 21 16:55:41 CEST 2005


> I'm trying to make the RPG game to be able to run again.

> But, when I type "run", nothing happens.

It's because your continue statement on line 45 loops around to line
19 (I double checked in the debugger).

Then it checks if the monster is still alive (AGAIN) on line 20, but
the monster is already dead, so the whole inner while loop is skipped
and the program will jump straight to line 43 again.

You might want to change your outermost while loop to something like
this:

iloveplaying=1
while iloveplaying:
    (move all the variable setup inside the main while loop
     that way the monster is reborn every time you play)

    while (mob>0):
        (do all the fighting stuff here as normal)

    run = raw_input("\nrun or exit ")
    if run != "run":
        iloveplaying=0



Alan



More information about the Tutor mailing list