Ok so I have a game setup that allows the 8 to move around inside a small room. It works fine except that every keypress lags one "frame" behind. So whenever a key is pressed it does the last keypress that was given. How do I make it react immediately to a keypress? I'm using conio for the keyboard input.
while((ch=getch())!=27)
{
sirx = Sir->xC();
siry = Sir->yC();
world[sirx][siry]=2;
system("cls");
a=0;
b=0;
if(ch==72)
if(world[sirx][siry-1]==0)
{
Sir->Pmove(0);
}
if(ch==77)
if(world[sirx+1][siry]==0)
{
Sir->Pmove(1);
}
if(ch==80)
if(world[sirx][siry+1]==0)
{
Sir->Pmove(2);
}
if(ch==75)
if(world[sirx-1][siry]==0)
{
Sir->Pmove(3);
}
while(b<16)
{
while(a<16)
{
if(world[a][b]==1)
cout<<"#";
if(world[a][b]==0)
cout<<" ";
if(world[a][b]==2)
cout<<"8";
a++;
}
cout<<endl;
a=0;
b++;
}
world[sirx][siry]=0;
cout<<sirx<<","<<siry;
}
return 0;
}