def __create_map(self): self.map = MapPanel(0, 0, self.MAP_WIDTH, self.MAP_HEIGHT + 1, self.EMPTY, border=PanelBorder.create(bottom="-")) self.panels += [self.map] self.place_objects(self.TREE, self.NUM_OF_ROCKS_START) self.place_objects(self.ROCK, self.NUM_OF_TREES_START) self.place_objects(self.SNOWMAN, self.NUM_OF_SNOWMAN_START) self.place_objects(self.COIN, self.NUM_OF_COINS_START) self.place_objects(self.HEART, self.NUM_OF_HEARTS_START) self.place_objects(self.JUMP, self.NUM_OF_JUMPS_START) # make a clearing for the player for y in range(8): for x in range(self.MAP_WIDTH): self.map[(x, self.MAP_HEIGHT - 1 - y)] = self.EMPTY # place decorative trees self.map[(self.player_pos[0] + 5, self.player_pos[1])] = self.TREE self.map[(self.player_pos[0] - 5, self.player_pos[1])] = self.TREE # place initial hearts self.map[(self.player_pos[0], self.player_pos[1] - 2)] = self.HEART self.map[(self.player_pos[0], self.player_pos[1] - 3)] = self.HEART
def init_board(self): self.map = MapPanel(0, 0, self.MAP_WIDTH, self.MAP_HEIGHT, self.EMPTY, border=PanelBorder.create(bottom=self.MAP_BOTTOM)) self.panels.append(self.map)
def init_board(self): self.map = MapPanel(0, 0, self.MAP_WIDTH, self.MAP_HEIGHT, self.EMPTY, border=PanelBorder.create(bottom="-")) self.panels += [self.map] self.map[(self.player_pos[0], self.player_pos[1])] = self.PLAYER_C self.map[(self.player_right[0], self.player_right[1])] = self.PLAYER_R self.map[(self.player_left[0], self.player_left[1])] = self.PLAYER_L self.draw_level()
def test_edges_2(): panel = Panel(0, 0, 1, 1, border=PanelBorder.create("2", "7", "5", "4", "3", "1", "8", "6")) frame = GridFrameBuffer(5, 5, init_value=" ") with pytest.raises(IndexError): panel.redraw(frame)
def init_board(self): self.map = MapPanel(1, 1, self.MAP_WIDTH, self.MAP_HEIGHT, self.EMPTY, border=PanelBorder.create(bottom=True, left=True, right=True, top=True)) self.panels += [self.map]
def test_edges(): panel = Panel(1, 1, 1, 1, border=PanelBorder.create("2", "7", "5", "4", "3", "1", "8", "6")) frame = GridFrameBuffer(5, 5, init_value=" ") panel.redraw(frame) exp = ["123 ", "4 5 ", "678 ", " ", " "] exp_frame = GridFrameBuffer.from_string_array(exp) assert frame == exp_frame
def __create_map(self): self.map = MapPanel(0, 0, self.MAP_WIDTH, self.MAP_HEIGHT + 1, self.EMPTY, border=PanelBorder.create(bottom=True, left=True, right=True, top=True)) self.panels += [self.map] self.place_bikes() for i in self.CORRUPTION: self.map[i.pos()] = i.char self.map[self.USER.pos()] = self.USER.char