Esempio n. 1
0
water_height = 40

height_divider = 20

half_width = map_width / 2
half_height = map_height / 2

max_len = hf.len(half_width, half_height)

#setting terrain types
for x in range(map_width):
    for y in range(map_height):
        noise = int(gen.fractal(x, y, octaves, persistence, freq, min,
                                max)) + 120
        noise *= pow(hf.len(x - half_width, y - half_height) / max_len, 0.75)
        noise = hf.roundToNearest(noise, 30)
        map_data[x + map_width * y][1] = noise

        #setting terrain types
        if noise > mountain_height:
            map_data[x + map_width * y][0] = tileTypes["MOUNTAINS"]
            map_data[x + map_width * y][1] = int(
                gen.fractal(x, y, octaves, persistence, freq, 200, 400))
        elif noise < water_height:
            map_data[x + map_width * y][0] = tileTypes["WATER"]

        #adding trees
#print noise, tree_band[0], tree_band[1]
        if int(noise) in range(tree_band[0], tree_band[1]):
            td = gen.fractal(x + 100, y + 100, octaves, persistence, 0.1, 0, 1)
            if 0 < (td):
Esempio n. 2
0
max = 255

#setting some limits to divide the heightfield into terrain types
peak_height = 190
mountain_height = 170
tree_band = (90, 150)
tree_density_scale = 0.5
water_height = 90

height_divider = 20

#setting terrain types
for x in range(map_width):
    for y in range(map_height):
        noise = int(gen.fractal(x, y, octaves, persistence, freq, min, max))
        map_data[x + map_width * y][1] = hf.roundToNearest(noise,
                                                           25) / height_divider
        #setting terrain types
        if noise > peak_height:
            map_data[x + map_width * y][0] = tileTypes["MOUNTAINS"]
            map_data[x + map_width * y][1] = int(
                gen.fractal(x, y, octaves, persistence, freq / 2, min,
                            max)) / (height_divider / 2)
        elif noise > mountain_height:
            map_data[x + map_width * y][0] = tileTypes["MOUNTAINS"]
            map_data[x + map_width * y][1] = int(
                gen.fractal(x, y, octaves, persistence, freq / 2, min,
                            max)) / 12
        elif noise < water_height:
            map_data[x + map_width * y][0] = tileTypes["WATER"]

        #adding trees