Beispiel #1
0
    def _get_relative_center_pixel_for_visual_position(self, pos):
        x = pos[0]
        y = pos[1]

        offsets = BoardTools.get_hex_vertex_offsets(self.hex_radius)
        xoffset = offsets[0]
        yoffset = offsets[1]

        shifts = BoardTools.get_hex_tile_offsets(self.hex_radius)
        xshift = shifts[0]
        yshift = shifts[1]

        oddOffset = 0
        if y % 2 == 1:
            oddOffset = xoffset

        x_pixel = xoffset + oddOffset + (x * xshift)
        y_pixel = self.hex_radius + (y * yshift)
        return (x_pixel, y_pixel)
Beispiel #2
0
    def _get_relative_center_pixel_for_slot(self, slot):
        column = slot[0]
        row = slot[1]

        if ui_cfg.base_style == 1:
            vertex_offsets = BoardTools.get_hex_vertex_offsets(self.hex_radius)
            x_voff = vertex_offsets[0]
            y_voff = vertex_offsets[1]
        
            tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius)
            x_toff = tile_offsets[0]
            y_toff = tile_offsets[1]

            oddOffset = 0
            #odd rows are shifted by a half tile 
            if row % 2 == 1:
                oddOffset = x_toff / 2

            x_pixel = (x_toff / 2) + oddOffset + (column * x_toff)
            y_pixel = self.hex_radius + (row * y_toff)
            y_pixel = self.get_pixel_height() - y_pixel

            if (self.direction == TKPlayerBase.RIGHT):
                x_pixel = self.get_pixel_width() - x_pixel

            return (x_pixel, y_pixel)

        elif ui_cfg.base_style == 2:
            tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius)
            x_toff = tile_offsets[0]
            y_toff = tile_offsets[1]

            x_pixel = (x_toff / 2) + (column * x_toff)
            y_pixel = (y_toff / 2) + row * y_toff
            y_pixel = self.get_pixel_height() - y_pixel
            return (x_pixel, y_pixel)