def _update(self, block): surf = Surface((const.res, const.res)) fill = {Tiles.Empty: (0, 0, 0), Tiles.Solid: (0, 0, 255), Tiles.Start: (0, 255, 0), Tiles.End: (255, 0, 255), Tiles.Deadly: (255, 0, 0), Tiles.EnemySpawn: (0, 255, 255)}[block.getType()] pygame.draw.rect(surf, fill, (block.relX, block.relY, block.w, block.h)) pygame.draw.rect(surf, (255, 255, 255), (block.relX, block.relY, block.w, block.h), 1) isSpawn = block.getAttr("spawnNum") if isSpawn: text = pygame.font.SysFont("arial", 25).render(str(isSpawn), 1, (0, 0, 0)) surf.blit(text, (int(surf.get_width() / 2 - text.get_width() / 2), int(surf.get_height() / 2 - text.get_height() / 2))) self._display.update(surf, Object(pos=(block.mapX * const.res, block.mapY * const.res)))
pygame.K_DOWN, [0, 0], [0, 1], lambda loc: [loc[0], loc[1] + width / 4] ] tier = 0 width = height = 32 groundLoc = windowSurface.get_height() - 63 - height playerLoc = [84, groundLoc] movements = [] dir = Direction(pygame.K_LEFT, [1, 0], [1, 1]).setWalkFunc(lambda loc: [loc[0] - width / 4, loc[1]]) dir.setMoveFunc( lambda rect: [rect[0] - width / 8, rect[3] - height / 4, rect[0] - 1, rect[3]]) dir.setMoveScreenFunc(lambda imgLoc, screenLoc: [ windowSurface.get_width() - width, imgLoc[1], screenLoc[0] - windowSurface. get_width(), screenLoc[1] ]) movements.append(dir) dir = Direction(pygame.K_RIGHT, [3, 1], [3, 0]).setWalkFunc(lambda loc: [loc[0] + width / 4, loc[1]]) dir.setMoveFunc( lambda rect: [rect[2] + 1, rect[3] - height / 4, rect[2] + width / 8, rect[3]]) dir.setMoveScreenFunc(lambda imgLoc, screenLoc: [imgLoc[0], imgLoc[1], screenLoc[0] + 32, screenLoc[1]]) movements.append(dir) # dir = Direction(pygame.K_UP, [2, 0], [2, 1]).setWalkFunc(lambda loc : [loc[0], loc[1] - width/4]) # dir.setMoveFunc(lambda rect : [rect[0], rect[1] - height/8, rect[2], rect[1] - 1])
tier = 0 width = height = 32 loc = [ windowSurface.get_rect().centerx - width / 2, windowSurface.get_rect().centery - height / 2 ] movements = [] dir = Direction(pygame.K_LEFT, [1, 0], [1, 1]).setWalkFunc(lambda loc: [loc[0] - width / 4, loc[1]]) dir.setMoveFunc( lambda rect: [rect[0] - width / 8, rect[3] - height / 4, rect[0] - 1, rect[3]]) dir.setMoveScreenFunc(lambda imgLoc, screenLoc: [ windowSurface.get_width() - width, imgLoc[1], screenLoc[0] - windowSurface. get_width(), screenLoc[1] ]) movements.append(dir) dir = Direction(pygame.K_RIGHT, [3, 1], [3, 0]).setWalkFunc(lambda loc: [loc[0] + width / 4, loc[1]]) dir.setMoveFunc( lambda rect: [rect[2] + 1, rect[3] - height / 4, rect[2] + width / 8, rect[3]]) dir.setMoveScreenFunc( lambda imgLoc, screenLoc: [0, imgLoc[1], screenLoc[0] + windowSurface.get_width(), screenLoc[1]]) movements.append(dir) dir = Direction(pygame.K_UP, [2, 0],