you might get some ideas from. I didn't test any of this:
Code:
velocityX:=0;
velocityY:=0;
repeat
StartTime:=GetTickCount;
Key:=SomeGetKeyFunction(); // Some function that doesn't stop waiting for press
// return 0 or something if nothing was pressed.
case Key of
VK_LEFT: velocityX:=-1;
VK_RIGHT: velocityX:=1;
end;
ballX:=ballX+velocityX;
ballY:=ballY+velocityY;
DrawScene;
// If drawing and moving would take different amount of time each frame
// then you may need to control the delay length.
// So that it runs same speed on all computers.
DelayTime:=50-(GetTickCount-StartTime);
if DelayTime>0 then Delay(DelayTime);
until Key = #27;
This is just a quick and dirty delay solution, but it should work decently enough for some simple projects.
Bookmarks