I'm having problem with using a gotoxy function to move the cursor around the screen (as part of game controls).
Code:
#define GET getche()
done = FALSE;
while(!done)
{
i = GET;
if (i == UPKEY)
{
gotoxy(x, y--);
}
if (i == DOWNKEY)
{
gotoxy(x, y++);
}
if (i == LEFTKEY)
{
gotoxy(x--, y);
}
if (i == RIGHTKEY)
{
gotoxy(x++, y);
}
I'm currently using getche() as I wanted to see if the console was picking up the correct input and it is. The problem is that when I hit a direction key, I get a delay in moving in the proper direction. The cursor will go one extra step before it changes. This is easier to explain using a screenshot and getche()
http://img291.imageshack.us/img291/9655/consolepr2.jpg
My brain is telling me that this will be caused by the incrementing/decrementing method I'm using with gotoxy, but the assignment says we HAVE to use gotoxy as the controls and I can't think of a better way to do it.
Thanks for any help