Computer Science Canada GUI Rock, Paper, Scissor's Game |
Author: | Planet_Fall [ Sun Jan 26, 2014 10:06 pm ] | ||
Post subject: | GUI Rock, Paper, Scissor's Game | ||
My first GUI game, has buttons and a score keeper. Enjoy! ![]()
P.S I used Turing 4.1.1 |
Author: | Tony [ Mon Jan 27, 2014 12:19 am ] | ||||
Post subject: | RE:GUI Rock, Paper, Scissor\'s Game | ||||
is the same every time -- you could have just one copy of this code at the end of the procedure, instead of having the same code for every possibility. Similarly, all 3 procedures have identical structure. You can collapse them down into a single procedure that takes an argument for the user choice. Your GUI declarations would look something like
|
Author: | Planet_Fall [ Mon Jan 27, 2014 10:55 am ] |
Post subject: | Re: GUI Rock, Paper, Scissor's Game |
I'm new to GUI so that last example, goes a bit over my head. Do you know of a good GUI tutorial? And if it's possible could you run me through the last example? |
Author: | Zren [ Mon Jan 27, 2014 7:35 pm ] | ||||||
Post subject: | Re: RE:GUI Rock, Paper, Scissor\'s Game | ||||||
Why use 3 different booleans to represent 1 thing that can have 3 different states? Each of those booleans have 2 different states. 3 booleans have a sum of 8 (2*2*2) different states.
Instead, try using a single integer that can represent way more than 3 different states. Map certain values to a particular state. Eg: ROCK = 1, PAPER = 2, SCISSORS = 3 You can then do if choice = ROCK then ... which reads off better as well. Tony @ Mon Jan 27, 2014 12:19 am wrote: Similarly, all 3 procedures have identical structure. You can collapse them down into a single procedure that takes an argument for the user choice. Your GUI declarations would look something like
Fairly certain you can only use procedures without any arguments when using the GUI module. That doesn't stop you from creating a proc for when rock is pressed, that calls another function like so.
|