0 index strikes again by Whitaker


Hello again, and welcome back to another adventure of me spending hours making simple mistakes. As we all know, or should know, code loves to start counting at zero! arrays start at zero, lists start at zero, even out player controllers start at zero! Needless to say, I thought we had set up our paths to start at zero. The biggest issue was that the paths are not actually an array, so I would not even get errors when I was looking for path "0." 

This all came about as I was making a new event tile that would transport the player to a random location on the board. However, the player would get sent to one location visually, however, they would receive the gems of another tile type. Then, come next round, they would be at the "correct" location. None of it was adding up!

Turns out I was looking for paths 0-4 instead of paths 1-5, but I was setting the location visually of paths 1-5. This was the core issue in my mix up of location and Tile checking logic. Upon correcting my logic to only get a random int between 1-5 instead I was able to visually put the player at the same location the code thought it was at. Such a simple issue to cause so many problems.

Get Party Panic!

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.