Python Python Collections (2016, retired 2019) Dungeon Game Cartographer

Shane Smith
Shane Smith
2,726 Points

Can't get this grid to draw properly

The grid is supposed to be drawn in a 5 x 5 arrangement, however mine is just a row of 25 boxes any ideas what im doing wrong?

Aaron van Leijenhorst
Aaron van Leijenhorst
10,913 Points

I had the same issue. My problem was that I had a wrong if statement. (Note: I have a width of 5 instead of 4 in Kenneth's example)

I had:

if x < 6:
    line_end=""
    #blabla more here
else:
    line_end="\n"
    #blabla more here

But the coordinates are zero based. So x < 6 is always the case cause the highest it will ever go is 5. This means that the new line character is never added so everything turns into one solid line of tiles.

So if I change it to:

if x < 5:
    line_end=""
    #blabla more here
else:
    line_end="\n"
    #blabla more here

My row turns into a 5x5 grid.