def __init__(self, **kwargs): super(TileMap, self).__init__(**kwargs) # init ScatterPlane with above parameters # How many tiles to make? 32x64? tileradius = 8 loaded_tiles = board.load_board() self.tiles = [] for y_tile in xrange(64): row = [] self.tiles.append(row) for x_tile in xrange(32): hexagon = Hexagon( loaded_tiles[y_tile][x_tile], pos=( (x_tile + 1) * 3 * tileradius + (y_tile % 2) * (1.5 * tileradius), (y_tile + 1) * 0.5 * sqrt(3) * tileradius, ), size_hint=(1.0 / 64, 1.0 / 64), ) self.add_widget(hexagon) hexagon.tileradius = tileradius hexagon.height = tileradius * sqrt(3) row.append(hexagon)
def __init__(self, **kwargs): super(TileMap, self).__init__(**kwargs) # init ScatterPlane with above parameters # How many tiles to make? 32x64? tileradius = 10 basis_x = cos(-30 * pi / 180.0) * tileradius basis_y = sin(-30 * pi / 180.0) * tileradius loaded_tiles = board.load_board() origin_x = 400 origin_y = 500 self.tiles = [] for y_tile in xrange(BOARD_HEIGHT): row = [] self.tiles.append(row) for x_tile in xrange(BOARD_WIDTH): hexagon = Hexagon( loaded_tiles[y_tile][x_tile], # Transform to hexagonal coordinates. pos=(origin_x + x_tile * basis_x + y_tile * (-basis_x), # y-basis goes in mirror direction origin_y + x_tile * basis_y + y_tile * basis_y), #pos=((x_tile + y_tile, # (y_tile+1) * 0.5 * sqrt(3) * tileradius), size_hint=(1.0/64, 1.0/64)) self.add_widget(hexagon) hexagon.tileradius = tileradius hexagon.height=(tileradius*sqrt(3)) row.append(hexagon)
def execute(board, moves): colors = {'r': 'red', 'g': 'grn', 'b': 'blu'} directions = {'w': 'up', 'a': 'left', 's': 'down', 'd': 'right'} board, teleports, endpoint = load_board(board, padding=0) for snake, direction in zip(moves[0::2], moves[1::2]): board, teleports, endpoint = move_board_state(board, teleports, endpoint, colors[snake], directions[direction]) return draw_board(board, teleports, endpoint, color=False, fancy=False).strip()
def __init__(self, **kwargs): super(TileMap, self).__init__(**kwargs) # init ScatterPlane with above parameters # How many tiles to make? 32x64? tileradius = 8 loaded_tiles = board.load_board() self.tiles = [] for y_tile in xrange(64): row = [] self.tiles.append(row) for x_tile in xrange(32): hexagon = Hexagon( loaded_tiles[y_tile][x_tile], pos=((x_tile+1) * 3 * tileradius + (y_tile % 2) * (1.5 * tileradius), (y_tile+1) * 0.5 * sqrt(3) * tileradius), size_hint=(1.0/64, 1.0/64)) self.add_widget(hexagon) hexagon.tileradius = tileradius hexagon.height=(tileradius*sqrt(3)) row.append(hexagon)