예제 #1
0
    def __init__(self, map, surface, **kwargs):
        super().__init__(**kwargs)

        self._map = map
        self._tool = None
        self._brush = None
        self._painting = None

        surf = Surface((map.w, map.h))
        self._display = Display(surf, klass=surf.get_rect(), transparent=True, alpha=75)
        for tile in self._map.getMap().values():
            tile.subscribe("editor", self._update)

        self._createMenu(surface)

        self._input = Input(inputStream=self.getInputStream())
        self._input.set(pygame.KEYDOWN, self.toggleShowing, pygame.K_o)
        self._input.set(pygame.KEYDOWN, self.menu.toggleEnabled, pygame.K_t)
        self._input.set(pygame.KEYDOWN, self._map.save, pygame.K_RETURN)
예제 #2
0
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
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)