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 level array, it deletes the rest of the array.
The only movement in the code right now is moving right (type 2 in the console to move right)
#include <iostream>
using namespace std;
#define con std::cout <<
#define newline std::cout << '\n'
#define text std::cin >>
#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[] = {"   ", "[ ]", "[X]"};
int render () {
    x = 1;
    y = 1;
    while (x < 37) {
        z = level[x - 1];
        con display[z];
        x = x + 1;
        y = y + 1;
        if (y == 7) {
            y = 1;
            newline;
        }
    }
    end;
}
int player () {
    con "Please make your next move : w: 1, a: 2, s: 3, d: 4";
    newline;
    con "Current position: " << 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;
}
I'm using this website for coding currently: https://www.programiz.com/cpp-programming/online-compiler/
This is the output:
[ ][ ][ ][ ][ ][ ]
[ ]            [ ]
[ ]   [X]      [ ]
[ ]            [ ]
[ ]            [ ]
[ ][ ][ ][ ][ ][ ]
Please make your next move : w: 1, a: 2, s: 3, d: 4
Current position: 15
2
[ ][ ][ ][ ][ ][ ]
[ ]            [ ]
[ ]   
And then it cuts off rendering the level.
I'm confused. What am I doing wrong?
 
     
    