LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Key down event structure, need help

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.

0 Kudos
Message 1 of 3
(2,959 Views)

keys just work fine for me, use proper State machine and poll for the Key events properly.

Avoid  Sequence Structure when possible

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 3
(2,946 Views)

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:

check.png

- 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:

check1.png

The whole game stuff is hidden in those 4 subVIs… 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 3
(2,937 Views)