Beispiel #1
0
 def get_pixel_height(self):
     if ui_cfg.base_style == 1:
         tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius)
         y_toff = tile_offsets[1]
         height = ((self.row_count-1) * y_toff) + 2 * self.hex_radius
         return height
     elif ui_cfg.base_style == 2:
         tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius)
         y_toff = tile_offsets[1]
         height = (y_toff * self.row_count)
         return height
Beispiel #2
0
 def get_pixel_width(self):
     if ui_cfg.base_style == 1:
         tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius)
         x_toff = tile_offsets[0]
         width = x_toff / 2 + (BASE_COLUMN_COUNT * x_toff)
         return width
     elif ui_cfg.base_style == 2:
         tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius)
         x_toff = tile_offsets[0]
         width = (BASE_COLUMN_COUNT) * x_toff
         return width
Beispiel #3
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)