如何培林产生的噪声在查看?

0

的问题

我在尝试做一个生存游戏和我有一个问题培林噪音。 我的程序给了我这个:

enter image description here

但是我想要的东西喜欢的岛屿或河流。

这是我的代号:

#SetUp#
import pygame, sys, random
pygame.init()
win = pygame.display.set_mode((800, 600))
pygame.display.set_caption('Isom')
x = 0
y = 0
s = 0
tilel = list()
random.seed(5843)
MAP = [random.randint(0, 1) for _ in range(192)]

#Tiles#
class tile():
    grass = pygame.image.load('Sprites/Images/Grass.png')
    water = pygame.image.load('Sprites/Images/Water.png')

#Loop#
while True:
    for key in pygame.event.get():
        if key.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    #World#
    for a in range(12):
        for b in range(16):
            if MAP[s] == 0:
                win.blit((tile.grass), (x, y))
            elif MAP[s] == 1:
                win.blit((tile.water), (x, y))
            x += 50
            s += 1
        x = 0
        y += 50
    x = 0
    y = 0
    s = 0
    #Update#
    pygame.display.update()
perlin-noise pygame python
2021-11-23 16:52:32
2

最好的答案

0

我建议安装的 noise 包。
然后使用 noise.pnoise1(x) 1维培林噪音, noise.pnoise2(x, y) 2维培林噪声, noise.pnoise3(x, y, z) 3维培林噪音。

2021-11-24 16:33:42
0

首先,关键的想法:培林是一个受欢迎的术语,但实际"培林"噪声算法是老和明显地方对准。 好的,作为一般规则,使用一个单纯型的噪音。

我建议PyFastNoiseLite: https://github.com/tizilogic/PyFastNoiseLite 按照安装的指示,然后镜C++例在FastNoiseLite文件: https://github.com/Auburn/FastNoiseLite/tree/master/Cpp 一定要注意其内部频率的乘积,其中可以改变 SetFrequency(f)

你也可以使用的蟒蛇的噪音图书馆为单一类型的噪音,有噪音 snoise2(x, y) 虽然如果您想使用 snoise3(x, y, z) 我将首先考虑的信息在这里: https://www.reddit.com/r/proceduralgeneration/comments/qr6snt/countdown_timer_simplex_patent_expiration/

2021-11-24 20:37:26

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................