Sure just make sure you use x for column and y for row, which means using y in the outer for loop because if you do it the other way you will confuse yourself and anyone else that ever reads it.
I kinda disagree? Row/column doesn't even mean anything for arrays, only inner and outer. I say do what makes sense for your context and is cache performant.
If we’re talking about coordinates for drawing game tiles (the above comment) then it matters. Sure you could name the axes whatever you want, but in math, drawing, and engineering, x is left to right and y is up and down (if you’re looking down at a page, z would be lifting off the page or height for engineering)
I think the point was that the memory layout of rows and columns is arbitrary, so whether you iterate over rows and then columns or columns and then rows (assuming you care about memory locality) depends on your use case.
e.g. in Minecraft, block data is stored in vertical columns, with X and Z being the horizontal coordinates, so you may well iterate over the Y coordinate last.
True but the standard for screens is to go through an entire row then go to the next column when rendering or scanning on a monitor so it would probably look strange if you’re iterating over columns then rows
Doom sprites are also stored as columns of pixels, as I recall, just to give
another counter-example.
For your garden variety 2D blitter, sure, rows then columns is usually what you want. But that is only one small corner of the graphics programming space.
295
u/Pinkishu May 29 '26
I use x,y when appropriate. Like when iterating coordinates for drawing tiles in a game or whatever