From 1247f46149cbb3a21590573fdcef23e920d0addc Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 13 Oct 2022 14:59:55 +0200 Subject: … MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- renderer/src/main.rs | 14 +++++++++----- renderer/src/tee.rs | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 13 deletions(-) (limited to 'renderer/src') diff --git a/renderer/src/main.rs b/renderer/src/main.rs index af01021..186b773 100644 --- a/renderer/src/main.rs +++ b/renderer/src/main.rs @@ -138,6 +138,11 @@ fn main() { env.windowed_context.window().request_redraw(); } Event::WindowEvent { event, .. } => match event { + WindowEvent::MouseInput { button, state, .. } => match state { + ElementState::Pressed => renderer.input.fire = 1, + ElementState::Released => renderer.input.fire = 0, + }, + WindowEvent::CursorMoved { position, .. } => {} WindowEvent::Resized(physical_size) => { env.surface = create_surface(&env.windowed_context, &fb_info, &mut env.gr_context); @@ -182,11 +187,6 @@ fn main() { } _ => (), } - renderer - .client_interface - .send - .send(ClientMesgIn::Input(renderer.input)) - .unwrap(); } } } @@ -216,6 +216,10 @@ pub struct Renderer { impl Renderer { pub fn tick(&mut self) { + self.client_interface + .send + .send(ClientMesgIn::Input(self.input)) + .unwrap(); for m in self.client_interface.receive.try_iter() { self.world.update(&m); match m { diff --git a/renderer/src/tee.rs b/renderer/src/tee.rs index 8e8e3ba..4d9d945 100644 --- a/renderer/src/tee.rs +++ b/renderer/src/tee.rs @@ -11,6 +11,8 @@ const TEE_REND_RADIUS: f32 = 32.0; const TEE_EYE_ROTATION_RADIUS: f32 = 8.0; const TEE_EYE_SIZE: f32 = 12.0; const TEE_EYE_DISTANCE: f32 = 8.0; +const TEE_FOOT_SIZE: f32 = 14.0; +const TEE_EYE_OFFSET_Y: f32 = -2.0; pub struct TeeRenderer { skins: BTreeMap, @@ -61,6 +63,24 @@ impl TeeRenderer { y: tee.y as f32, }; + { + canvas.save(); + + canvas.draw_image_rect( + &skin_texture, + Some((&SKIN_FOOT, SrcRectConstraint::Strict)), + Rect { + top: -TEE_FOOT_SIZE + TEE_REND_RADIUS * 0.5, + left: -TEE_FOOT_SIZE * 2.0 - TEE_FOOT_SIZE * 0.5, + right: TEE_FOOT_SIZE * 2.0 - TEE_FOOT_SIZE * 0.5, + bottom: TEE_FOOT_SIZE + TEE_REND_RADIUS * 0.5, + }, + &tee_paint, + ); + + canvas.restore(); + } + canvas.draw_image_rect( &skin_texture, Some((&SKIN_BODY_SHADOW, SrcRectConstraint::Strict)), @@ -96,10 +116,10 @@ impl TeeRenderer { &skin_texture, Some((&SKIN_EYE_NORMAL, SrcRectConstraint::Strict)), Rect { - top: -TEE_EYE_SIZE, + top: -TEE_EYE_SIZE + TEE_EYE_OFFSET_Y, left: -TEE_EYE_SIZE - TEE_EYE_DISTANCE / 2.0, right: TEE_EYE_SIZE - TEE_EYE_DISTANCE / 2.0, - bottom: TEE_EYE_SIZE, + bottom: TEE_EYE_SIZE + TEE_EYE_OFFSET_Y, }, &tee_paint, ); @@ -110,10 +130,10 @@ impl TeeRenderer { &skin_texture, Some((&SKIN_EYE_NORMAL, SrcRectConstraint::Strict)), Rect { - top: -TEE_EYE_SIZE, + top: -TEE_EYE_SIZE + TEE_EYE_OFFSET_Y, left: -TEE_EYE_SIZE - TEE_EYE_DISTANCE / 2.0, right: TEE_EYE_SIZE - TEE_EYE_DISTANCE / 2.0, - bottom: TEE_EYE_SIZE, + bottom: TEE_EYE_SIZE + TEE_EYE_OFFSET_Y, }, &tee_paint, ); @@ -129,10 +149,10 @@ impl TeeRenderer { &skin_texture, Some((&SKIN_FOOT, SrcRectConstraint::Strict)), Rect { - top: -TEE_EYE_SIZE, - left: -TEE_EYE_SIZE - TEE_EYE_DISTANCE / 2.0, - right: TEE_EYE_SIZE - TEE_EYE_DISTANCE / 2.0, - bottom: TEE_EYE_SIZE, + top: -TEE_FOOT_SIZE + TEE_REND_RADIUS * 0.5, + left: -TEE_FOOT_SIZE * 2.0 + TEE_FOOT_SIZE * 0.5, + right: TEE_FOOT_SIZE * 2.0 + TEE_FOOT_SIZE * 0.5, + bottom: TEE_FOOT_SIZE + TEE_REND_RADIUS * 0.5, }, &tee_paint, ); -- cgit v1.2.3-70-g09d2