In my game, I am trying to make it so when the enemy's health equals 0, the player advances. I used a while statement and a true or false variable. When the enemy health is less than or equal to 0, the program exits the while statement. It does not work. It keeps going. How could I fix this?

I really don't want any snarky or rude comments.

If you're using a boolean variable as your while condition and that while loop never exits, that means that either the variable is never set to False (because the part that's supposed to set it to False is never reached for some reason) or the body of the while loop contains an infinite loop itself.

Either way we won't be able to tell you what the problem is without seeing the code.

PS: Without having seen the code, it seems to me that using a boolean variable as the condition for the while loop is not the most straight-forward way to solve your problem. Something like while enemy.health > 0: should be perfectly sufficient.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.