Search code examples
loopssmallbasic

Error message inside a loop - Pong game


I am making a game similar to pong in small basic. What I want to do is when the ball hits the wall the game ends and shows an error message.

What I did was use a while loop as such below:

While (hits right wall) or (hits left wall) or (hits top wall) or (hits bottom wall) = "True" 
    GraphicsWindow.ShowMessage("you lost", "game over")
Endwhile

What that actually does is keep repeating the error message and I have to quit the program. How can I get it to just show the message once when the conditions for it hitting either wall is true?


Solution

  • Use break once the condition is met and once you show the error message.