It's the
difference between the place of origin (the cell), and the place you want to be (Third row, second column).
The difference between the second column and the first column is one column (2 - 1 = 1), so you need to move one column.
The difference between the third row and the first row is two rows (3 - 1 = 2), so you need to move two rows.
The reason we start counting at zero alot of times in programming, is because we are always
at some location in memory, wanting to
move to another location in memory. If the place where we are
at is also the place we want to be, then we just move "zero" places. Once you understand this, so you know
why it makes sense, then you can just keep that information in the back of your head, and take the much much easier mental shortcut of saying, "We start counting at zero", and cut out the "we're
here, we want to be
there, the difference is
thus.", because the end result always just to subtract one from the "
there" location anyway. We work with
relative positions, not absolute positions, so our "
here" is
always 1, so we can just shortcut by always subtracting 1 from our "
there".
We always work with relative positions instead of absolute positions because we never can be sure about what actual physical location of memory we're at. Our memory address might be 0x45FF34A4 at one run, or 0x33C63A3D the next run - but it doesn't matter, because we know we have a tileset at [
whatever location in memory], and whatever that location is, it doesn't effect us, because we know that 4 steps beyond that location is the specific tile we want. So, (absolute location of memory) + 4 steps = Our tile.
Instead of complicating math unnecessarily and saying "0x45FF34A4 + 4", we move the problem domain to be relative to zero (for ease of mental problem solving), and say, "0 + 4", and then add 0x45FF34A4 to the final result. (Note that '4' is moving '4' steps to get to the 5th tile, because the first tile is located at location 0x45FF34A4 itself, but since we moved the problem domain to be relative to zero, then the first tile is located at position zero. Unnecessarily large numbers that are our location in memory can be shortcutted out of our math since it's irrelevant to our final result.
That was really confusing. If I'm doing a crappy job of explaining this, just let me know. If someone more skilled in explanations is reading this, you are most welcome to step in any time you want to undo any damage I may be causing!
If you are just born, you are in your first year of life. You aren't 1 year old (1 year old = you are in your second year of life).
If I'm 5 years old, that means I've already
moved 5 years from my place of origin (my birth at zero years old). It means I am now in my sixth year of life.
If it is 12:05 am, you are 5 minutes into the first hour of the day. The first hour is hour 'zero', it hasn't yet reached hour '1' which is the second hour of the day.
Taking the age thing further: If I was born in 2010, nobody stops and thinks that "Your age is now at time-location 2012 minus 2". They say, "You are now 2". Everyone understands that my birth was in 2010, so my "2" is relative to 2010. Even though I was born in 2010, that year doesn't tell anyone information that they want, but my age
relative to that year is what is important.
It doesn't matter that the tileset starts at memory location 0x45FF34A4 in a piece of RAM somewhere. But the location of the tile in the tileset
relative to the origin is the information we want. If we want the tile, we can just eliminate the '0x45FF34A4 ' information entirely, and work from a problem domain of 'zero' (memory location 0x00).