mgecumshooter/esotera
world now generates random every time
Commit 8edc4b96f5c4 · mgecumshooter · 2026-10-24 13:00 +0300
Comments
No comments yet.
Diff
diff --git a/Cargo.lock b/Cargo.lock
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -69,6 +69,17 @@
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
[[package]]
+name = "chacha20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "rand_core",
+]
+
+[[package]]
name = "clang-sys"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -89,6 +100,15 @@
]
[[package]]
+name = "cpufeatures"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
+dependencies = [
+ "libc",
+]
+
+[[package]]
name = "either"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -99,6 +119,7 @@
version = "0.1.0"
dependencies = [
"fastnoise-lite",
+ "rand",
"sola-raylib",
]
@@ -118,6 +139,18 @@
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+ "rand_core",
+]
+
+[[package]]
name = "glob"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -220,6 +253,29 @@
]
[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "rand"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
+dependencies = [
+ "chacha20",
+ "getrandom",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
+
+[[package]]
name = "regex"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,4 +5,5 @@
[dependencies]
fastnoise-lite = "1.1.1"
+rand = "0.10.3"
sola-raylib = "6.3.1"
diff --git a/src/main.rs b/src/main.rs
--- a/src/main.rs
+++ b/src/main.rs
@@ -62,9 +62,11 @@
Cube::new(Vector3::new(2f32, 6f32, 2f32)),
);
+ let seed: u64 = rand::random::<u64>();
+
// main game loop
while !rl.window_should_close() {
- world.load_around_player(plr.get_eye_pos());
+ world.load_around_player(plr.get_eye_pos(), seed);
world.update_chunks();
let active_chunks: Vec<&Chunk> = world.chunks.values().collect();
diff --git a/src/world/mod.rs b/src/world/mod.rs
--- a/src/world/mod.rs
+++ b/src/world/mod.rs
@@ -39,7 +39,7 @@
}
- pub fn load_around_player(&mut self, player_pos: Vector3) {
+ pub fn load_around_player(&mut self, player_pos: Vector3, seed: u64) {
const LOAD_PER_FRAME: usize = 2;
let mut loaded_this_frame = 0;
@@ -53,7 +53,7 @@
let pos_v3 = Vector3::new(player_chunk.0 as f32, player_chunk.1 as f32, player_chunk.2 as f32);
let chunk = Chunk::load_from_disk(pos_v3).unwrap_or_else(|| {
let mut ch = Chunk::new(pos_v3);
- ch.generate(42);
+ ch.generate(seed);
ch
});
self.chunks.insert(player_chunk, chunk);
@@ -79,7 +79,7 @@
);
let mut chunk = Chunk::load_from_disk(pos_v3).unwrap_or_else(|| {
let mut ch = Chunk::new(pos_v3);
- ch.generate(42);
+ ch.generate(seed);
ch
});