-
On-Key changes
I need my game to move the guy up on up arrow, odwn on down arrow, etc, but i cant do it. i was think somewhere along the lines of this?
Code:
if(_kbhit() == (char)75)
{
posone -= 1;
}
else if(_kbhit() == (char)77)
{
posone += 1;
}
else if(_kbhit() == (char)72)
{
postwo -= 1;
}
else if(_kbhit() == (char)80)
{
postwo += 1;
}
of course its wrong but any help would be appreciated.
P.S. posone is left(negative) right(positive) and postwo is up(negative) down(positive) on the game map.(stored in a 2d array, map[posone][postwo], get it? ;))
-
Code:
char keyPress;
keyPress = getc();
switch(keyPress)
{
case 75 : /*blah blah blah*/;break;
case 77 : /*blah blah blah*/;break;
case 72 : /*blah blah blah*/;break;
case 80 : /*blah blah blah*/;break;
default : break;
}
-