Last active
August 12, 2024 05:50
-
-
Save discolingua/2c3a5d138fd073d24fdb9edb30c2a761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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