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

Re: [pygame] roguelike question



> Have you read PEP 8?
> 
> Your Common.Common class, which has two unrelated methods and no
> instance state, and is instantiated everywhere for a single use and then
> discarded, is not how we do things in Python land.  What's wrong with a
> simple global function?


I only discovered PEP 8 recently, so I don't have it down. And I'm not sure what you mean by "global function" I put it in a class so that I could access it in the files that needed it. Is that not correct?

> 
> Because the code:
> 
>    for tile in tiles:
>        if tile.rect.bottom == new_tile.rect.top:
>            tile = new_tile
> 
> is not doing what you think it is doing (and also, the comparison looks
> wrong).  You need something like:
> 
>    for index, tile in enumerate(tiles):
>        if tile.rect == new_tile.rect:
>            tiles[index] = new_tile
> 
> (Incidentally, a plain list of tiles is not the best data structure for
> a roguelike.)

Okay, that works. Thanks.

So, would a 2d list be better? I hard-coded the tiles for testing. I was planning on a 2d list.

> Why not use Mercurial and put the code on bitbucket.org?
> 
> Or git and github.com?
> 
> Or Bazaar and launchpad.net?

Because I didn't think of it? :)

Thanks,
~Mike