I was following episode 32 this morning. I typed all the changes Casey has made to the coordinates system, checking the game state after every second compilation. At some point my avatar stopped moving between the rooms but I didn't think too much about it: Casey changed so many things, surely something must be broken at this point. At the end of the coding session, however, Casey's code worked flawlessly, unlike mine. WTF?!
An hour later, I knew what was my mistake.
In RecanonicalizeCoord() function Casey used following two lines for changing the TileMap index:
but because I prefer the postfix notation, I casually typed:
Turns out this syntax increments only the pointer itself, not the referenced value, as was intended. If, like me, you would like to use postfix notation, here's the proper syntax:
They say that every bug is an opportunity to learn something new. I lost an hour but I'm a better programmer now. Totally worth it!