[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] bidimensional arrays or the quick way to maps




The dictionary approach is what I use as well. It has some nice touches, such as the ability to have non-square maps without using "this cell is illegal" filler, and the ability to work in special case cells that are outside of the standard grid coords. The resulting code tends to be more readable as well, as you can use expressions like "if cellLoc in tileMap:", rather than "x,y = cellLoc", "if tileMap[x][y] != None and 0 <= x <= WIDTH and 0 <= y <= HEIGHT".

The downside is you can't use array slicing tricks (especially the funkier NumPy ones), but in practice that doesn't seem to be something you need for Tile Maps.

-Jasper

thanks to you all, it is working beautifully ^__^



Oh yeah, one more minor point. Perhaps I'm the only one daft enough to forget about map() in the heat of the moment, but avoid naming anything "map", which Python will happily let you do! I'm still picking stinky remnants of this out of my code. :-/

-Jasper