Skip to content

Instantly share code, notes, and snippets.

@discolingua
Last active August 12, 2024 05:50
Show Gist options
  • Save discolingua/2c3a5d138fd073d24fdb9edb30c2a761 to your computer and use it in GitHub Desktop.
Save discolingua/2c3a5d138fd073d24fdb9edb30c2a761 to your computer and use it in GitHub Desktop.
extends TileMap
const TREES_TILE = 0
const GRASS_TILE = 1
const PLAINS_TILE = 2
var rng = RandomNumberGenerator.new()
var _k = 0
var _lo = 0
var _hi = 0
func _ready():
rng.randomize()
var _noise = OpenSimplexNoise.new()
_noise.seed = rng.randf_range(0,999999)
_noise.octaves = 2
_noise.period = 8
_noise.persistence = 0.15
_noise.lacunarity = 1.4
for _i in range(39):
for _j in range (-128,127):
_k = _noise.get_noise_2d(_i, _j)
if _k < -0.2 :
set_cell(_i, _j, TREES_TILE)
_lo += 1
elif _k > 0.3:
set_cell(_i, _j, GRASS_TILE)
_hi += 1
else:
set_cell(_i, _j, PLAINS_TILE)
print(_lo)
print(_hi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment