This commit is contained in:
Back777space
2025-04-06 00:04:50 +02:00
parent eeae924c8d
commit 4073a2675a
14 changed files with 23 additions and 40 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,5 +1,6 @@
({ ({
"lebron": File (path: "images/KingLebron.png"), "lebron": File (path: "images/KingLebron.png"),
"flash_hold_4": File (path: "images/pixelart/Flashlight_hold_4.png"),
"house": File (path: "meshes/House.glb"), "house": File (path: "meshes/House.glb"),
"library": Folder ( "library": Folder (
path: "meshes/library", path: "meshes/library",

View File

@@ -14,6 +14,7 @@ pub(super) fn plugin(app: &mut App) {
.continue_to_state(GameState::Menu) .continue_to_state(GameState::Menu)
.with_dynamic_assets_file::<StandardDynamicAssetCollection>("main.assets.ron") .with_dynamic_assets_file::<StandardDynamicAssetCollection>("main.assets.ron")
.load_collection::<ImageAssets>() .load_collection::<ImageAssets>()
.load_collection::<FlashlightAssets>()
.load_collection::<GltfAssets>(), .load_collection::<GltfAssets>(),
// .load_collection::<AudioAssets>() // .load_collection::<AudioAssets>()
// .load_collection::<TextureAssets>() // .load_collection::<TextureAssets>()
@@ -50,3 +51,9 @@ pub(crate) struct ImageAssets {
#[asset(key = "lebron")] #[asset(key = "lebron")]
pub(crate) king: Handle<Image>, pub(crate) king: Handle<Image>,
} }
#[derive(AssetCollection, Resource, Clone)]
pub(crate) struct FlashlightAssets {
#[asset(key = "flash_hold_4")]
pub(crate) flash_hold_4: Handle<Image>,
}

View File

@@ -14,10 +14,10 @@ fn main() {
bevy_plugin::plugin, bevy_plugin::plugin,
asset_loading::plugin, asset_loading::plugin,
level_instantiation::map_plugin, level_instantiation::map_plugin,
player::plugin,
main_menu::plugin, main_menu::plugin,
RapierPhysicsPlugin::<NoUserData>::default(), RapierPhysicsPlugin::<NoUserData>::default(),
RapierDebugRenderPlugin::default(), RapierDebugRenderPlugin::default(),
player::plugin,
)) ))
.init_state::<GameState>() .init_state::<GameState>()
.add_systems(OnEnter(GameState::Playing), setup) .add_systems(OnEnter(GameState::Playing), setup)
@@ -35,19 +35,16 @@ enum GameState {
Menu, Menu,
} }
fn debug_our_king(mut commands: Commands, images: Res<ImageAssets>) {
commands.spawn(Sprite::from_image(images.king.clone()));
}
fn setup( fn setup(
mut commands: Commands, mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>, mut materials: ResMut<Assets<StandardMaterial>>,
image: Res<ImageAssets>
) { ) {
// circular base // circular base
commands.spawn(( commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))), 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)), Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
)); ));
commands.spawn(( commands.spawn((

View File

@@ -1,10 +1,10 @@
use bevy::{ use bevy::{
input::mouse::AccumulatedMouseMotion, pbr::NotShadowCaster, prelude::*, input::mouse::AccumulatedMouseMotion, prelude::*,
render::view::RenderLayers, window::PrimaryWindow, render::view::RenderLayers, window::PrimaryWindow,
}; };
use bevy_rapier3d::prelude::*; use bevy_rapier3d::prelude::*;
use crate::GameState; use crate::{asset_loading::{FlashlightAssets, ImageAssets}, GameState};
#[derive(Debug, Component)] #[derive(Debug, Component)]
pub struct Player; pub struct Player;
@@ -42,12 +42,9 @@ const STATIC_LAYER: usize = 1;
pub fn init_player( pub fn init_player(
mut commands: Commands, mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>, flashlights: Res<FlashlightAssets>,
mut materials: ResMut<Assets<StandardMaterial>>, images: Res<ImageAssets>,
) { ) {
let arm = meshes.add(Cuboid::new(0.1, 0.1, 0.5));
let arm_material = materials.add(Color::WHITE);
commands commands
.spawn(( .spawn((
Player, Player,
@@ -65,10 +62,6 @@ pub fn init_player(
}, },
Transform::from_xyz(0.0, 1.0, 0.0), Transform::from_xyz(0.0, 1.0, 0.0),
GlobalTransform::default(),
Visibility::default(),
InheritedVisibility::default(),
ViewVisibility::default(),
)) ))
.with_children(|parent| { .with_children(|parent| {
parent.spawn(( parent.spawn((
@@ -78,11 +71,6 @@ pub fn init_player(
fov: 90.0_f32.to_radians(), fov: 90.0_f32.to_radians(),
..default() ..default()
}), }),
Transform::default(),
GlobalTransform::default(),
Visibility::default(),
InheritedVisibility::default(),
ViewVisibility::default(),
)); ));
// camera voor pitslampke // camera voor pitslampke
@@ -92,31 +80,21 @@ pub fn init_player(
order: 1, order: 1,
..default() ..default()
}, },
Projection::from(PerspectiveProjection {
fov: 70.0_f32.to_radians(),
..default()
}),
RenderLayers::layer(STATIC_LAYER), RenderLayers::layer(STATIC_LAYER),
Transform::default(),
GlobalTransform::default(),
Visibility::default(),
InheritedVisibility::default(),
ViewVisibility::default(),
)); ));
// pitslampke // pitslampke
parent.spawn(( parent.spawn((
Mesh3d(arm), Transform::from_xyz(-3.0, -3.0, 0.0),
MeshMaterial3d(arm_material), Sprite {
Transform::from_xyz(0.2, -0.1, -0.25), image: images.king.clone(),
GlobalTransform::default(), ..default()
RenderLayers::layer(STATIC_LAYER), },
NotShadowCaster, RenderLayers::layer(STATIC_LAYER),
Visibility::default(),
InheritedVisibility::default(),
ViewVisibility::default(),
)); ));
}); });
commands.spawn(Sprite::from_image(images.king.clone()));
} }
fn hide_cursor(mut windows: Query<&mut Window, With<PrimaryWindow>>) { fn hide_cursor(mut windows: Query<&mut Window, With<PrimaryWindow>>) {