Re: ideas for grid scanning system?
What your looking for is similar to a Flood Fill Algorithm, which coincidentally i've been working on recently for a project. So here's an example in python:
def gridcheck(self, grid, start_x, start_y):
# based on an implementation by Eric S. Raymond
x = start_x y = start_y tile_id = grid[y][x] connected = [[x,y]] edge = [(x, y)] while edge: newedge = [] for (x, y) in edge: for (s, t) in ((x+1, y), (x-1, y), (x, y+1), (x, y-1)): try: p = grid[t][s] except IndexError: pass else: if p == tile_id: connected.append([s,t]) newedge.append((s, t)) edge = newedge return connected
This function takes the Grid and the starting x and y positions, then should return a list containing the coordinates of all tiles that match the starting tile, if any.
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector