Beispiel #1
0
int getch ()
{
	int c, s;

	while ((c = getcha ()) == ' ' || c=='\t');
	s = c;
	while (c != '\n')
		c = getcha ();
	return (s);
}
Beispiel #2
0
void main( void ){
  int inKey;
  struct curCoor map;
  map.X = BOARD_WIDTH/2;
  map.Y = BOARD_HEIGHT/2;
  

  initscr();

  while(1){    
    inKey = getcha();
    if ( inKey == 0x1b) { 
      inKey = getcha();
      if (inKey == 0x5b){ 
	inKey = getcha();
      }
    } else { 
	if (inKey == 'c'){
	  erase();
	}

    }
    
   // Up-Arrow 
    if ( inKey == 0x41 ){
      if (map.Y > 0 ){
        map.Y -= 1;
      } else {
        continue;
      }
    }

   // Down-Arrow
    if ( inKey == 0x42 ){
      if (map.Y < (BOARD_HEIGHT-1) ){
        map.Y += 1;
      } else {
        continue;
      }
    }

   // Right-Arrow 
    if ( inKey == 0x43 ){
      if (map.X < (BOARD_WIDTH-1) ){
        map.X += 1;
      } else {
        continue;
      }
    }

   // Left-Arrow 
    if ( inKey == 0x44 ){
      if (map.X > 0 ){
        map.X -= 1;
      } else {
        continue;
      }
    }
  etchBoard[map.Y][map.X] = 1;

  mvaddch(map.Y, map.X, '1');

  refresh();

  }



}