I want to make in LabView a game similar to this: memory game
but I get stuck in a infinite loop and do not know how to get out.
This is what I have so far :
This is a piece of code for two of the buttons. In my opinion there are only 3 possible cases (bt1 and bt2 are the identical buttons):
The 'once' variable indicates if another button was pressed before (0-was not pressed before ; 1- was pressed before).
As you can see the infinite loop occurs between the 2nd and the 3rd case. Any suggestion of how I can solve this would be very helpful.
Update: In the middle part I deleted the part where 'once' receives the value 0, to avoid the infinite loop. (after BT1 and BT2 are set false)
The reason it is not working is as follows:
Depending on the speed of the while loop it may not be possible to notice the change. Highlight execution is useful here.
The issue with your structure is that the there is no difference between case 2 and case 3, i.e. you could set the cards to have a value, if equal case one if not case 2 and junk case three as two cards not turned.
Rather than use Boolean, use something with a value, e.g. picture controls.
The following uses an event listener to monitor button presses:
There are four controls, 2 skull & 2 apple.
If more than one control is clicked there is a check for equality and if true the the controls are hidden, if false they revert to grey.
You can have as many pictures as desired in this scenario,