i have made a simple ping pong game and i would like to make the panel to move when the key was pressed but the ball itself would wait a time period...
here's my code i have no idea on how to do this so i'm asking you
Hello, it's always good to check if a key is hit. Use the following code:
1 2 3 4 5 6 7 8 9 10 11 12
if (kbhit())
{
char key = getch();
if (key == LEFT )
{
// Move left
}
elseif (key == RIGHT)
{
// Move right
}
}
kbhit() checks a memory buffer and tells if a button is hit. When you invoke getch() it will return you the char from the memory buffer and clear it. After that kbhit() will return false.