Strings......................

main
Johannes Hendrik Gerard van der Weide 2023-12-01 17:13:51 +01:00
parent a6e9a8345e
commit cb0fb3d5b0
2 changed files with 10 additions and 12 deletions

View File

@ -1 +1 @@
{"up":32,"down":28,"left":10,"right":13}
{"up":"W","down":"S","left":"A","right":"D"}

View File

@ -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<AssetServer>) {
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<AssetServer>) {
let settings_data: Settings =
serde_json5::from_str::<Settings>(&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<AssetServer>) {
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);
}
}