I'm having trouble understanding what a specific syntax accomplishes in a piece of code. I understand what the code accomplishes overall, I'm just trying to understand exactly how it works so it's no longer just "magic".
The line I'm having trouble with is the last line, however I do understand what is happening before the = operator. The part I'm having difficulty understanding is what is occurring after the operand. More specifically this part:
L" ABCDEFG=#"[pField[y*fieldWidth + x]];
The code at a high level is meant to iterate through a 2D array, then convert it into a 1D array, checking each piece for the int value it holds, then drawing a specific symbol to that place in the array, later to be displayed in the terminal.
Not sure if this is important, but you may want the context. The array pField, is an array which holds the boarder to the actual game, it contains a 9 if the piece of the array represents a boarder, and a 0 otherwise. There is actually already a stack overflow related to the pField array, ill leave it here I'm having trouble understanding the syntax used in a piece of code
My question is, I understand what the code does at a high level, but I don't understand the syntax used to get it do what it is meant to do, L" ABCDEFG=#"[pField[y*fieldWidth + x]];
is the piece of syntax where I really just am not sure what I'm looking at, or even what this is called.
Here is the full loop and logic structure:
wchar_t *screen = new wchar_t[nScreenWidth*nScreenHeight];
for (int x = 0; x < fieldWidth; x++)
for (int y = 0; y < fieldHeight; y++)
screen[(y + 2)*nScreenWidth + (x + 35)] = L" ABCDEFG=#"[pField[y*fieldWidth + x]];