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

Username:   Password: 
 RegisterRegister   
 How do you restart a game in turing after you have shown them that you have lost or won
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ZZK




PostPosted: 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



HANGMAN_Group.t
 Description:
the game

Download
 Filename:  HANGMAN_Group.t
 Filesize:  8.34 KB
 Downloaded:  419 Time(s)


HANGMAN_Group.t
 Description:
the game

Download
 Filename:  HANGMAN_Group.t
 Filesize:  8.34 KB
 Downloaded:  265 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: 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).
Kharybdis




PostPosted: 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.
ProgrammingFun




PostPosted: 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.
copthesaint




PostPosted: 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.
Turing:
var winOne : int := Window.Open ("Graphics,Offscreenonly,NoButtonBar")
Draw.FillOval (maxx div 2, maxy div 2, maxy div 2, maxy div 2, red)
View.Update
delay (1000)
var f : int
open : f, "Reset.txt", put
put : f, "There is a line here"
close : f
Window.Close (winOne)


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.
ponchu




PostPosted: 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
Insectoid




PostPosted: 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.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: