Python text game - Cant exit a while loop
<p>this is the main code:</p>

<pre><code>import MainMod
print("Welcome!")
print("Note: In this games you use wasd+enter to move!\nYou press 1 key and then enter,if you press multiple kets it wont work.\nYou will always move by 5 meters.")
CurrentRoom = 1

#Limits work this way!1st and 2nd number are X values(1st is &lt;---- limit,2nd is ---&gt; limit)
#3rd and 4th are y values(1st is v limit,2nd is ^ limit)
# X and Y are coordinates; 0,0 is the starting point of every room
while True:
    if CurrentRoom ==1:
        print("This is room 1")
        MainMod.roomlimits = [-15 , 15, -15 , 15]
        MainMod.doorloc1 = [-15,10,15]
        MainMod.doorloc2 = [15,-2,2]

    while CurrentRoom == 1:
        MainMod.MainLel()

        if MainMod.door1 == 1:
            print("DAMN SON")
            CurrentRoom = 2
            break
        elif MainMod.door2 == 1:
            print("Plz no")
            CurrentRoom = 3
            break

    while CurrentRoom == 2:
        MainMod.MainLel()
</code></pre>

<p>and this is the MainMod module is :</p>

<pre><code>x = 0
y = 0
roomlimits = 0
doorloc1=0
doorloc2=0
door1 = 0
door2 = 0
direct = 0

def MainLel():
    global direct
    movementinput()
    movement(direct)
    doorcheck()

def movement(dir):
    global x,y,roomlimits,door1,door2,doorloc1,doorloc2

    if dir == "w":
        y += 5
        if y &gt; roomlimits[3]:
            y = roomlimits[3]
        print("Youre current coordinates are x:",x," y:",y)
    elif dir == "s":
        y -= 5
        if y &lt; roomlimits[2]:
            y = roomlimits[2]
        print("Youre current coordinates are x:",x," y:",y)
    elif dir == "d":
        x += 5
        if x &gt; roomlimits[1]:
            x = roomlimits[1]
        print("Youre current coordinates are x:",x," y:",y)

    elif dir == "a":
        x -=    5
        if x &lt; roomlimits[0]:
            x = roomlimits[2]
        print("Youre current coordinates are x:",x," y:",y)

def movementinput():
    global direct
    while True:
        direct = input("")
        if direct in ("w","a","s","d","W","A","D","S"):
            break
        else:
            print("You failure.")

def doorcheck():
    global x,y,doorloc1,doorloc2,door1,door2
    if x ==  doorloc1[0] and doorloc1[1] &lt;= y &lt;= doorloc1[2]:
        door1 = 1
    elif y == doorloc2[0] and doorloc2[1] &lt;= x &lt;= doorloc2[2]:
        door2 = 1
    else:
        door1,door2 = 0,0
</code></pre>

<p>Im using a module instead of classes because i dont know how to use classes yet,anyways,what happens in the program is that if i am in the door location,it simply prints "DAMN SON" and doesnt break out of the Room loop,any help?   EDIT NOTE: I added the break statement later on to try if it would help,sadly it didnt,i am also a bit tired so im guessing i made a logic mistake somewhere,thanks in advance for help.</p>

<p>Final edit: The code was functional all along,i was just testing it incorrectly!Thanks for the awnsers,ill close this question now.</p>

<p>Since I could not imagine it didn't work, I added two markers (print commands), to room 1 and 2:</p>

<pre><code>while CurrentRoom == 1:
    print("one")
    mod.MainLel()
</code></pre>

<p>and</p>

<pre><code>while CurrentRoom == 2:
    print("two")
    mod.MainLel()
</code></pre>

<p>This is what happened:</p>

<pre class="lang-none prettyprint-override"><code>Youre current coordinates are x: -5  y: 15
one
a
Youre current coordinates are x: -10  y: 15
one
a
Youre current coordinates are x: -15  y: 15
DAMN SON
two
a
Youre current coordinates are x: -15  y: 15
two
</code></pre>

<p>It turned out to be working fine. The <code>break</code> is redundant however. The loop will break anyway, since the condition becomes <code>False</code>.</p>

python