none
Restart Function RRS feed

  • Question

  • How do you restart a entire program from the bottom to the top. I want if the user enters replay then the program should restart to the beginning. Please help
    Thursday, September 3, 2009 12:44 PM

Answers

  • I have written a simple "Pong" game, and what I did was to group all of my initialization code into a sub-routine I call "SetUp".  Next, I put my main run-time code in a Sub called "MainLoop".  Then, when the game ends, there is another sub called "PlayAgain", which just asks the user whether they wish to play again.  If not, it simply ends, but if yes, then it just calls SetUp & MainLoop again, and we're ready to go. 
    Thursday, September 3, 2009 6:38 PM

All replies

  • It depends on how you want to implement it.
    You can use while loop with condition always true unless user change it to false.

    Another way you can just use GOTO keyword

    I suggest you read chapter 5 on the Introducing Small Basic.pdf file that comes with SB installation.
    Thursday, September 3, 2009 2:29 PM
  • I have written a simple "Pong" game, and what I did was to group all of my initialization code into a sub-routine I call "SetUp".  Next, I put my main run-time code in a Sub called "MainLoop".  Then, when the game ends, there is another sub called "PlayAgain", which just asks the user whether they wish to play again.  If not, it simply ends, but if yes, then it just calls SetUp & MainLoop again, and we're ready to go. 
    Thursday, September 3, 2009 6:38 PM