camera zooming

This commit is contained in:
2025-05-09 18:13:28 +01:00
parent e3ea662668
commit 31e6eb29b2
7 changed files with 96 additions and 64 deletions
+8 -7
View File
@@ -11,8 +11,8 @@ use noise::{NoiseFn, Perlin};
pub const CHUNK_SIZE: i32 = 8;
pub const Z_BELOW: f32 = 3.0;
pub const Z_ABOVE: f32 = 5.0;
pub const Z_BELOW: f32 = 20.0;
pub const Z_ABOVE: f32 = 10.0;
pub const Z_TOTAL: f32 = Z_ABOVE + Z_BELOW; // MAX 255 DO NOT EXCEED
#[derive(Resource)]
@@ -164,6 +164,7 @@ fn generate_chunks_from_algo(
) {
let is_empty = events.is_empty();
let start = Instant::now();
let count = events.len();
let cave_noise = Perlin::new(0);
for event in events.read() {
@@ -204,9 +205,9 @@ fn generate_chunks_from_algo(
let noise_value = cave_noise.get([
world_x as f64 * 0.05,
world_y as f64 * 0.05,
z as f64 * (0.15 * -z as f64),
z as f64 * 0.05,
]);
if noise_value < -0.65 {
if noise_value < -0.85 {
FloorTilePrefab::air(position).spawn(&mut commands);
tilemap
.floor_tiles
@@ -278,13 +279,13 @@ fn generate_chunks_from_algo(
}
}
if !is_empty {
println!("Chunks loaded in {:.2?}", start.elapsed());
println!("{} chunks loaded in {:.2?}", count, start.elapsed());
}
}
fn setup_initial_chunks(mut event_writer: EventWriter<LoadChunkEvent>) {
for x in -10..=10 {
for y in -10..=10 {
for x in -16..=16 {
for y in -9..=9 {
event_writer.write(LoadChunkEvent {
chunk_position: IVec2::new(x, y),
});