Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 need help with playing the game again...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
yingmu




PostPosted: Sun Mar 06, 2005 7:35 pm   Post subject: need help with playing the game again...

ok i made a questionaire game from ifs, wat do you do that can ask the player if he/she wants to play again and then let them replay the game?
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Mar 06, 2005 7:41 pm   Post subject: (No subject)

Put your whole program in a loop (or, not your whole program. Everything but the variables etc. Then, ask if they want to play again. If they say no, exit the loop. If they say yes, don't exit the loop. Instead, go back to the top of the loop, and do everything over again.

code:

%variables, procs, functions, etc.
var playAgain : string (1)
loop
    % main code.  Probably a lot of if statements ;)
    put "Would you like to play again?  y/n" ..
    getch (playAgain)
    if playAgain = "n" or playAgain = "N" then
        exit
    end if
end loop

Note that that has some problems in that the user can enter "q" and it will restart. You'll have to fix that. Wink
Delos




PostPosted: Sun Mar 06, 2005 7:41 pm   Post subject: (No subject)

Put the whole thing in a loop. before the end of the loop, insert a part asking whether a repition is req'd. If it is not, then exit the loop.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: