Computer Science Canada

Turing Concentration Game Help

Author:  canadianeagle [ Tue Jan 21, 2014 7:59 pm ]
Post subject:  Turing Concentration Game Help

wow
<Trying to make Concentration game in turing>


wow
<Don't know how to write an if statement for this situation. There are 16 different buttons and I need help figuring out : if one button is clicked, then another button is clicked,
how do i check if the words flipped over are equal?>


Describe what you have tried to solve this problem
<>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<>

Turing:


<%creating button procedures and buttons
procedure PressBtn1
    play ("2a")
    button (1) := GUI.CreateButtonFull (30, 355, 90, "1", PressBtn1, 70, '^D',
        true)
    GUI.SetColour (button (1), brightred)
    GUI.SetLabel (button (1), Term (2))
end PressBtn1
button (1) := GUI.CreateButtonFull (30, 355, 90, "1", PressBtn1, 70, '^D',
    true)>



Please specify what version of Turing you are using
<Turing 4.1.1>

Author:  Zren [ Tue Jan 21, 2014 10:37 pm ]
Post subject:  RE:Turing Concentration Game Help

Quote:
how do i check if the words flipped over are equal?


Equal ... what? equal colour?

Turing's GUI module doesn't have a getter function for that.

http://compsci.ca/holtsoft/doc/gui.html

You could, however, store that data elsewhere.

Turing:

var buttonValues : array 1 .. 16 of int
buttonValues(1) := brightred
buttonValues(2) := brightred
buttonValues(3) := green
% ...



EDIT:

And because you seem like the type to copy paste functions. I'll give you a tip. Since you're going to be having a lot of buttons that do almost the same thing, try using another procedure with a parameter.

Turing:

proc onButtonPress(buttonId:int)
    % Do your logic here.
    if buttonValues(buttonId) ...

    end if
end onButtonPress

proc onButton1Press()
    onButtonPress(1)
end onButton1Press

proc onButton2Press()
    onButtonPress(2)
end onButton2Press


: