getch() function
getch() function
(OP)
I have written a simple game with a ball which bounces off the margins of the screen and at the bottom of the screen is my pad which is controlled by 'a' and 'd' buttons on my keyboard.:(simplified)
int c = 1;
while(1)
{
if(kbhit())
{
c = getch();
if(c == 27) exit(1);
if(c == 'a' || c == 'A') movepadleft();
if(c == 'd' || c == 'D') movepadright();
}
movetheball();
}
The thing that i don't like is: when i press a or d the pad moves for a short period of time, then stops and then moves constantly as long as i keep the button pressed.(it is the same thing just if i open notepad and press a letter: the letter i press apears, then there is a pause and then it prints that letter al long as i keep the button pressed).
This function(getch()) is not suitable for this problem? What alternatives i have to solve the problem?
int c = 1;
while(1)
{
if(kbhit())
{
c = getch();
if(c == 27) exit(1);
if(c == 'a' || c == 'A') movepadleft();
if(c == 'd' || c == 'D') movepadright();
}
movetheball();
}
The thing that i don't like is: when i press a or d the pad moves for a short period of time, then stops and then moves constantly as long as i keep the button pressed.(it is the same thing just if i open notepad and press a letter: the letter i press apears, then there is a pause and then it prints that letter al long as i keep the button pressed).
This function(getch()) is not suitable for this problem? What alternatives i have to solve the problem?





RE: getch() function
TTFN
RE: getch() function
RE: getch() function
RE: getch() function
TTFN
RE: getch() function
Ciao.
RE: getch() function
RE: getch() function
-10d
RE: getch() function