From 6fb06a102e09b7b599b4acd970943357e9fdf0fc Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Wed, 6 Dec 2023 13:35:53 +0000 Subject: [PATCH] feat: make camera follow player Former-commit-id: d13b9416c74308eaf9df81b431b82152b7a20510 --- src/main.rs | 11 ++++++++++- src/player.rs | 31 ++++++++++++++++++------------- src/ui.rs | 10 +++++----- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index 90c78e5..13b058b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,7 @@ fn main() { .init_resource::() .init_resource::() .add_systems(Startup, (setup, setup_ui)) - .add_systems(Update, (render_ui, movement)) + .add_systems(Update, (render_ui, movement, camera_follow)) .run(); } @@ -69,6 +69,15 @@ fn setup(mut commands: Commands, asset_server: Res) { tonemapping: Tonemapping::TonyMcMapface, ..default() }); + commands.spawn( + SpriteBundle { + texture: asset_server.load("player/player-4x.png"), + transform: Transform { + scale: Vec3::splat(0.2), + ..default() + }, + ..default() + }); commands.spawn(( SpriteBundle { texture: asset_server.load("player/player-4x.png"), diff --git a/src/player.rs b/src/player.rs index 2616f0e..3af183a 100644 --- a/src/player.rs +++ b/src/player.rs @@ -18,10 +18,9 @@ pub struct Player { pub fn movement( time: Res