diff --git a/assets/images/pixelart/Flashlight_click_0.png b/assets/images/pixelart/Flashlight_click_0.png new file mode 100644 index 0000000..0519c7e Binary files /dev/null and b/assets/images/pixelart/Flashlight_click_0.png differ diff --git a/assets/images/pixelart/Flashlight_click_1.png b/assets/images/pixelart/Flashlight_click_1.png new file mode 100644 index 0000000..8810341 Binary files /dev/null and b/assets/images/pixelart/Flashlight_click_1.png differ diff --git a/assets/images/pixelart/Flashlight_click_2.png b/assets/images/pixelart/Flashlight_click_2.png new file mode 100644 index 0000000..26adff5 Binary files /dev/null and b/assets/images/pixelart/Flashlight_click_2.png differ diff --git a/assets/images/pixelart/Flashlight_click_3.png b/assets/images/pixelart/Flashlight_click_3.png new file mode 100644 index 0000000..7945d8f Binary files /dev/null and b/assets/images/pixelart/Flashlight_click_3.png differ diff --git a/assets/images/pixelart/Flashlight_click_4.png b/assets/images/pixelart/Flashlight_click_4.png new file mode 100644 index 0000000..bd824d9 Binary files /dev/null and b/assets/images/pixelart/Flashlight_click_4.png differ diff --git a/assets/images/pixelart/Flashlight_hold_0.png b/assets/images/pixelart/Flashlight_hold_0.png new file mode 100644 index 0000000..d8d846d Binary files /dev/null and b/assets/images/pixelart/Flashlight_hold_0.png differ diff --git a/assets/images/pixelart/Flashlight_hold_1.png b/assets/images/pixelart/Flashlight_hold_1.png new file mode 100644 index 0000000..a299321 Binary files /dev/null and b/assets/images/pixelart/Flashlight_hold_1.png differ diff --git a/assets/images/pixelart/Flashlight_hold_2.png b/assets/images/pixelart/Flashlight_hold_2.png new file mode 100644 index 0000000..c177578 Binary files /dev/null and b/assets/images/pixelart/Flashlight_hold_2.png differ diff --git a/assets/images/pixelart/Flashlight_hold_3.png b/assets/images/pixelart/Flashlight_hold_3.png new file mode 100644 index 0000000..6c1ddd1 Binary files /dev/null and b/assets/images/pixelart/Flashlight_hold_3.png differ diff --git a/assets/images/pixelart/Flashlight_hold_4.png b/assets/images/pixelart/Flashlight_hold_4.png new file mode 100644 index 0000000..e3956a8 Binary files /dev/null and b/assets/images/pixelart/Flashlight_hold_4.png differ diff --git a/assets/main.assets.ron b/assets/main.assets.ron index 3b1df6a..a89d4f7 100644 --- a/assets/main.assets.ron +++ b/assets/main.assets.ron @@ -1,5 +1,6 @@ ({ "lebron": File (path: "images/KingLebron.png"), + "flash_hold_4": File (path: "images/pixelart/Flashlight_hold_4.png"), "house": File (path: "meshes/House.glb"), "library": Folder ( path: "meshes/library", diff --git a/src/asset_loading/mod.rs b/src/asset_loading/mod.rs index 04eba14..bb6316f 100644 --- a/src/asset_loading/mod.rs +++ b/src/asset_loading/mod.rs @@ -14,6 +14,7 @@ pub(super) fn plugin(app: &mut App) { .continue_to_state(GameState::Menu) .with_dynamic_assets_file::("main.assets.ron") .load_collection::() + .load_collection::() .load_collection::(), // .load_collection::() // .load_collection::() @@ -50,3 +51,9 @@ pub(crate) struct ImageAssets { #[asset(key = "lebron")] pub(crate) king: Handle, } + +#[derive(AssetCollection, Resource, Clone)] +pub(crate) struct FlashlightAssets { + #[asset(key = "flash_hold_4")] + pub(crate) flash_hold_4: Handle, +} diff --git a/src/main.rs b/src/main.rs index b09c66f..0d67feb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,10 +14,10 @@ fn main() { bevy_plugin::plugin, asset_loading::plugin, level_instantiation::map_plugin, - player::plugin, main_menu::plugin, RapierPhysicsPlugin::::default(), RapierDebugRenderPlugin::default(), + player::plugin, )) .init_state::() .add_systems(OnEnter(GameState::Playing), setup) @@ -35,19 +35,16 @@ enum GameState { Menu, } -fn debug_our_king(mut commands: Commands, images: Res) { - commands.spawn(Sprite::from_image(images.king.clone())); -} - fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, + image: Res ) { // circular base commands.spawn(( Mesh3d(meshes.add(Circle::new(4.0))), - MeshMaterial3d(materials.add(Color::WHITE)), + MeshMaterial3d(materials.add(image.king.clone())), Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)), )); commands.spawn(( diff --git a/src/player.rs b/src/player.rs index 113168d..bcead3d 100644 --- a/src/player.rs +++ b/src/player.rs @@ -1,10 +1,10 @@ use bevy::{ - input::mouse::AccumulatedMouseMotion, pbr::NotShadowCaster, prelude::*, + input::mouse::AccumulatedMouseMotion, prelude::*, render::view::RenderLayers, window::PrimaryWindow, }; use bevy_rapier3d::prelude::*; -use crate::GameState; +use crate::{asset_loading::{FlashlightAssets, ImageAssets}, GameState}; #[derive(Debug, Component)] pub struct Player; @@ -42,12 +42,9 @@ const STATIC_LAYER: usize = 1; pub fn init_player( mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, + flashlights: Res, + images: Res, ) { - let arm = meshes.add(Cuboid::new(0.1, 0.1, 0.5)); - let arm_material = materials.add(Color::WHITE); - commands .spawn(( Player, @@ -65,10 +62,6 @@ pub fn init_player( }, Transform::from_xyz(0.0, 1.0, 0.0), - GlobalTransform::default(), - Visibility::default(), - InheritedVisibility::default(), - ViewVisibility::default(), )) .with_children(|parent| { parent.spawn(( @@ -78,11 +71,6 @@ pub fn init_player( fov: 90.0_f32.to_radians(), ..default() }), - Transform::default(), - GlobalTransform::default(), - Visibility::default(), - InheritedVisibility::default(), - ViewVisibility::default(), )); // camera voor pitslampke @@ -92,31 +80,21 @@ pub fn init_player( order: 1, ..default() }, - Projection::from(PerspectiveProjection { - fov: 70.0_f32.to_radians(), - ..default() - }), RenderLayers::layer(STATIC_LAYER), - Transform::default(), - GlobalTransform::default(), - Visibility::default(), - InheritedVisibility::default(), - ViewVisibility::default(), )); // pitslampke parent.spawn(( - Mesh3d(arm), - MeshMaterial3d(arm_material), - Transform::from_xyz(0.2, -0.1, -0.25), - GlobalTransform::default(), - RenderLayers::layer(STATIC_LAYER), - NotShadowCaster, - Visibility::default(), - InheritedVisibility::default(), - ViewVisibility::default(), + Transform::from_xyz(-3.0, -3.0, 0.0), + Sprite { + image: images.king.clone(), + ..default() + }, + RenderLayers::layer(STATIC_LAYER), )); }); + + commands.spawn(Sprite::from_image(images.king.clone())); } fn hide_cursor(mut windows: Query<&mut Window, With>) {