Exemplo n.º 1
0
def PoleGen(hm, NS):

    if NS == 0:
        rng = randint(2, 5)
        for i in range(WORLD_WIDTH):
            for j in range(rng):
                tcod.heightmap_set_value(hm, i, WORLD_HEIGHT - 1 - j, 0.31)
            rng += randint(1, 3) - 2
            if rng > 6:
                rng = 5
            if rng < 2:
                rng = 2

    if NS == 1:
        rng = randint(2, 5)
        for i in range(WORLD_WIDTH):
            for j in range(rng):
                tcod.heightmap_set_value(hm, i, j, 0.31)
            rng += randint(1, 3) - 2
            if rng > 6:
                rng = 5
            if rng < 2:
                rng = 2

    return
Exemplo n.º 2
0
    def __init__(self, width, height):
        self.width = width
        self.height = height
        self.console = tcod.console_new(self.width, self.height)
        self.elevation = tcod.heightmap_new(self.width, self.height)
        self.map = tcod.map_new(self.width, self.height)
        
        # put some interesting values into elevation
        noise = tcod.noise_new(2,tcod.NOISE_DEFAULT_HURST, tcod.NOISE_DEFAULT_LACUNARITY, 0)
        for x in range (0, self.width):
            for y in range (0, self.height):
                k = 3.4
                value = tcod.noise_get(noise,[x/k,y/k], tcod.NOISE_PERLIN)
                tcod.heightmap_set_value(self.elevation, x, y, value)
        tcod.noise_delete(noise)

        self.update()
Exemplo n.º 3
0
def pole_generator(heightmap, ns: int):

    if ns == 0:
        rng = randint(2, 5)
        for i in range(WORLD_WIDTH):
            for j in range(rng):
                tcod.heightmap_set_value(heightmap, i, WORLD_HEIGHT - 1 - j,
                                         0.31)
            rng += randint(1, 3) - 2
            rng = min(max(2, rng), 5)

    if ns == 1:
        rng = randint(2, 5)
        for i in range(WORLD_WIDTH):
            for j in range(rng):
                tcod.heightmap_set_value(heightmap, i, j, 0.31)
            rng += randint(1, 3) - 2
            rng = min(max(2, rng), 5)
Exemplo n.º 4
0
def test_heightmap():
    hmap = libtcodpy.heightmap_new(16, 16)
    repr(hmap)
    noise = libtcodpy.noise_new(2)

    # basic operations
    libtcodpy.heightmap_set_value(hmap, 0, 0, 1)
    libtcodpy.heightmap_add(hmap, 1)
    libtcodpy.heightmap_scale(hmap, 1)
    libtcodpy.heightmap_clear(hmap)
    libtcodpy.heightmap_clamp(hmap, 0, 0)
    libtcodpy.heightmap_copy(hmap, hmap)
    libtcodpy.heightmap_normalize(hmap)
    libtcodpy.heightmap_lerp_hm(hmap, hmap, hmap, 0)
    libtcodpy.heightmap_add_hm(hmap, hmap, hmap)
    libtcodpy.heightmap_multiply_hm(hmap, hmap, hmap)

    # modifying the heightmap
    libtcodpy.heightmap_add_hill(hmap, 0, 0, 4, 1)
    libtcodpy.heightmap_dig_hill(hmap, 0, 0, 4, 1)
    libtcodpy.heightmap_rain_erosion(hmap, 1, 1, 1)
    libtcodpy.heightmap_kernel_transform(hmap, 3, [-1, 1, 0], [0, 0, 0],
                                    [.33, .33, .33], 0, 1)
    libtcodpy.heightmap_add_voronoi(hmap, 10, 3, [1,3,5])
    libtcodpy.heightmap_add_fbm(hmap, noise, 1, 1, 1, 1, 4, 1, 1)
    libtcodpy.heightmap_scale_fbm(hmap, noise, 1, 1, 1, 1, 4, 1, 1)
    libtcodpy.heightmap_dig_bezier(hmap, [0, 16, 16, 0], [0, 0, 16, 16],
                              1, 1, 1, 1)

    # read data
    libtcodpy.heightmap_get_value(hmap, 0, 0)
    libtcodpy.heightmap_get_interpolated_value(hmap, 0, 0)

    libtcodpy.heightmap_get_slope(hmap, 0, 0)
    libtcodpy.heightmap_get_normal(hmap, 0, 0, 0)
    libtcodpy.heightmap_count_cells(hmap, 0, 0)
    libtcodpy.heightmap_has_land_on_border(hmap, 0)
    libtcodpy.heightmap_get_minmax(hmap)

    libtcodpy.noise_delete(noise)
    libtcodpy.heightmap_delete(hmap)
Exemplo n.º 5
0
def test_heightmap():
    hmap = libtcodpy.heightmap_new(16, 16)
    repr(hmap)
    noise = libtcodpy.noise_new(2)

    # basic operations
    libtcodpy.heightmap_set_value(hmap, 0, 0, 1)
    libtcodpy.heightmap_add(hmap, 1)
    libtcodpy.heightmap_scale(hmap, 1)
    libtcodpy.heightmap_clear(hmap)
    libtcodpy.heightmap_clamp(hmap, 0, 0)
    libtcodpy.heightmap_copy(hmap, hmap)
    libtcodpy.heightmap_normalize(hmap)
    libtcodpy.heightmap_lerp_hm(hmap, hmap, hmap, 0)
    libtcodpy.heightmap_add_hm(hmap, hmap, hmap)
    libtcodpy.heightmap_multiply_hm(hmap, hmap, hmap)

    # modifying the heightmap
    libtcodpy.heightmap_add_hill(hmap, 0, 0, 4, 1)
    libtcodpy.heightmap_dig_hill(hmap, 0, 0, 4, 1)
    libtcodpy.heightmap_rain_erosion(hmap, 1, 1, 1)
    libtcodpy.heightmap_kernel_transform(hmap, 3, [-1, 1, 0], [0, 0, 0],
                                         [.33, .33, .33], 0, 1)
    libtcodpy.heightmap_add_voronoi(hmap, 10, 3, [1, 3, 5])
    libtcodpy.heightmap_add_fbm(hmap, noise, 1, 1, 1, 1, 4, 1, 1)
    libtcodpy.heightmap_scale_fbm(hmap, noise, 1, 1, 1, 1, 4, 1, 1)
    libtcodpy.heightmap_dig_bezier(hmap, [0, 16, 16, 0], [0, 0, 16, 16], 1, 1,
                                   1, 1)

    # read data
    libtcodpy.heightmap_get_value(hmap, 0, 0)
    libtcodpy.heightmap_get_interpolated_value(hmap, 0, 0)

    libtcodpy.heightmap_get_slope(hmap, 0, 0)
    libtcodpy.heightmap_get_normal(hmap, 0, 0, 0)
    libtcodpy.heightmap_count_cells(hmap, 0, 0)
    libtcodpy.heightmap_has_land_on_border(hmap, 0)
    libtcodpy.heightmap_get_minmax(hmap)

    libtcodpy.noise_delete(noise)
    libtcodpy.heightmap_delete(hmap)
Exemplo n.º 6
0
def temperature(heightmap, temp):
    for x in range(WORLD_WIDTH):
        for y in range(WORLD_HEIGHT):
            height_effect = 0
            if y > WORLD_HEIGHT / 2:
                tcod.heightmap_set_value(temp, x, y,
                                         WORLD_HEIGHT - y - height_effect)
            else:
                tcod.heightmap_set_value(temp, x, y, y - height_effect)
            height_effect = tcod.heightmap_get_value(heightmap, x, y)

            if height_effect > 0.8:
                height_effect *= 5
                if y > WORLD_HEIGHT / 2:
                    tcod.heightmap_set_value(temp, x, y,
                                             WORLD_HEIGHT - y - height_effect)
                else:
                    tcod.heightmap_set_value(temp, x, y, y - height_effect)

            if height_effect < 0.25:
                height_effect *= 10
                if y > WORLD_HEIGHT / 2:
                    tcod.heightmap_set_value(temp, x, y,
                                             WORLD_HEIGHT - y - height_effect)
                else:
                    tcod.heightmap_set_value(temp, x, y, y - height_effect)

    return heightmap, temp
Exemplo n.º 7
0
 def __setitem__(self, index, value):
     x, y = index
     assert x < self.width and y < self.height
     if type(x) is float and type(y) is float:
         x, y = self.interpolated_value(x, y)
     tcod.heightmap_set_value(self._data, x, y, value)
Exemplo n.º 8
0
 def __setitem__(self, index, value):
     x, y = index
     assert x < self.width and y < self.height
     if type(x) is float and type(y) is float:
         x, y = tcod.heightmap_interpolated_value(x, y)
     tcod.heightmap_set_value(self._data, x, y, value)