On Thursday 20 August 2009, Richard Jones wrote: > On 18/07/2009, at 2:13 AM, Chris Laux wrote: > > I've been playing with Cocos' tile module a bit lately, and I think > > I found a > > bug in RectMapLayer.get_in_region. I'm using it with a manually > > created map > > (not using the xml map loader) for basic collision detection. > > Without this > > change, I would get more cells than I should and would hit walls 1 > > cell early > > on the bottom and left. AFAICT, it isn't affecting test_tiles.py one > > way or > > the other. Are there any other tests out there to verify this bug/fix? > > Thanks for this, I've committed the fix and added a test for it (along > with a ton of others and a bunch of new cocos.tiles functionality like > collision detection stuff) > >
Sweet, but the test (test_tiles_model.py) doesn't run afaict - it can't import Rect. I tried hacking it up a bit, but no luck. Attached are some functions I wrote to make maps out of simple text files, I don't know if they're suitable for inclusion in cocos. I'm using them as a quick & dirty way to make simple maps. -- -chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cocos-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
from cocos import tiles def text_map_tile_reader(file, tile_width, tile_height, chars_to_tiles): mapdata_lines = open(file).readlines() mapdata_lines.reverse() mapdata_cells = [[] for i in range(len(mapdata_lines[0]) - 1)] x, y = 0, 0 for line in mapdata_lines: line = line[:-1] # get rid of \n for char in line: if char in chars_to_tiles: tile = chars_to_tiles[char] else: tile = chars_to_tiles[None] mapdata_cells[x].append(tiles.RectCell(x, y, tile_width, tile_height, dict(), tile)) x += 1 y += 1 x = 0 return mapdata_cells def text_map_sprite_reader(file, tile_width, tile_height, chars_to_sprites): mapdata_lines = open(file).readlines() mapdata_lines.reverse() x, y = 0, 0 sprites = [] for line in mapdata_lines: line = line[:-1] # get rid of \n for char in line: if char in chars_to_sprites: s = chars_to_sprites[char]() s.x, s.y = x, y sprites.append(s) x += tile_width y += tile_height x = 0 return sprites
