tags:

views:

44

answers:

1

Hi, I've been using PGU(Phil's Pygame Utilities) for a while. It has a dictionary called tdata, which is passed as an argument while loading tiles

tdata = { tileno:(agroup, hit_handler, config)}

I'm making a pacman clone in which I have 2 groups : player and ghost, for which I want to collision detection with the same type of tile.

For example, if the tile no is 2, I want this tile to have agroups as both player and ghost. I tried doing the following:

tdata = {0x02 :('player', tile_hit_1, config), 0x02 : ('ghost', tile_hit_2, config)}

However, on doing this, it only gives collision detection for ghost, not the player.

Any ideas on how I can do collision detection for both the player and the ghost with the same type of tile?

A: 

I've had a look at the source code at: http://code.google.com/p/pgu/

In vid.py (http://code.google.com/p/pgu/source/browse/trunk/pgu/vid.py) there is code for loading tdata information.

Line 300: def tga_load_tiles(self,fname,size,tdata={}):

Then on lines 324 and 325:

agroups,hit,config = tdata[n]
tile.agroups = self.string2groups(agroups)

So looking at the definiton of string2groups which begins on line 369. The agroups parameter is a string which is split on commas. So I think you can put the name of more than one group in the string.

Try:

tdata = {0x02: ('player,ghost', tile_hit, config)}

PreludeAndFugue