04-25-2017 01:46 AM
Hello,
I'm trying to make SNAKE game, i need help with key down event. I want to use arrow keys to change heading of snake. When i run the program, keystrokes are not registered at all, I would like to know, what's wrong. Also, if you have any better idea of handling snake movement, let me know (would like simple solutions, i'm new to labview).
Thanks for help.
04-25-2017 02:03 AM - edited 04-25-2017 02:05 AM
keys just work fine for me, use proper State machine and poll for the Key events properly.
Avoid Sequence Structure when possible
04-25-2017 02:09 AM - edited 04-25-2017 02:13 AM
Hi Ambroz,
- why are there 2 event structures in just one loop in your only VI?
- why do you use a sequence structure?
- why don't you use a state machine?
- your first frame can be simplified to:
- why do you use a WaitForMultiple function, when the event structure next to it already has a timeout event for the very same wait time?
- why do you have this very "interesting" construct twice in your VI?
- Do you know how event structures work? Do you know what happens when you configure the very same event for two event structures in the very same VI?
When something doesn't work you should create a simple VI for testing purposes and try to understand this very feature you want to implement!
As an inspiration this is the main loop of my Snake version:
The whole game stuff is hidden in those 4 subVIs… 😄