You also have to check for special events that change the state of your program - if the player goes through a door or finishes a stage or is defeated by an enemy, etc. and move to different loops throughout your program accordingly. As far as breaking out of a loop, yes, you can do it if you need to, but how you do it depends on the kind of loop you've got.