From 228ad9a50e0fbcf37890440f3ca0a94258a407f8 Mon Sep 17 00:00:00 2001 From: AmadeusWM <63149896+AmadeusWM@users.noreply.github.com> Date: Sun, 6 Apr 2025 22:07:17 +0200 Subject: [PATCH] lorrens aub --- assets/main.assets.ron | 8 +++++ src/asset_loading/mod.rs | 16 +++++++++ src/level_instantiation/mod.rs | 4 ++- src/player.rs | 66 +++++++++++++++++++++++++++++----- 4 files changed, 84 insertions(+), 10 deletions(-) diff --git a/assets/main.assets.ron b/assets/main.assets.ron index 80405c4..90500f4 100644 --- a/assets/main.assets.ron +++ b/assets/main.assets.ron @@ -6,6 +6,14 @@ ), "id_card": File(path: "meshes/id_card.glb"), "id_card_toolbar": File(path: "images/id_card_toolbar.png"), + "flash_hold_0": File (path: "images/pixelart/Flashlight_hold_0.png"), + "flash_hold_0_pressed": File (path: "images/pixelart/Flashlight_click_0.png"), + "flash_hold_1": File (path: "images/pixelart/Flashlight_hold_1.png"), + "flash_hold_1_pressed": File (path: "images/pixelart/Flashlight_click_1.png"), + "flash_hold_2": File (path: "images/pixelart/Flashlight_hold_2.png"), + "flash_hold_2_pressed": File (path: "images/pixelart/Flashlight_click_2.png"), + "flash_hold_3": File (path: "images/pixelart/Flashlight_hold_3.png"), + "flash_hold_3_pressed": File (path: "images/pixelart/Flashlight_click_3.png"), "flash_hold_4": File (path: "images/pixelart/Flashlight_hold_4.png"), "flash_hold_4_pressed": File (path: "images/pixelart/Flashlight_click_4.png"), "flashlight_click": File (path: "audio/flashlight-switch.ogg"), diff --git a/src/asset_loading/mod.rs b/src/asset_loading/mod.rs index ecd367f..cab7759 100644 --- a/src/asset_loading/mod.rs +++ b/src/asset_loading/mod.rs @@ -59,6 +59,22 @@ pub(crate) struct ImageAssets { #[derive(AssetCollection, Resource, Clone)] pub(crate) struct FlashlightAssets { + #[asset(key = "flash_hold_0")] + pub(crate) flash_hold_0: Handle, + #[asset(key = "flash_hold_0_pressed")] + pub(crate) flash_hold_0_pressed: Handle, + #[asset(key = "flash_hold_1")] + pub(crate) flash_hold_1: Handle, + #[asset(key = "flash_hold_1_pressed")] + pub(crate) flash_hold_1_pressed: Handle, + #[asset(key = "flash_hold_2")] + pub(crate) flash_hold_2: Handle, + #[asset(key = "flash_hold_2_pressed")] + pub(crate) flash_hold_2_pressed: Handle, + #[asset(key = "flash_hold_3")] + pub(crate) flash_hold_3: Handle, + #[asset(key = "flash_hold_3_pressed")] + pub(crate) flash_hold_3_pressed: Handle, #[asset(key = "flash_hold_4")] pub(crate) flash_hold_4: Handle, #[asset(key = "flash_hold_4_pressed")] diff --git a/src/level_instantiation/mod.rs b/src/level_instantiation/mod.rs index 121028c..41e9564 100644 --- a/src/level_instantiation/mod.rs +++ b/src/level_instantiation/mod.rs @@ -531,8 +531,10 @@ impl GameLevel { let end_node = self.nodes.get_mut(&self.end_node).unwrap(); if self.end_node.1 >= self.end_node.0 { end_node.north = Side::Connection; - } else if self.end_node.0 >= self.end_node.1 { + end_node.south = Side::Connection; + } else { end_node.east = Side::Connection; + end_node.west = Side::Connection; } } diff --git a/src/player.rs b/src/player.rs index 68f5e41..53a4792 100644 --- a/src/player.rs +++ b/src/player.rs @@ -55,7 +55,15 @@ impl Default for HeadBob { pub struct BaseTransform(pub Transform); #[derive(Debug, Component)] -pub struct Flashlight; +pub struct Flashlight { + // 0 - 4 + pub charge: f32, + pub is_on: bool, +} + +#[derive(Debug, Component)] +pub struct SpotlightFlashlight { +} #[derive(Component)] pub struct FlashlightButtonAnimation { @@ -83,7 +91,7 @@ pub fn plugin(app: &mut App) { apply_head_bob, on_resize_system, handle_flashlight, - update_flashlight_button_animation, + (update_flashlight_button_animation, update_flashlight_charge, update_flashlight_sprite).chain(), ) .run_if(in_state(GameState::Playing)), ) @@ -151,6 +159,7 @@ pub fn init_player( let window = window.single(); let transform = flashlight_base_transform(window.width(), window.height()); parent.spawn(( + Flashlight { charge: 4.0, is_on: false }, Sprite::from_image(flashlights.flash_hold_4.clone()), transform.0.clone(), transform, @@ -160,7 +169,7 @@ pub fn init_player( // feitelijke pitslamp parent.spawn(( - Flashlight, + SpotlightFlashlight{}, SpotLight { intensity: 0.0, color: Color::srgba(0.9, 0.628, 0.392, 1.0), @@ -396,7 +405,7 @@ pub fn apply_head_bob( } pub fn handle_flashlight( player_query: Query<&PlayerAction, With>, - mut flashlight_query: Query<&mut SpotLight, With>, + mut flashlight_query: Query<&mut SpotLight, With>, mut flashlight_sprite_query: Query<&mut FlashlightButtonAnimation>, audio_assets: Res, audio: Res