Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Physics, block placing breaking complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamkob12 committed Sep 28, 2023
1 parent 7aa61a3 commit 3272c98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use bevy_meshem::prelude::*;
use block_reg::*;
use chunk::*;
use core::f32::consts::PI;
#[allow(unused_imports)]
use debug_3d::*;
use futures_lite::future;
use noise::Perlin;
Expand All @@ -24,7 +25,7 @@ pub use utils::*;

// const FACTOR: usize = CHUNK_DIMS.0;
// Render distance should be above 1.
pub const RENDER_DISTANCE: i32 = 8;
pub const RENDER_DISTANCE: i32 = 4;
pub const GEN_SEED: u32 = 5;
const CROSSHAIR_SIZE: f32 = 36.0;

Expand Down Expand Up @@ -61,7 +62,7 @@ fn main() {

.init_resource::<BlockRegistry>()
.insert_resource(AmbientLight {
brightness: 0.35, color: Color::WHITE,})
brightness: 0.8, color: Color::WHITE,})
.insert_resource(CycleTimer(Timer::new(
bevy::utils::Duration::from_millis(50),
TimerMode::Repeating,)))
Expand All @@ -77,7 +78,7 @@ fn main() {
.add_systems(OnEnter(InitialChunkLoadState::Complete), setup_light)
.add_systems(Update,
check_if_loaded.run_if(in_state(InitialChunkLoadState::MeshesLoaded)),)
.add_systems(Update,(handle_tasks, add_break_detector, debug_cage),)
.add_systems(Update,(handle_tasks, add_break_detector, /* debug_cage */),)
.add_systems(PostUpdate, handle_block_break_place);

app.run();
Expand All @@ -99,7 +100,7 @@ fn setup(
commands.spawn(LoadedChunks(0));
let mut projection = camera_query.get_single_mut().unwrap();
if let Projection::Perspective(ref mut perspective) = *projection {
perspective.fov = PI / 2.6;
perspective.fov = PI / 3.0;
}
}

Expand Down Expand Up @@ -224,7 +225,7 @@ fn handle_block_break_place(
} else {
Entity::PLACEHOLDER
};
let mut onto_chunk = [u16::max_value(); 4096];
let mut onto_chunk = [u16::max_value(); CHUNK_LEN];
for (e, c) in chunk_query.iter() {
if e == onto_ent {
onto_chunk = c.grid;
Expand Down
1 change: 0 additions & 1 deletion src/player/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ pub(super) fn player_move(
}
}
}
// Apply gravity
direction = direction.normalize_or_zero();
// Calculate if we collided with a block
let velocity = direction * time.delta_seconds() * settings.speed;
Expand Down
6 changes: 3 additions & 3 deletions src/sky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ pub fn daylight_cycle(
mut atmosphere: AtmosphereMut<Nishita>,
mut query: Query<(&mut Transform, &mut DirectionalLight), With<Sun>>,
) {
atmosphere.sun_position = Vec3::new(0., 0.8, 0.8);
atmosphere.sun_position = Vec3::new(0.0, 0.9, 0.7);

if let Some((mut light_trans, mut directional)) = query.single_mut().into() {
light_trans.rotation = Quat::from_rotation_x(-2.85);
directional.illuminance = 25000.0;
light_trans.rotation = Quat::from_rotation_x(-2.75);
directional.illuminance = 20000.0;
}
}

0 comments on commit 3272c98

Please sign in to comment.