code-dot-org/blockly — pull request #520 by Bjvanminnen (2014-04-23 23:13:58+00:00)
Title: refactor getPegmanYCoordinate slightly

I was having a hard time understanding exactly what getPegmanYCoordinate was doing, so I spent some time figuring it out, and then refactored it to make it (I think) more understandable.

The common case is that we just want the y coordinate on screen for a given maze row. This is now get PegmanYForRow.

The other case is that we're choosing an animation from a sprite sheet, and need to adjust the y coordinate accordingly. For this we use getPegmanFrameOffsetY.

In addition, I found that createPegmanAnimation was never being called with options.rowIdx, so I got rid of that.

I validated the change running gruntTest, and also by running through affected scenarios and asserting that the y value I generate at line 644(right) is the same as the one that was generated with the original approach.