Ejemplo n.º 1
0
def precipitation(precip_heightmap, temp_heightmap):
    precip_heightmap[:] += 2
    for x in range(WORLD_WIDTH):
        for y in range(WORLD_HEIGHT):
            temp = tcod.heightmap_get_value(temp_heightmap, x, y)
    precipitation = tcod.noise_new(2, tcod.NOISE_DEFAULT_HURST,
                                   tcod.NOISE_DEFAULT_LACUNARITY)
    tcod.heightmap_add_fbm(precip_heightmap, precipitation, 2, 2, 0, 0, 32, 1,
                           1)
    tcod.heightmap_normalize(precip_heightmap, 0.0, 1.0)

    return precip_heightmap, temp_heightmap
Ejemplo n.º 2
0
def make_base_heightmap(dim, noise):
	height = tcod.heightmap_new(*dim)
	height[:] = 1
	tcod.heightmap_add_fbm(height,
		noise = noise,
		mulx = 6,
		muly = 6,
		addx = 0,
		addy = 0,
		octaves = 5,
		delta = 0,
		scale = 1
	)
	tcod.heightmap_normalize(height, 0.1, 1.5)
	return height
Ejemplo n.º 3
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)
Ejemplo 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)
Ejemplo n.º 5
0
    def build_base_map(self, hill_cnt=60):
        self.add_land(hill_cnt, 16 * self.width / 200, 0.7, 0.6)
        tcod.heightmap_normalize(self._hm)
        tcod.heightmap_add_fbm(self._hm, noise2d, 2.20 * self.width / 400,
                               2.2 * self.width / 400, 0, 0, 10, 1.0, 2.05)
        tcod.heightmap_normalize(self._hm)
        self._hm2 = self._hm.copy()
        self.set_land_mass(0.6, SAND_HEIGHT)
        # Fix land/mountain ratio using x^3 curve above sea level
        for x in range(self.width):
            for y in range(self.height):
                h = self._hm[y, x]
                if h >= SAND_HEIGHT:
                    coef = (h - SAND_HEIGHT) / (1.0 - SAND_HEIGHT)
                    h = SAND_HEIGHT + coef * coef * coef * (1.0 - SAND_HEIGHT)
                    self._hm[y, x] = h

        f = [0, 0]
        for x in range(self.width):
            f[0] = 6.0 * x / self.width
            for y in range(self.height):
                f[1] = 6.0 * y / self.height
                self._clouds[y, x] = 0.5 * (1.0 + 0.8 * tcod.noise_get_fbm(
                    noise2d, f, 4.0, tcod.NOISE_SIMPLEX))
Ejemplo n.º 6
0
 def add_fbm(self, noise, mulx, muly, addx, addy, octaves, delta, scale):
     "Perturb  by adding fbm noise values."
     tcod.heightmap_add_fbm(self._data, noise, mulx, muly, addx, addy, octaves, delta, scale)
Ejemplo n.º 7
0
 def add_fbm(self, noise, mulx, muly, addx, addy, octaves, delta, scale):
     tcod.heightmap_add_fbm(self._data, noise, mulx, muly, addx, addy, octaves, delta, scale)
     return self