|
|
|
|
@@ -4,6 +4,9 @@ extends Node2D
|
|
|
|
|
var noise_values
|
|
|
|
|
@onready var world_grid = $world_grid
|
|
|
|
|
|
|
|
|
|
var resource_texture: Noise = FastNoiseLite.new()
|
|
|
|
|
@export var resoure_quantity = 0.4
|
|
|
|
|
|
|
|
|
|
var temp_size = 150
|
|
|
|
|
var temp_noise_val = []
|
|
|
|
|
var temp_noise_reg = []
|
|
|
|
|
@@ -13,6 +16,9 @@ var atlas_regions = [Vector2i(0,1),Vector2i(0,0),Vector2i(2,0),Vector2i(0,2)]
|
|
|
|
|
|
|
|
|
|
func get_noise_value(x: int, y: int):
|
|
|
|
|
return noise_values.get_noise_2d(x,y) * 500
|
|
|
|
|
|
|
|
|
|
func is_resource_tile(x: int, y: int) -> bool:
|
|
|
|
|
return resource_texture.get_noise_2d(x, y) > resoure_quantity
|
|
|
|
|
|
|
|
|
|
func get_noise_region(x,y):
|
|
|
|
|
var noise_val = get_noise_value(x,y)
|
|
|
|
|
@@ -21,10 +27,14 @@ func get_noise_region(x,y):
|
|
|
|
|
return i
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
resource_texture.seed = randi()
|
|
|
|
|
#await resource_texture.changed
|
|
|
|
|
noise_values = noise_texture.noise
|
|
|
|
|
for x in range(-temp_size, temp_size):
|
|
|
|
|
for y in range(-temp_size, temp_size):
|
|
|
|
|
world_grid.set_cell(0, Vector2i(x,y),0,atlas_regions[get_noise_region(x,y)])
|
|
|
|
|
world_grid.set_cell(Constants.TilemapLayers.GROUND, Vector2i(x,y),0,atlas_regions[get_noise_region(x,y)])
|
|
|
|
|
if is_resource_tile(x,y):
|
|
|
|
|
world_grid.set_cell(Constants.TilemapLayers.ENVIRONMENT, Vector2i(x,y), 0, Vector2i(5,6))
|
|
|
|
|
temp_noise_val.append(get_noise_value(x,y))
|
|
|
|
|
temp_noise_reg.append(get_noise_region(x,y))
|
|
|
|
|
prints(temp_noise_val.min(), temp_noise_val.max())
|
|
|
|
|
@@ -34,5 +44,5 @@ func _ready():
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
|
var mouse_pos = world_grid.local_to_map(get_local_mouse_position())
|
|
|
|
|
world_grid.clear_layer(1)
|
|
|
|
|
world_grid.set_cell(1, mouse_pos,0,Vector2i(0,7))
|
|
|
|
|
world_grid.clear_layer(Constants.TilemapLayers.CURSOR)
|
|
|
|
|
world_grid.set_cell(Constants.TilemapLayers.CURSOR, mouse_pos,0,Vector2i(0,7))
|
|
|
|
|
|