I'm new to the series and brand new to the forum, but I'm loving the adventure so far...
However I don't like copying without really understanding and am always searching
deeper into how things work.
I'm following the series but every time I don't understand something I start implementing it myself,
usually with really ugly code, but I enjoy learning how it all works. However as you would expect
I've struggled with everything and only made it to episode 9 or so... just finished implementing
DirectSound in pure c... I hate COM xD
Anyway, my issue is window messages. I've tried to use WASD and Arrow keys for movement, but in a simple
test, Arrows key end up sending thousands of messages a second. While Characters send messages as you
would expect ( a pause, then repeat is activated ).
-- This is the code I'm using for testing at the moment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ... switch(message){ //case WM_SYSKEYUP: //case WM_KEYUP: //case WM_SYSKEYDOWN: case WM_KEYDOWN: { switch(wParam){ case VK_LEFT: { arrow++; //arrow is a global variable for testing }break; case 0x41: { //'A' letter++;//same as arrow }break; default: { }break; } }break; ... |
-- I then print out the variables:
printf("> arrow : %d \n> letter : %d \n", arrow, letter);
-- The output after holding down each key for (roughly) 2 seconds is this:
(both variables are initialised to zero)
arrow : 621096
letter : 31
If my keyboard isn't the culprit then I suggest
I have to manipulate the repeat-count of the messages,
or process a certain amount of messages per frame
This is probably normal behaviour but I can't find any reference to it
(that's why I'm making a post)
I've tried moving until the WM_KEYUP and WM_SYSKEYUP messages are processed
and I get better movement, the difference in messages
is still huge and it feels wrong and I don't understand it :-(
If someone knows what's going on here please let me know.
By the way this is my first forum post ever, I hope it's in the right place and such
Thankyou