I am curious as to why I need to do an operation like the below:
In order for the map to move in the correct direction. Now as you can see, pressing W and S will move the y coordinate up and down, which I expect. But A and D directions are also flipped, so instead of x starting on the left, it now starts on the right, so plusing x moves the map left instead of right.
The _map object is a TileMap which uses the function drawMapFromCsv to draw the map from a Tilesheet, like so:
Now there’s probably something in the above code causing the co-ordinate system to flip not just on the y-axis, but the x-axis as well. How could I do it so that only the y-axis is flipped?
It’s not the x axis that’s flipped, it’s the y axis.
It’s important to understand this because the x and y axes work this way in practically every game engine out there.
The reason you think it’s the x axis that’s backwards is because you’re flipping the axes again. That’s how cameras work: when the character moves in one direction, the world scrolls in the opposite direction.
This. It may seem like the same thing, but in the long run it’ll make your life a lot less confusing.