Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Oops type error
Browse files Browse the repository at this point in the history
  • Loading branch information
darthdeus committed Aug 17, 2024
1 parent 1ad594e commit 56d08b0
Showing 1 changed file with 28 additions and 34 deletions.
62 changes: 28 additions & 34 deletions comfy/src/game_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ pub async fn run_comfy_main_async(
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.set_min_inner_size(PhysicalSize::new(
window.set_min_inner_size(Some(PhysicalSize::new(
resolution.width(),
resolution.height(),
));
)));

window.set_max_inner_size(PhysicalSize::new(
window.set_max_inner_size(Some(PhysicalSize::new(
resolution.width(),
resolution.height(),
));
)));

use winit::platform::web::WindowExtWebSys;
web_sys::window()
Expand All @@ -124,7 +124,6 @@ pub async fn run_comfy_main_async(
.expect("Couldn't append canvas to document body.");
}


let scale_factor = game_config()
.scale_factor_override
.unwrap_or(window.scale_factor() as f32);
Expand Down Expand Up @@ -204,7 +203,6 @@ pub async fn run_comfy_main_async(
.set_cursor_visible(!global_state.cursor_hidden);
}


set_frame_time(frame_start.elapsed().as_secs_f32());
inc_frame_num();

Expand All @@ -220,36 +218,32 @@ pub async fn run_comfy_main_async(
tracy_client::frame_mark();
}

Event::DeviceEvent { event, .. } => {
match event {
DeviceEvent::Key(input) => {
if let Some(keycode) =
KeyCode::try_from_winit(input.physical_key)
{
match input.state {
ElementState::Pressed => {
let mut state =
GLOBAL_STATE.borrow_mut();

state.pressed.insert(keycode);
state.just_pressed.insert(keycode);
state.just_released.remove(&keycode);
}

ElementState::Released => {
let mut state =
GLOBAL_STATE.borrow_mut();

state.pressed.remove(&keycode);
state.just_pressed.remove(&keycode);
state.just_released.insert(keycode);
}
Event::DeviceEvent { event, .. } => match event {
DeviceEvent::Key(input) => {
if let Some(keycode) =
KeyCode::try_from_winit(input.physical_key)
{
match input.state {
ElementState::Pressed => {
let mut state = GLOBAL_STATE.borrow_mut();

state.pressed.insert(keycode);
state.just_pressed.insert(keycode);
state.just_released.remove(&keycode);
}

ElementState::Released => {
let mut state = GLOBAL_STATE.borrow_mut();

state.pressed.remove(&keycode);
state.just_pressed.remove(&keycode);
state.just_released.insert(keycode);
}
}
}
_ => {}
}
}
_ => {}
},
Event::WindowEvent { ref event, window_id: _ } => {
if engine.renderer.as_mut().unwrap().on_event(event, egui())
{
Expand Down Expand Up @@ -335,8 +329,8 @@ pub async fn run_comfy_main_async(
}

WindowEvent::Resized(physical_size) => {
if physical_size.width > min_resolution.0 &&
physical_size.height > min_resolution.1
if physical_size.width > min_resolution.0
&& physical_size.height > min_resolution.1
{
engine.resize(uvec2(
physical_size.width,
Expand Down

0 comments on commit 56d08b0

Please sign in to comment.