Implements procedural ground tile generation
Adds procedural ground tile generation with chunking for improved performance. Includes: - Ground tile entity with debug text and cell information - Grass and tree placement based on cell data - Ground shader for visual representation - Chunk loading and unloading system based on player position
This commit is contained in:
parent
95665f54eb
commit
b5bf7619e6
21 changed files with 532 additions and 149 deletions
56
Utilities/Random/RandomClass.gd
Normal file
56
Utilities/Random/RandomClass.gd
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
extends Node
|
||||
|
||||
class_name RandomClass
|
||||
|
||||
var _rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
print("Global RNG initialized with seed: ", _rng.seed)
|
||||
|
||||
# Set a specific seed for reproducible results
|
||||
func set_seed(seed_value: int) -> void:
|
||||
_rng.seed = seed_value
|
||||
print("RNG seed set to: ", seed_value)
|
||||
|
||||
# Randomize the seed (for non-reproducible results)
|
||||
func randomize() -> void:
|
||||
_rng.randomize()
|
||||
print("RNG seed randomized to: ", _rng.seed)
|
||||
|
||||
# Get the current seed value
|
||||
func get_seed() -> int:
|
||||
return _rng.seed
|
||||
|
||||
# Get a random integer between min and max (inclusive)
|
||||
func randi_range(min_value: int, max_value: int) -> int:
|
||||
return _rng.randi_range(min_value, max_value)
|
||||
|
||||
# Get a random float between 0.0 and 1.0
|
||||
func randf() -> float:
|
||||
return _rng.randf()
|
||||
|
||||
func randi() -> int:
|
||||
return _rng.randi()
|
||||
|
||||
# Get a random float between min and max
|
||||
func randf_range(min_value: float, max_value: float) -> float:
|
||||
return _rng.randf_range(min_value, max_value)
|
||||
|
||||
# Get a random normalized vector
|
||||
func random_unit_vector() -> Vector2:
|
||||
return Vector2(randf_range(-1.0, 1.0), randf_range(-1.0, 1.0)).normalized()
|
||||
|
||||
# Get a random point inside a circle with radius 1
|
||||
func random_point_in_circle() -> Vector2:
|
||||
var r = sqrt(randf())
|
||||
var theta = randf() * 2.0 * PI
|
||||
return Vector2(r * cos(theta), r * sin(theta))
|
||||
|
||||
# Get a random point inside a circle with specified radius
|
||||
func random_point_in_circle_with_radius(radius: float) -> Vector2:
|
||||
return random_point_in_circle() * radius
|
||||
|
||||
# Get a random boolean value with specified probability
|
||||
func random_bool(probability: float = 0.5) -> bool:
|
||||
return randf() < probability
|
||||
Loading…
Add table
Add a link
Reference in a new issue