generated from krampus/template-godot4
Construct generation
All checks were successful
linting & formatting / build (push) Successful in 12s
All checks were successful
linting & formatting / build (push) Successful in 12s
This commit is contained in:
parent
b709118be2
commit
e2e786a198
@ -4,6 +4,10 @@ class_name Chunk extends Node3D
|
|||||||
const SIZE := Vector2(64, 64)
|
const SIZE := Vector2(64, 64)
|
||||||
const SCENE := preload("res://src/world/generation/chunk/chunk.tscn")
|
const SCENE := preload("res://src/world/generation/chunk/chunk.tscn")
|
||||||
|
|
||||||
|
@export var construct_offset := Vector2(0.1, 0.0)
|
||||||
|
@export var construct_height_factor := 300.0
|
||||||
|
@export var construct_height_threshold := 30.0
|
||||||
|
|
||||||
|
|
||||||
func chunk_position() -> Vector2:
|
func chunk_position() -> Vector2:
|
||||||
return Chunk.world_to_chunk(position)
|
return Chunk.world_to_chunk(position)
|
||||||
@ -13,6 +17,18 @@ func generate() -> void:
|
|||||||
# TODO: this
|
# TODO: this
|
||||||
print_debug("Generating chunk at ", chunk_position())
|
print_debug("Generating chunk at ", chunk_position())
|
||||||
|
|
||||||
|
# Let's generate a building...
|
||||||
|
var construct_noise := WorldGenManager.noise.get_noise_2dv(chunk_position() + construct_offset)
|
||||||
|
var construct_height := construct_noise * construct_height_factor
|
||||||
|
if construct_height > construct_height_threshold:
|
||||||
|
print_debug("GENERATING CONSTRUCT")
|
||||||
|
var construct := CSGBox3D.new()
|
||||||
|
add_child(construct)
|
||||||
|
construct.size = Vector3(60, construct_height, 60)
|
||||||
|
construct.position = Vector3(2, construct_height / 2, 2)
|
||||||
|
construct.collision_layer = 1
|
||||||
|
construct.use_collision = true
|
||||||
|
|
||||||
|
|
||||||
static func chunk_to_world(chunk_pos: Vector2) -> Vector3:
|
static func chunk_to_world(chunk_pos: Vector2) -> Vector3:
|
||||||
return Vector3(chunk_pos.x * SIZE.x, 0, chunk_pos.y * SIZE.y)
|
return Vector3(chunk_pos.x * SIZE.x, 0, chunk_pos.y * SIZE.y)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user