Well if your "get player move func is like this:
Code:
void change_location ( const char modex, const char modey )
{
grid[x][y] = CLEAR;
if ( modex == '+' ) x++;
else if ( modex == '-' ) x--;
if ( modey == '+' ) y++;
else if ( modey == '-' ) y--;
grid[x][y] = FILL;
}
.
.
.
switch ( move ) {
case UP: change_location ( 0, '-' ); break;
case DOWN: change_location ( 0, '+' ); break;
case LEFT: change_location ( '-', 0 ); break;
case RIGHT: change_location ( '+', 0 ); break;
default:
perror ( "Invalid input" );
}
ten it would go like this:
Code:
for ( ; ; ) {
if ( direction == x )
change_location ( change, 0 );
else
change_location ( 0, change );
pause_for_input ( &move );
switch ( move ) {
case LEFT:
change_location ( '-', 0 );
direction = ( direction == x ) ? y : x;
break;
case RIGHT:
change_location ( '+', 0 );
direction = ( direction == x ) ? y : x;
break;
}
/* Reset change so that direction
** is incremented or decremented
** accordingly
*/
}
Thanks to Prelude for showing me this excellent method.