I'm currently using an array to store position data for a text based game I'm creating.
I'm trying to edit each string in the array accordingly, for example, if my array was ['___','_1_','___']
with 1
being the character and _
being a blank space; also keeping my character position in another array ([1,1]
); if I were to try and move the character up 1 and replace his position with a hash (#
) it wouldn't work. I can edit the position array just fine but nothing else.
map[pos[1] - 1][pos[0]] = '1';
map[pos[1]][pos[0]] = '#';
pos[1] = pos[1] - 1;
That is what I'm using right now however only the third line actually works. If I ran this once, the map array would still be ['___','_1_','___']
but my position array would change to [1,0]
.
What is the best way to change the map value to fit my needs?