Fix mid-air jumping
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Sijmen 2021-06-10 17:00:44 +02:00
parent d006c6f9ef
commit f6bb14ba4b
Signed by: vijfhoek
GPG key ID: 82D05C89B28B0DAE
3 changed files with 19 additions and 18 deletions

View file

@ -2,7 +2,6 @@ use wgpu::{CommandEncoder, RenderPipeline, SwapChainTexture};
use crate::{
render_context::RenderContext,
state::PRIMITIVE_STATE,
vertex::{HudVertex, Vertex},
world::block::BlockType,
};
@ -101,7 +100,15 @@ impl Hud {
write_mask: wgpu::ColorWrite::ALL,
}],
}),
primitive: PRIMITIVE_STATE,
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
strip_index_format: None,
front_face: wgpu::FrontFace::Ccw,
cull_mode: None,
clamp_depth: false,
polygon_mode: wgpu::PolygonMode::Fill,
conservative: false,
},
depth_stencil: None,
multisample: Default::default(),
})

View file

@ -6,6 +6,7 @@ use crate::{aabb::Aabb, render_context::RenderContext, utils, view::View, world:
pub struct Player {
pub sprinting: bool,
pub grounded: bool,
pub creative: bool,
pub forward_pressed: bool,
@ -23,13 +24,16 @@ impl Player {
Self {
sprinting: false,
grounded: false,
creative: false,
view,
forward_pressed: false,
backward_pressed: false,
left_pressed: false,
right_pressed: false,
up_speed: 0.0,
view,
}
}
@ -81,6 +85,9 @@ impl Player {
}
self.up_speed = 0.0;
self.grounded = true;
} else {
self.grounded = false;
}
// x component

View file

@ -16,16 +16,6 @@ use crate::{
world::World,
};
pub const PRIMITIVE_STATE: wgpu::PrimitiveState = wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
strip_index_format: None,
front_face: wgpu::FrontFace::Ccw,
cull_mode: None,
clamp_depth: false,
polygon_mode: wgpu::PolygonMode::Fill,
conservative: false,
};
pub struct State {
pub window_size: PhysicalSize<u32>,
pub mouse_grabbed: bool,
@ -175,11 +165,8 @@ impl State {
(false, true) => 0.0,
// Not creative
(true, false) => {
// TODO Don't allow player to jump in mid-air
0.6
}
(false, false) => self.player.up_speed,
(true, false) if self.player.grounded => 0.6,
_ => self.player.up_speed,
};
}
VirtualKeyCode::LShift if self.player.creative => {