INNER CODE UNIT · Rust

update_window_dimensions

CleanCut/rusty_engine · src/game.rs:226

pub fn update_window_dimensions(
    window_query: Query<&Window, With<PrimaryWindow>>,
    mut engine: ResMut<Engine>,
) {
    // It's possible to not have a window for the first frame or two
    let Ok(window) = window_query.single() else {
        return;
    };
    let screen_dimensions = Vec2::new(window.width(), window.height());
    if screen_dimensions != engine.window_dimensions {
        engine.window_dimensions = screen_dimensions;
        debug!("Set window dimensions: {}", engine.window_dimensions);
    }
}

/// Component to add to the collider lines visualizations to link them to the sprite they represent
#[derive(Component)]
#[doc(hidden)]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…