title: I'm having trouble with changing parts of an array
body: <p>I'm currently working on a small game to play in the console. I'm trying to make player movement, but when I try to replace a certain element within the <code>level</code> array, it deletes the rest of the array.</p>
  <p>The only movement in the code right now is moving right (type <code>2</code> in the console to move right)</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  using namespace std;
  
  #define con std::cout &lt;&lt;
  #define newline std::cout &lt;&lt; '\n'
  #define text std::cin &gt;&gt;
  #define end return 0
  #define repeat while (true)
  
  int width, height;
  int rprog;
  int x, y, z;
  int playerpos;
  int input;
  double level[] = 
     {1, 1, 1, 1, 1, 1,
      1, 0, 0, 0, 0, 1,
      1, 0, 2, 0, 0, 1,
      1, 0, 0, 0, 0, 1,
      1, 0, 0, 0, 0, 1,
      1, 1, 1, 1, 1, 1};
  
  const char *display[] = {&quot;   &quot;, &quot;[ ]&quot;, &quot;[X]&quot;};
  
  int render () {
      x = 1;
      y = 1;
      while (x &lt; 37) {
          z = level[x - 1];
          con display[z];
          x = x + 1;
          y = y + 1;
          if (y == 7) {
              y = 1;
              newline;
          }
      }
      end;
  }
  
  int player () {
      con &quot;Please make your next move : w: 1, a: 2, s: 3, d: 4&quot;;
      newline;
      con &quot;Current position: &quot; &lt;&lt; playerpos;
      newline;
      text input;
      if (input == 2) {
          level[playerpos] = 0;
          playerpos = playerpos - 1;
          level[playerpos] = 3;
      }
      end;
  }
  
  int main() {
      playerpos = 15;
      while (true) {
          render ();
          player ();
      }
      end;
  }
  </code></pre>
  <p>I'm using this website for coding currently: <a href="https://www.programiz.com/cpp-programming/online-compiler/" rel="nofollow noreferrer">https://www.programiz.com/cpp-programming/online-compiler/</a></p>
  <p>This is the output:</p>
  <pre class="lang-none prettyprint-override"><code>[ ][ ][ ][ ][ ][ ]
  [ ]            [ ]
  [ ]   [X]      [ ]
  [ ]            [ ]
  [ ]            [ ]
  [ ][ ][ ][ ][ ][ ]
  Please make your next move : w: 1, a: 2, s: 3, d: 4
  Current position: 15
  2
  [ ][ ][ ][ ][ ][ ]
  [ ]            [ ]
  [ ]   
  </code></pre>
  <p>And then it cuts off rendering the level.</p>
  <p>I'm confused. What am I doing wrong?</p>