reversing coordinates in an array variable C++

  arrays, c++, variables

I am not exactly sure how to phrase this question, sorry for the unhelpful title.

I have a large array (5 columns, 50 rows) that I am using to draw out a level environment in ascii text (each entry in the array is a single character and they are all printed out to make an image)
i.e:

  char worldarr[5][9] = 
{
        {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'}, //the length of these entries are actually
        {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'}, //50 but I shortened them for the post
        {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'},
        {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'},
        {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'},
}

where the output is:

XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX

Now I am trying to set up a coordinate system, where (0,0) is the bottom left hand corner, the goal is to be able to put in a coordinate and have that location replaced with an ‘@’ my original assumption was that I could use this:

int x = 0, y = 0;
worldarr[y][x] = '@'; 

but this outputs:

@XXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX

not:

XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
@XXXXXXXX

how could I make a new system to force (0,0) to be at the bottom, or better yet, the exact center of the array (if possible).

sorry again for the terrible conciseness, I am not sure what I am working with.

Source: Windows Questions C++

LEAVE A COMMENT