mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
change world generations, enable mi[mapping in sampler, unlink movement speed from fps
This commit is contained in:
parent
fc6da8856d
commit
dfdcc3e4b7
|
@ -1,7 +1,7 @@
|
||||||
use glam::{Vec3, Mat4, Quat, EulerRot, Vec2};
|
use glam::{Vec3, Mat4, Quat, EulerRot, Vec2};
|
||||||
use shipyard::{Component, View, ViewMut, IntoIter, UniqueView, Workload, IntoWorkload};
|
use shipyard::{Component, View, ViewMut, IntoIter, UniqueView, Workload, IntoWorkload};
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
use crate::{transform::Transform, input::Inputs, settings::GameSettings};
|
use crate::{transform::Transform, input::Inputs, settings::GameSettings, DeltaTime};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct FlyController;
|
pub struct FlyController;
|
||||||
|
@ -19,7 +19,7 @@ fn update_look(
|
||||||
controllers: View<FlyController>,
|
controllers: View<FlyController>,
|
||||||
mut transforms: ViewMut<Transform>,
|
mut transforms: ViewMut<Transform>,
|
||||||
inputs: UniqueView<Inputs>,
|
inputs: UniqueView<Inputs>,
|
||||||
settings: UniqueView<GameSettings>,
|
settings: UniqueView<GameSettings>
|
||||||
) {
|
) {
|
||||||
let look = inputs.look * settings.mouse_sensitivity;
|
let look = inputs.look * settings.mouse_sensitivity;
|
||||||
if look == Vec2::ZERO { return }
|
if look == Vec2::ZERO { return }
|
||||||
|
@ -29,7 +29,7 @@ fn update_look(
|
||||||
yaw -= look.x;
|
yaw -= look.x;
|
||||||
pitch -= look.y;
|
pitch -= look.y;
|
||||||
pitch = pitch.clamp(-MAX_PITCH, MAX_PITCH);
|
pitch = pitch.clamp(-MAX_PITCH, MAX_PITCH);
|
||||||
rotation = Quat::from_euler(EulerRot::YXZ, yaw, pitch, 0.);
|
rotation = Quat::from_euler(EulerRot::YXZ, yaw, pitch, 0.).normalize();
|
||||||
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
|
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,10 @@ fn update_look(
|
||||||
fn update_movement(
|
fn update_movement(
|
||||||
controllers: View<FlyController>,
|
controllers: View<FlyController>,
|
||||||
mut transforms: ViewMut<Transform>,
|
mut transforms: ViewMut<Transform>,
|
||||||
inputs: UniqueView<Inputs>
|
inputs: UniqueView<Inputs>,
|
||||||
|
dt: UniqueView<DeltaTime>,
|
||||||
) {
|
) {
|
||||||
let movement = inputs.movement;
|
let movement = inputs.movement * 30. * dt.0.as_secs_f32();
|
||||||
if movement == Vec2::ZERO { return }
|
if movement == Vec2::ZERO { return }
|
||||||
for (_, mut transform) in (&controllers, &mut transforms).iter() {
|
for (_, mut transform) in (&controllers, &mut transforms).iter() {
|
||||||
let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation();
|
let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation();
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub struct GameSettings {
|
||||||
impl Default for GameSettings {
|
impl Default for GameSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
render_distance: 2,
|
render_distance: 5,
|
||||||
mouse_sensitivity: 0.01,
|
mouse_sensitivity: 0.01,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub fn draw_world(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let texture_sampler = Sampler(&texture.0, SamplerBehavior {
|
let texture_sampler = Sampler(&texture.0, SamplerBehavior {
|
||||||
minify_filter: MinifySamplerFilter::Linear,
|
minify_filter: MinifySamplerFilter::LinearMipmapLinear,
|
||||||
magnify_filter: MagnifySamplerFilter::Nearest,
|
magnify_filter: MagnifySamplerFilter::Nearest,
|
||||||
max_anisotropy: 8,
|
max_anisotropy: 8,
|
||||||
wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
||||||
|
|
|
@ -4,13 +4,20 @@ use super::{
|
||||||
block::Block
|
block::Block
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn generate_world(_position: IVec3, _seed: u32) -> BlockData {
|
pub fn generate_world(position: IVec3, _seed: u32) -> BlockData {
|
||||||
let mut blocks = Box::new([[[Block::Air; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]);
|
let mut blocks = Box::new([[[Block::Air; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]);
|
||||||
blocks[0][0][0] = Block::Stone;
|
blocks[0][0][0] = Block::Stone;
|
||||||
blocks[1][0][0] = Block::Stone;
|
blocks[1][0][0] = Block::Stone;
|
||||||
blocks[0][1][0] = Block::Stone;
|
blocks[0][1][0] = Block::Stone;
|
||||||
blocks[0][2][0] = Block::Stone;
|
blocks[0][2][0] = Block::Stone;
|
||||||
blocks[0][0][1] = Block::Stone;
|
blocks[0][0][1] = Block::Stone;
|
||||||
|
if position.y == 0 {
|
||||||
|
for x in 0..CHUNK_SIZE {
|
||||||
|
for z in 0..CHUNK_SIZE {
|
||||||
|
blocks[x][0][z] = Block::Stone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//TODO actual world generation
|
//TODO actual world generation
|
||||||
blocks
|
blocks
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue