Code Duplication    Length = 21-24 lines in 2 locations

examples/samples_py.py 2 locations

@@ 779-802 (lines=24) @@
776
#############################################
777
# bsp sample
778
#############################################
779
bsp_depth = 8
780
bsp_min_room_size = 4
781
# a room fills a random part of the node or the maximum available space ?
782
bsp_random_room = False
783
# if true, there is always a wall on north & west side of a room
784
bsp_room_walls = True
785
bsp_map = None
786
# draw a vertical line
787
def vline(m, x, y1, y2):
788
    if y1 > y2:
789
        y1,y2 = y2,y1
790
    for y in range(y1,y2+1):
791
        m[x][y] = True
792
793
# draw a vertical line up until we reach an empty space
794
def vline_up(m, x, y):
795
    while y >= 0 and not m[x][y]:
796
        m[x][y] = True
797
        y -= 1
798
799
# draw a vertical line down until we reach an empty space
800
def vline_down(m, x, y):
801
    while y < SAMPLE_SCREEN_HEIGHT and not m[x][y]:
802
        m[x][y] = True
803
        y += 1
804
805
# draw a horizontal line
@@ 585-605 (lines=21) @@
582
            self.recompute = True
583
584
#############################################
585
# pathfinding sample
586
#############################################
587
588
class PathfindingSample(Sample):
589
    def __init__(self):
590
        self.name = 'Path finding'
591
592
        self.px = 20
593
        self.py = 10
594
        self.dx = 24
595
        self.dy = 1
596
        self.map = None
597
        self.path = None
598
        self.dijk_dist = 0.0
599
        self.using_astar = True
600
        self.dijk = None
601
        self.recalculate = False
602
        self.busy = 0.0
603
        self.oldchar = ' '
604
605
        self.map = libtcod.map_new(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT)
606
        for y in range(SAMPLE_SCREEN_HEIGHT):
607
            for x in range(SAMPLE_SCREEN_WIDTH):
608
                if SAMPLE_MAP[y][x] == ' ':