From cb0fb3d5b0c6efffb4d7409aa38ca0960b4286d4 Mon Sep 17 00:00:00 2001 From: Johannes Hendrik Gerard van der Weide Date: Fri, 1 Dec 2023 17:13:51 +0100 Subject: [PATCH] Strings...................... --- data/settings.json | 2 +- src/main.rs | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/data/settings.json b/data/settings.json index 0c65381..dbdf807 100644 --- a/data/settings.json +++ b/data/settings.json @@ -1 +1 @@ -{"up":32,"down":28,"left":10,"right":13} \ No newline at end of file +{"up":"W","down":"S","left":"A","right":"D"} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7b2b55..a75dc36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,10 +4,10 @@ use std::fs; #[derive(Component, Serialize, Deserialize)] pub struct Settings { - pub up: u32, - pub down: u32, - pub left: u32, - pub right: u32, + pub up: String, + pub down: String, + pub left: String, + pub right: String, } #[derive(Component, Serialize, Deserialize)] @@ -44,10 +44,10 @@ fn setup(mut commands: Commands, asset_server: Res) { commands.spawn(Camera2dBundle::default()); let json_settings = Settings { - up: 32, - down: 28, - left: 10, - right: 13, + up: "W".to_string(), + down: "S".to_string(), + left: "A".to_string(), + right: "D".to_string(), }; let _ = fs::write( "./data/settings.json", @@ -58,7 +58,6 @@ fn setup(mut commands: Commands, asset_server: Res) { let settings_data: Settings = serde_json5::from_str::(&settings_json).expect("Error serializing to JSON"); - let texture = asset_server.load("blobcat_hertog.png"); let json_file = fs::read_to_string("./data/player_data.json").expect("Error Reading Player Data"); let player_data: Player = @@ -69,7 +68,7 @@ fn setup(mut commands: Commands, asset_server: Res) { custom_size: Some(Vec2::new(50.0, 50.0)), ..default() }, - texture, + texture: asset_server.load("blobcat_hertog.png"), ..default() }, //TODO: find out how to use vectors in json so I don't have to use this array fuckery @@ -150,6 +149,5 @@ fn character_movement(mut characters: Query<(&mut Transform, &mut Player)>, time } else { player.movement.y = -player.movement.y; } - info!("Player is at {:#?} !", transform); } }