Computer Science Canada yes or no button,yes = game restart, no = quit |
Author: | SamF [ Sun Jan 03, 2010 3:47 pm ] |
Post subject: | yes or no button,yes = game restart, no = quit |
What is it you are trying to achieve? I want to make 2 buttons for my game at the end of the game, a yes button and a no button. Hitting yes will cause the game to restart, hitting no causing the game the close Describe what you have tried to solve this problem I havent tried this but i was thinking about it, creating two buttons, and i copy paste the whole program into the loop if the person hits yes and if he/she hits no i just put quit Turing 4.1.1 |
Author: | imbored [ Sun Jan 03, 2010 3:51 pm ] |
Post subject: | RE:yes or no button,yes = game restart, no = quit |
or you can just put a loop until they hit no... and then make a ending screen like "THE END!!!" or something idk what your doing... maybe "GAME OVER" at the end with a nice back ground and sound effects |
Author: | SamF [ Sun Jan 03, 2010 5:22 pm ] | ||
Post subject: | yes or no button,yes = game restart, no = quit | ||
This isnt my actual program, i just created it as an example, is there a way tht i could do something so in the buttons process, i dont have to copy paste the program into there, because the actual program i made is about 400-500 lines long, and i dont want to copy paste because then there would be too many lines.
|
Author: | imbored [ Sun Jan 03, 2010 6:15 pm ] |
Post subject: | RE:yes or no button,yes = game restart, no = quit |
umm after "would you like to play again" you dont have to re do the "guess the number thing" again in the procedure. In the main program you already have the guessing game. so the procedure only handles the button inputs. so instead of having your procedure do the same thing the main program is doing. Just put the graphics of the button and the if statements so when the mouse is clicked into that space it activates kinda thing. Instead of putting if and then repeating the stuff in your program... just make a boolean true and false. so "if mouse hits yes" then bpValue := true and "if mouse hits no" then bpValue := false. In the mainprogram you have have it "exit when bValue := false". You would also have to make the procedure either a function of a procedure with a pass by reference. |
Author: | SamF [ Sun Jan 03, 2010 6:32 pm ] |
Post subject: | RE:yes or no button,yes = game restart, no = quit |
im kinda new to boolean so i dont really know how to work with it, do i have to create a new variable called bpValue, if i do, of what type does it have to be? |
Author: | imbored [ Sun Jan 03, 2010 6:52 pm ] |
Post subject: | RE:yes or no button,yes = game restart, no = quit |
for a boolean its just true and false thats all the thing it takes. and for your procedure its procedure button(var bpValue :boolean) there is a var there because that would allow it to change the value of the variable. for the main program you would have var bValue : boolean something like that and to call the procedure buttons(bValue) ps: the name bpvalue is just (boolean)(parameter)(name) thats how i do variables so i know what the variable is for. |