On Mon, Oct 04, 2010 at 01:05:36PM -0500, Michael Schultz wrote: > Hi, new to the list, but not the language. I'm completely at home with > Python :) 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? > Right now, I'm coding a roguelike game, and am having > trouble getting the map to update changes. I've got movement and > collision detection, but for whatever reason, the changes to the map > are not being updated. > > When the player is up against a "d" tile, and presses the key "d", the > "d" should be replaced with a "." tile, but nothing's happening. 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.) > Here's the files: > > ===move_test.py > http://pastebin.com/fmz491K9 > > ===Actions.py > http://pastebin.com/TUm3mv3b > > ===Terrain.py > http://pastebin.com/SXR8LqyL > > ===Common.py > http://pastebin.com/YhN2Cszu > > ===Imp.py > http://pastebin.com/2g4Yz469 Why not use Mercurial and put the code on bitbucket.org? Or git and github.com? Or Bazaar and launchpad.net? Marius Gedminas -- The primary purpose of the DATA statement is to give names to constants; instead of referring to PI as 3.141592653589797, at every appearance, the variable PI can be given that value with a DATA statement, and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of PI change. -- Fortran manual for Xerox computers
Attachment:
signature.asc
Description: Digital signature