title: Player don't move if he shoot a bullet, c++ ncurses
body: <p>I need to implement the shooting mechanics, but everytime that I shoot, the player movement freez.
  I made a class for the shooting and I try to update the player movement everytime that the bullet moves; but it doesn't work. How can I fix that? I think that I need to change the code in the for.
  This is the main code:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &quot;Personaggio.hpp&quot;
  
  bool gameover = false;
  
  int main (){
      initscr();
      noecho();
      raw();
      cbreak();
  
      WINDOW * win = newwin (24, 80, 0, 0);
      refresh();
      box (win, 0, 0);
      wrefresh(win);
      keypad(win, TRUE);
  
  
      personaggio player(22, 24, '&amp;', win);
  
      while (!gameover){
          wtimeout(win, 80);
          int movement = wgetch(win);
  
          if (movement==KEY_UP||movement==KEY_DOWN||movement==KEY_LEFT||movement==KEY_RIGHT){
              shoot *bullet = new shoot(player.cy(), player.cx(), '*', win);
              bullet-&gt;shooting(movement, player);
  
              delete bullet;
          }
          else {
              player.del();
              player.moving(movement);
  
              player.draw();
          }
      }
      endwin();
      return 0;
  }
  </code></pre>
  <p>This is the player class:</p>
  <pre><code>#include &lt;ncurses.h&gt;
  
  class personaggio {
  protected:
      int currX, currY;
      int xMax, yMax;
      char character;
      WINDOW *window;
  public:
      personaggio(int y, int x, char c, WINDOW *win) {
          window = win;
          getmaxyx(window, yMax, xMax);
          currX = x;
          currY = y;
          character= c;
      }
  
      void up() {
          mvwaddch(window, currY, currX, ' ');
          currY--;
          if (mvwinch(window, currY, currX) != 32 ||currY == 0) {
              currY++;
              refresh();
          }
      }
  
      void down() {
          mvwaddch(window, currY, currX, ' ');
          currY++;
          if (mvwinch(window, currY, currX) != 32 || currY == 23) {
              currY--;
              refresh();
          }
      }
  
      void right() {
          mvwaddch(window, currY, currX, ' ');
          currX++;
          if (mvwinch(window, currY, currX) != 32 || currX == 79) {
              currX--;
              refresh();
          }
      }
  
      void left() {
          mvwaddch(window, currY, currX, ' ');
          currX--;
          if (mvwinch(window, currY, currX) != 32 || currX == 0) {
              currX++;
              refresh();
          }
      }
  
      int moving(int movement) {
          switch (movement) {
              case 'w':
                  up();
                  break;
              case 's':
                  down();
                  break;
              case 'd':
                  right();
                  break;
              case 'a':
                  left();
                  break;
          }
          return movement;
      }
  
  
      void draw() {
          mvwaddch(window, currY, currX, character);
      }
  
      void del() {
          mvwaddch(window, currY, currX, ' ');
          wrefresh(window);
      }
  
      int cy() {
          return currY;
      }
  
      int cx() {
          return currX;
      }
  
  };
  </code></pre>
  <p>This is the function inside the shooting class:</p>
  <pre><code>class shoot: public personaggio {
  public:
      shoot(int y, int x, char c, WINDOW *window) : personaggio(y, x, c, window) {}
  
      int shooting(int movement, personaggio player) {
          switch (movement) {
              case KEY_UP:
                  shootup(movement, player);
                  break;
           /*   case KEY_DOWN:       //for now I am working only with KEY_UP
                  shootdown();
                  break;
              case KEY_RIGHT:
                  shootrg();
                  break;
              case KEY_LEFT:
                  shootlf();
                  break;*/
              default:
                  break;
          }
          return movement;
      }
  
  
      void shootup(int movement, personaggio player) {
          int tmp = currY;
          if (tmp != 1) {
              for (int i = 0; i &lt; 5; i++) {
                  tmp--;
                  player.moving(movement);
                  player.draw();
                  wrefresh(window);
                  if (mvwinch(window, tmp, currX) == 32) {
                      if (i != 4) {
                          draw(tmp);
  
                          napms(80);
                          del (tmp);
                      } else {
                          mvwaddch(window, tmp, currX, character);
                          wrefresh(window);
  
                          napms(80);
                          del(tmp);
                      }
                  } else {
                      tmp++;
                      if (tmp != currY) {
                          mvwaddch(window, tmp, currX, '&quot;');
                          wrefresh(window);
                          napms(100);
  
                          del(tmp);
                      }
                      i = 5;
                  }
                  player.del();
                  wrefresh(window);
              }
          }
          move(currY, currX);
      }
  
      void del(int tmp){
          mvwaddch(window, tmp, currX, ' ');
          wrefresh(window);
      }
  
      void draw(int tmp) {
          mvwaddch(window, tmp, currX, ACS_BULLET);
          wrefresh(window);
      }
  };
  </code></pre>