C-Snake | A simple snake game implemented in C++
kandi X-RAY | C-Snake Summary
kandi X-RAY | C-Snake Summary
A simple snake game implemented in C++
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of C-Snake
C-Snake Key Features
C-Snake Examples and Code Snippets
Community Discussions
Trending Discussions on C-Snake
QUESTION
I've made a snake game in WPF which works perfectly using WASD, but when I use the arrow keys instead, using the exact same code, it lags for 5 seconds after each key press.
A feature of the game is that you can adjust the play area size. When the play area size is small, the delay is short to non-existant. When the play area size is large, the delay is much more noticable. I do not however think the issue is with the game size, as it works fine with WASD.
The code I use to capture key input is below:
...ANSWER
Answered 2018-Nov-13 at 12:23Set e.Handled = true
in all cases.
The arrow keys have a function in the WPF framework (positioning, resizing). If you indicate that your user code has handled them, they are no longer forwarded to the windowing framework, which obviously takes its time processing those.
Another option is to capture the keystrokes earlier in the event pipeline, by overriding OnPreviewKeyDown
and call its base only for keystrokes you don't process.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install C-Snake
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page