diff --git a/src/hud/mod.rs b/src/hud/mod.rs index a0b0d0a..334e61a 100644 --- a/src/hud/mod.rs +++ b/src/hud/mod.rs @@ -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(), }) diff --git a/src/player.rs b/src/player.rs index dda2350..c08dd03 100644 --- a/src/player.rs +++ b/src/player.rs @@ -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 diff --git a/src/state.rs b/src/state.rs index 08997ca..a554d9c 100644 --- a/src/state.rs +++ b/src/state.rs @@ -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, 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 => {