title: How do I make something happen on the screen even without a key being pressed?
body: <p>I am making Pacman in C++ with the Ncurses library. I am able to move Pacman with my code, but I want to move it so that pacman keeps moving even when I am not pressing any key and when I press another direction key, it changes direction. Right now, the pacman only takes one step when I press a key. Also I have to press a key 2 or 3 times before pacman moves in that direction.</p>
  
  <pre><code>if (ch==KEY_LEFT)
  {
      int b,row,column;
      getyx(stdscr,row,column);
      int h; 
      do    // do-whileloop to move the pacman left until it hits the wall
      {
          column-=1;
          mvprintw(row,column,"&gt;");  //print the "&gt;" symbol
          refresh();
          waitf(0.1);      //this pauses the game for 0.1sec
          attron(COLOR_PAIR(1));      
          mvprintw(row,column,"&gt;");
          attroff(COLOR_PAIR(1));
          refresh();
          waitf(0.1);
          mvprintw(row,(b),"O");  //showing the open mouth of pacman
          refresh();
          waitf(0.1);
          attron(COLOR_PAIR(1));a
          mvprintw(row,column,"O");
          attroff(COLOR_PAIR(1));
          h = getch();
      }
      while(h == KEY_LEFT);
  }
  
  right = getch();
  </code></pre>
  
  <p>loop to move right in an if condition</p>
  
  <pre><code>up = getch();
  </code></pre>
  
  <p>loop to move up in an if condition</p>
  
  <pre><code>down = getch();
  </code></pre>
  
  <p>oop for moving down in an if condition.</p>