How do you restart a game in turing after you have shown them that you have lost or won
Author |
Message |
ZZK
|
Posted: Fri Apr 30, 2010 6:01 am Post subject: How do you restart a game in turing after you have shown them that you have lost or won |
|
|
What is it you are trying to achieve?
Trying to get a restart option in my hangman game
What is the problem you are having?
I dont know how to have a restart button
Please specify what version of Turing you are using
4.1
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
HANGMAN_Group.t |
Filesize: |
8.34 KB |
Downloaded: |
422 Time(s) |
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
HANGMAN_Group.t |
Filesize: |
8.34 KB |
Downloaded: |
271 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
ProgrammingFun
![](http://compsci.ca/v3/uploads/user_avatars/11682880074bcb590d30b0a.png)
|
Posted: Fri Apr 30, 2010 7:14 am Post subject: Re: How do you restart a game in turing after you have shown them that you have lost or won |
|
|
You could put the whole thing in a loop.
In the end, ask if you want to play again.
If player says yes, end if
If player says no, exit loop.
Turing: |
loop
%main program here
%program has ended
var playagain: string (1)
put "Enter y to restart game or enter any other key to quit."
getch (playagain )
if playagain = "y" then
end if
else
exit loop
end if
end loop
|
Above is a basic example (may have syntax errors tho).
|
|
|
|
|
![](images/spacer.gif) |
Kharybdis
![](http://compsci.ca/v3/uploads/user_avatars/111642592477ec7e78e574.gif)
|
Posted: Fri Apr 30, 2010 9:51 am Post subject: RE:How do you restart a game in turing after you have shown them that you have lost or won |
|
|
If you're using procedures and functions, just have a procedure for your "main game', and then your actual 'main' procedure.
In that main procedure, create a loop. To run the game, just call the "main game" procedure. When that procedure ends, ask them if they want to play again. If not, you just stop the loop, and boom, you're done. Otherwise, it'll run the procedure "main game" once again.
|
|
|
|
|
![](images/spacer.gif) |
ProgrammingFun
![](http://compsci.ca/v3/uploads/user_avatars/11682880074bcb590d30b0a.png)
|
Posted: Fri Apr 30, 2010 3:17 pm Post subject: RE:How do you restart a game in turing after you have shown them that you have lost or won |
|
|
Kharybdis has a good and efficient point.
|
|
|
|
|
![](images/spacer.gif) |
copthesaint
![](http://compsci.ca/v3/uploads/user_avatars/15853548854c9c056fda48d.jpg)
|
Posted: Fri Apr 30, 2010 9:43 pm Post subject: Re: How do you restart a game in turing after you have shown them that you have lost or won |
|
|
Heres a way to reset your program, I made these two files so you can try it out.
Save this file as Circle.t and then generate an executable of it.
This file is going to run the Circle program.
Turing: | var window : int := Window.Open ("Graphics,Offscreenonly,NoButtonBar")
var playCircle : boolean := true
for i : 0 .. 3
loop
if playCircle then
if Sys.Exec ("Circle.exe") then
Window.Hide (window )
put "running program"
playCircle := false
end if
else
if File.Exists ("Reset.txt") then
Window.Show (window )
put "program Finished."
File.Delete ("Reset.txt")
if Error.Last = eNoError then
put skip, "Reset.txt deleted"
else
put "could not delete Reset.txt"
end if
playCircle := true
exit
end if
end if
end loop
end for
Window.Close (window )
|
So just make the file that will load the game the 'main menu' and then have your main menu start the game.
you can do this in alot of ways, Im just showing you how there are alot of options for how to do this and opening your mind to new Ideas.
|
|
|
|
|
![](images/spacer.gif) |
ponchu
![](http://compsci.ca/v3/uploads/user_avatars/107072339154cb9411c80f5.jpg)
|
Posted: Thu Feb 05, 2015 9:09 am Post subject: RE:How do you restart a game in turing after you have shown them that you have lost or won |
|
|
hey, wondering how to restart by pressing a GUI button instead of imputing a letter such as "y" thanks
|
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Thu Feb 05, 2015 4:29 pm Post subject: RE:How do you restart a game in turing after you have shown them that you have lost or won |
|
|
It's the same concept. If you understand how to use the GUI, this tutorial should be adequate help.
|
|
|
|
|
![](images/spacer.gif) |
|
|