LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

User Events Generation - TicTacToe

Hey everybody,
 
In order to get a better understanding of how the event structures are used, I have been playing around with making a tic tac toe game (ironically, i did not know that was a coding challenge until I just started this thread). 
 
Anyways, the way I'm doing it is by dynamically registering a mouse move event during mouse down on a boolean control (your game 'marker').  Then when the control is moved overtop of an activex container the boolean lights up.  Right now, however, it only works for one of the game pieces ('Dot 8').
 
My question is this, can someone please show me how to create a user event?  I want to create an event where when any boolean control's position is within the bounds of the activex containers it will light up.  I could do this manually with a whole lot of logic (you'll get the idea if you check out the code) but that is rediculous and wouldn't help my learning exercise at all.
 
Thanks so much for the help!
 
Jonathan
 
(Code is attached)
0 Kudos
Message 1 of 4
(2,517 Views)

First, I'll suggest the simple suggestion - avoid ActiveX and go for what's simpler and more elegant. Simply have the user click in a game array with alternating clicks determining whether it's X or O. You can figure out how to detect the clicked cell yourself or you can try taking a look at the VI posted here for some reference.

As for how to generalize this, the first solution which pops to mind would be to subVI the code you have on the top. Make the control reference a control (which you can get from the event terminal) and make the ActiveX references an array. Build the array once outside your main loop and wire the array into the subVI. Then, auto index it to find whether your control overlaps one of its elements.


___________________
Try to take over the world!
Message 2 of 4
(2,481 Views)

Awesome tst thanks, i'm gonna go play things for a moment and see what i come up with...  I like the idea of making the activex refs an array so i can just index through them.  I think that'll work.  Oh and I could make the tic tac toe game really easily other ways, I'm just doing it this way to learn.  It's not for the coding challenge just for my own advancement.

thanks again

0 Kudos
Message 3 of 4
(2,468 Views)
If you want to look at the code of my interface posted HERE, See attached (LabVIEW 7.1). It uses simple mouse-down events on the array indicator to determine where to place the correct piece.
 
Enjoy!
 
(Disclaimer: The code is not fully tested and documented. There could be bugs 😉 There is also room for improvements)
 
0 Kudos
Message 4 of 4
(2,463 Views)