How could I use TileMap's and OpenSimplexNoise together?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

I want to generate a random map with OpenSimplexNoise’s and port it to TileMap’s.

:bust_in_silhouette: Reply From: Zylann

Like this? (untested, just wrote it to give you an idea):

var sea_tile = tilemap.tile_set.find_tile_by_name("Sea")
var land_tile = tilemap.tile_set.find_tile_by_name("Land")

var osn = OpenSimplexNoise.new()

for y in 10:
	for x in 10:
		var height = osn.get_noise_2d(x, y)
		if height > 0.0:
			tilemap.set_cell(x, y, land_tile)
		else:
			tilemap.set_cell(x, y, sea_tile)

I don’t understand why OpenSimplexNoise generates values less than 0.

JulioYagami | 2019-09-11 14:39

According to the doc, the return value of get_noise functions is between -1 and 1: OpenSimplexNoise — Godot Engine (3.1) documentation in English

Zylann | 2019-09-11 17:48