Restarting and Exiting 
	 
	
		| Author | 
		Message | 
	 
		 
		Krocker
 
 
 
    
		 | 
		
		
			
				  Posted: Wed Dec 08, 2010 1:34 pm    Post subject: Restarting and Exiting  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| hiya, how do i make a game that askes the player at the end whether they want to restart the game or exit. how wouldi make the game restart and or exit on command of a push button (parallelget) | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Zren
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Dec 08, 2010 1:56 pm    Post subject: RE:Restarting and Exiting  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Well you'd need to think. What programming structure allows you to repeat something hmmmm? Like, I want to play this game FOREVER man. /snide comments.
 
 
If your game uses a main game loop, envelop it in another loop so that it begins from the bigining? Stick a menu in there, and presto!
 
 
My advice is to remember to reset your variables to default, and stick things in procedures.
 
 
	  | Turing: | 	 		  
 
var choice : string
 
 
proc game
 
    loop
 
        put "~~~ nargles ~~~"
 
        exit when true % For testing purposes
 
        
 
        % Check Button status
 
        % exit when button = pushed
 
    end loop
 
end game
 
 
proc menu
 
    loop
 
        put "menu", skip, "  > " ..
 
        get choice
 
        case choice of
 
            label "yes" :
 
                game
 
            label : % Anything else quits the program
 
                exit
 
        end case
 
        
 
        % If you want to exit the game when button pushed
 
        % Check the status of it again and exit this loop as well
 
    end loop
 
end menu
 
 
menu
 
  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Krocker
 
 
 
    
		 | 
		
		
			
				  Posted: Sun Dec 12, 2010 11:04 am    Post subject: RE:Restarting and Exiting  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| uh? i dont get it. srry, im fairly new to turing, so ya. also, i have many loops in the game cause it needs to get value :=parallelget. so ya | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		TokenHerbz
 
  
 
    
		 | 
		
		
			
				  Posted: Sun Dec 12, 2010 1:06 pm    Post subject: RE:Restarting and Exiting  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				well you have a loop with your game, and put that into a procedure so you can call it at any time.  it exits when game is over.
 
 
you put that in another loop where it will only exit if you DONT want to restart the game, otherwise it will LOOP your game proc, thus restarting it.
 
 
any easier understanding set up would be:
 
 
	  | Turing: | 	 		  
 
procedure game %your game structure is inside here.
 
    loop
 
        put "You are playing the game in here"
 
        put "all game code/proc/fcn/etc in here"
 
        exit when %game is over
 
    end loop
 
end game
 
 
%%your main game loop structure works like this
 
 
loop
 
    %intro if you want one
 
    game %calls your game to play the game (will exit only when game is done)
 
    
 
    %%now lets ask to restart the game or not...
 
    %if answer is NO then
 
        exit
 
    %end if
 
    
 
    %otherwise what happens is we continue this loop, and it will call
 
    %our game to play again :) if we dont want to restart it exits this
 
    %loop, and our game wont be played again.
 
end loop
 
 
put "GAME OVER MAN, NO RESTARTS NOW!"
 
  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |