Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do something like this:</p> <p>Use SetTimer to create a timer on your window event loop 10ms interval should be good for what you want. The reason it has to be on the window thread is that GetAsyncKeyState will not give you the desired results when called from a different thread. We use a timer since the call to GetAsyncKeyState should be on a different message then the key processing events so the key is still in the queue.</p> <p>Within the timer function you can do something like this</p> <pre><code>int deltaX = 0, deltaY = 0; unsigned int downDown = GetAsyncKeyState(VK_DOWN); unsigned int upDown = GetAsyncKeyState(VK_UP); unsigned int leftDown = GetAsyncKeyState(VK_LEFT); unsigned int rightDown = GetAsyncKeyState(VK_RIGHT); if(downDown &amp; 0x00008000)deltaY -= MOVEDELTA; if(upDown &amp; 0x00008000)deltaY += MOVEDELTA; if(leftDown &amp; 0x00008000)deltaX -= MOVEDELTA; if(rightDown &amp; 0x00008000)deltaX += MOVEDELTA; g_cObjectWorld.AdjustCueBallX(deltaX); g_cObjectWorld.AdjustCueBallY(deltaY); g_cObjectWorld.ResetImpulseVector(); </code></pre> <p>In this way you can also make sure that the movement stops on keyup (deltaX == 0 &amp;&amp; deltaY == 0) I'm not sure what are the semantics of AdjustCueBall(X|Y) but if you make sure they stop moving in that direction when they get 0 it should work just fine.</p> <p>Also you should notice that your keyboard must support multiple key press in the hardware for you to be able to move diagonally using two keys - If it does the solution above will work if it doesn't you will still be able to move in either one of the four fundamental directions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload