def run_codes(self,cdata,rect):
"""Run codes.
Arguments:
cdata -- a dict of code:(handler function, value)
rect -- a tile rect of the parts of the layer that should have
their codes run
"""
tw,th = self.tiles[0].image.get_width(),self.tiles[0].image.get_height()
x1,y1,w,h = rect
clayer = self.clayer
t = Tile()
for y in range(y1,y1+h):
for x in range(x1,x1+w):
n = clayer[y][x]
if n in cdata:
fnc,value = cdata[n]
t.tx,t.ty = x,y
t.rect = pygame.Rect(x*tw,y*th,tw,th)
fnc(self,t,value)
评论列表
文章目录