From abe81e44ef62c2b368aa4ff13f66ae198b0dea3c Mon Sep 17 00:00:00 2001
From: Louis Capitanchik <contact@louiscap.co>
Date: Mon, 3 Oct 2022 12:32:25 +0100
Subject: [PATCH] Fix web resolution

---
 game_core/Cargo.toml                   | 2 +-
 game_core/src/splash_screen/systems.rs | 4 ++--
 game_core/src/system/camera.rs         | 4 ++--
 game_core/src/system/load_config.rs    | 9 +++++++++
 game_core/src/system/resources.rs      | 4 ++--
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/game_core/Cargo.toml b/game_core/Cargo.toml
index 48018ea..268949d 100644
--- a/game_core/Cargo.toml
+++ b/game_core/Cargo.toml
@@ -7,7 +7,7 @@ edition = "2021"
 
 [features]
 default = []
-no-aspect = []
+no_aspect = []
 
 [dependencies]
 anyhow.workspace = true
diff --git a/game_core/src/splash_screen/systems.rs b/game_core/src/splash_screen/systems.rs
index c0c90b4..4054c76 100644
--- a/game_core/src/splash_screen/systems.rs
+++ b/game_core/src/splash_screen/systems.rs
@@ -9,7 +9,7 @@ use crate::splash_screen::components::{
 	SplashAnimation, SplashAnimationBundle, SplashAnimationTimer, SplashAnimationType,
 };
 use crate::system::flow::AppState;
-use crate::system::load_config::initial_size;
+use crate::system::load_config::{initial_size, viewport_size};
 use crate::system::utilities::f32_min;
 use crate::system::window::WindowManager;
 
@@ -49,7 +49,7 @@ pub fn setup_splash_screen(
 	// 	}
 	// };
 
-	let window_size = initial_size();
+	let window_size = viewport_size();
 
 	let handle = match handles.images.get("splash") {
 		Some(handle) => handle,
diff --git a/game_core/src/system/camera.rs b/game_core/src/system/camera.rs
index e7d082b..992a987 100644
--- a/game_core/src/system/camera.rs
+++ b/game_core/src/system/camera.rs
@@ -8,7 +8,7 @@ use bevy::render::camera::ScalingMode;
 use iyes_loopless::prelude::AppLooplessStateExt;
 
 use crate::system::flow::AppState;
-use crate::system::load_config::initial_size;
+use crate::system::load_config::{initial_size, viewport_size};
 
 /// A flag component to indicate which entity should be followed by the camera
 #[derive(Component)]
@@ -19,7 +19,7 @@ pub struct GameCamera;
 
 /// System that creates a default orthographic camera, with correct tags for querying
 pub fn spawn_orthographic_camera(mut commands: Commands) {
-	let (target_width, target_height) = initial_size();
+	let (target_width, target_height) = viewport_size();
 	commands
 		.spawn_bundle(Camera2dBundle {
 			projection: OrthographicProjection {
diff --git a/game_core/src/system/load_config.rs b/game_core/src/system/load_config.rs
index 8d172b9..5481bd2 100644
--- a/game_core/src/system/load_config.rs
+++ b/game_core/src/system/load_config.rs
@@ -10,6 +10,11 @@ mod setup {
 	}
 
 	pub fn initial_size() -> (f32, f32) {
+		let (w, h) = viewport_size();
+		(w * 3.0, h * 3.0)
+	}
+
+	pub fn viewport_size() -> (f32, f32) {
 		(16.0 * 32.0, 16.0 * 18.0)
 	}
 }
@@ -20,6 +25,10 @@ mod setup {
 		String::from("assets")
 	}
 
+	pub fn viewport_size() -> (f32, f32) {
+		(16.0 * 32.0, 16.0 * 18.0)
+	}
+
 	#[cfg(feature = "no_aspect")]
 	pub fn initial_size() -> (f32, f32) {
 		static default_width: f32 = 16.0 * 32.0;
diff --git a/game_core/src/system/resources.rs b/game_core/src/system/resources.rs
index 9ac587c..cab2bb4 100644
--- a/game_core/src/system/resources.rs
+++ b/game_core/src/system/resources.rs
@@ -11,8 +11,8 @@ impl Plugin for DefaultResourcesPlugin {
 		let (width, height) = initial_size();
 
 		app.insert_resource(WindowDescriptor {
-			width: width * 3.0,
-			height: height * 3.0,
+			width,
+			height,
 			resizable: true,
 			title: String::from("Ludum Dare 51"),
 			present_mode: PresentMode::AutoNoVsync,
-- 
GitLab