Upon closer inspection of your original code... I find my previous answer was a bit incomplete. Sorry.
1 2 3 4
|
//Tell the game manager to add a move
hdc = BeginPaint(hWnd, &ps);
game.SetMove( xPos, yPos, hdc, hWnd);
EndPaint(hWnd, &ps);
|
BeginPaint/EndPaint pairs only allow you to draw to the area of the screen that has been Invalidated (with InvalidateRect). If you don't invalidate the screen, the drawing here does nothing. This is why you were not seeing onscreen changes.
A "fix" (really, a hack) is to use GetDC/ReleaseDC instead of BeginPaint/EndPaint. Or Invalidate the desired rect(s) before calling BeginPaint.
-----------
That said -- I stand by my original post in that the layout you're going for here is fundamentally flawed. Sleeping (or worse...
deadlocking) for any period of time makes your program completely unresponsive for that period of time. For only 1 second it might not be so bad, but for longer time periods you're just asking for trouble.
If you really want to use this wait method (I understand the appeal -- it certainly is simpler than setting up a timer), then
at least use Sleep() instead of that custom wait() function:
|
Sleep(1000); // wait for 1 second
|
Sleep tells the OS that your program does not need CPU time, which allows other programs to take CPU time. Whereas deadlocking in a while() loop makes your program chew up 100% of the CPU time reducing overall system performance.
As for how to use SetTimer -- look it up.
http://msdn.microsoft.com -- search for SetTimer, KillTimer, or WM_TIMER (read: not WM_SetTimer). I'm sure there are examples.