I don't really know how to type the Title so I came up with this. So basically I am trying to make some sort of a snake in C. But I don't know how to make the controls. Lets say you have pressed left arrow and the snake has to move left till another key is pressed but I can't come up with the code for that its always stopping and waiting for me to press the key.
I was thinking for something like this:
for ( i = 0; i < 10 ; i++ ) {
if( next_move = getch() ) break;
else Sleep(10);
}
if(!next_move)
next_move = prev_move;
if( move ( next_move, bite_cord ) ) {
prev_move = next_move;
next_move = 0;
Sleep(300);
system("CLS");
printf("You lost. ");
}
My idea was to wait one second and if theres no key pressed to continue with the previous one but if its pressed to save the pressed now.
Do you have any ideas of how to do it?