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)))
enemies = tools.getImage("sprites") detailHeight = int(map.get_height() / 8 / 4) # windowSurface = pygame.display.set_mode((int(map.get_width() / 16), int(map.get_height() / 8)), 0, 32) pygame.display.set_caption('Totally not Zelda') BLACK = (0, 0, 0) BG_COLOR = (252, 216, 168) UP = [pygame.K_UP, [2, 0], [2, 1], lambda loc: [loc[0], loc[1] - width / 4]] DOWN = [ 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: [0, imgLoc[1], screenLoc[0] + windowSurface.get_width(), 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]) dir.setMoveScreenFunc(lambda imgLoc, screenLoc: [ imgLoc[0], windowSurface.get_height() - height, screenLoc[0], screenLoc[1] - windowSurface.get_height() ]) movements.append(dir) dir = Direction(pygame.K_DOWN, [0, 0], [0, 1]).setWalkFunc(lambda loc: [loc[0], loc[1] + width / 4]) dir.setMoveFunc( lambda rect: [rect[0], rect[3] + 1, rect[2], rect[3] + height / 8]) dir.setMoveScreenFunc( lambda imgLoc, screenLoc: [imgLoc[0], 0, screenLoc[0], screenLoc[1] + windowSurface.get_height()]) movements.append(dir) FACE = movements[0].getImage()