From 9af3c65ee2c4cafa80ac51ef281bfd11a3e932c8 Mon Sep 17 00:00:00 2001 From: AmadeusWM <63149896+AmadeusWM@users.noreply.github.com> Date: Sat, 5 Apr 2025 15:49:23 +0200 Subject: [PATCH] new main --- src/main.rs | 72 +++++++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 49 deletions(-) diff --git a/src/main.rs b/src/main.rs index 90eb67a..c3517f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,58 +1,32 @@ -//! Illustrates the use of vertex colors. +use bevy::prelude::*; +use blenvy::*; -use bevy::{prelude::*, render::mesh::VertexAttributeValues}; - -fn main() { +fn main() -> AppExit { App::new() - .add_plugins(DefaultPlugins) + .add_plugins((DefaultPlugins, BlenvyPlugin::default())) + // We need to register components to make them visible to Blenvy + .register_type::() .add_systems(Startup, setup) - .run(); + .run() } -/// set up a simple 3D scene -fn setup( - mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, -) { - // plane - commands.spawn(( - Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))), - MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))), - )); - // cube - // Assign vertex colors based on vertex positions - let mut colorful_cube = Mesh::from(Cuboid::default()); - if let Some(VertexAttributeValues::Float32x3(positions)) = - colorful_cube.attribute(Mesh::ATTRIBUTE_POSITION) - { - let colors: Vec<[f32; 4]> = positions - .iter() - .map(|[r, g, b]| [(1. - *r) / 2., (1. - *g) / 2., (1. - *b) / 2., 1.]) - .collect(); - colorful_cube.insert_attribute(Mesh::ATTRIBUTE_COLOR, colors); - } - commands.spawn(( - Mesh3d(meshes.add(colorful_cube)), - // This is the default color, but note that vertex colors are - // multiplied by the base color, so you'll likely want this to be - // white if using vertex colors. - MeshMaterial3d(materials.add(Color::srgb(1., 1., 1.))), - Transform::from_xyz(0.0, 0.5, 0.0), - )); +#[derive(Component, Reflect)] +#[reflect(Component)] +struct Player { + strength: f32, + perception: f32, + endurance: f32, + charisma: f32, + intelligence: f32, + agility: f32, + luck: f32, +} - // Light +fn setup(mut commands: Commands) { commands.spawn(( - PointLight { - shadows_enabled: true, - ..default() - }, - Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), - )); - - // Camera - commands.spawn(( - Camera3d::default(), - Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + BlueprintInfo::from_path("levels/World.glb"), + SpawnBlueprint, + HideUntilReady, + GameWorldTag, )); }