clear-code-projects / Zelda

Files for the Zelda in python tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix: .png files are placed out of order when calling the walk() method

joewab opened this issue · comments

I was having trouble rendering the map correctly because the graphics from the objects folder were being listed out of order when using the walk() method. I'm not sure if the Tile program somehow inserts index numbers into the png files, but the file names were not enough to impose any kind of ordering in and of themselves. So, for example, when the objects map called for 14 to be rendered, it instead rendered 10.png since the list that was created was not in any numerical order. (although it didn't seem random, it was always in the exact same incorrect order). Anyway there's an easy fix with the sorted() method:

Screen Shot 2024-03-18 at 8 22 09 PM

I struggled trying to figure out why this was happening for a long time. I hope this helps somebody. I would have submitted a PR but I'm not sure how that would be done with this repo that is just zip files...