Проектная работа - MVP
Создание нового проекта
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/// Эксперименты в ходе прохождения туториала:
|
||||
/// https://github.com/fogarecious/bevy_tutorial
|
||||
use bevy::{prelude::*, winit::WinitSettings};
|
||||
use tracing::Level;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
// .add_plugins(MinimalPlugins)
|
||||
.add_plugins(
|
||||
DefaultPlugins
|
||||
.build()
|
||||
.set(bevy::log::LogPlugin {
|
||||
level: Level::INFO,
|
||||
filter: "wgpu_hal=warn,bevy_learning=trace".to_string(),
|
||||
// fmt_layer: |_| snake_game::define_log_layer(),
|
||||
..Default::default()
|
||||
})
|
||||
.set(TaskPoolPlugin {
|
||||
task_pool_options: TaskPoolOptions::with_num_threads(1),
|
||||
}),
|
||||
)
|
||||
.insert_resource(WinitSettings::desktop_app())
|
||||
.insert_resource(ClearColor(Color::srgb(0.3, 0.6, 0.8)))
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(PostStartup, (print_all_entities, inspect))
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, _window: Query<&Window>, _world: &World) {
|
||||
let _window = _window.single().unwrap();
|
||||
|
||||
let _root = commands
|
||||
.spawn((
|
||||
Sprite::from_color(Color::srgb(1., 1., 1.), Vec2::new(100., 100.)),
|
||||
Transform {
|
||||
translation: vec3(0., 0., 0.),
|
||||
// scale: Vec3::new(1., 1., 1.),
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.id();
|
||||
let _red = commands
|
||||
.spawn((
|
||||
Sprite::from_color(Color::srgb(1., 0., 0.), Vec2::new(30., 30.)),
|
||||
Transform {
|
||||
translation: vec3(-20., 30., 0.),
|
||||
..Default::default()
|
||||
},
|
||||
ChildOf(_root),
|
||||
))
|
||||
.id();
|
||||
let _blue = commands
|
||||
.spawn((
|
||||
Sprite::from_color(Color::srgb(0., 0., 1.), Vec2::new(20., 20.)),
|
||||
Transform {
|
||||
translation: vec3(20., 30., 0.),
|
||||
..Default::default()
|
||||
},
|
||||
ChildOf(_root),
|
||||
))
|
||||
.id();
|
||||
|
||||
commands.spawn(Camera2d);
|
||||
}
|
||||
|
||||
fn print_all_entities(mut commands: Commands, query: Query<Entity>) {
|
||||
for entity in query {
|
||||
commands.entity(entity).log_components();
|
||||
}
|
||||
}
|
||||
|
||||
fn inspect(mut _commands: Commands, _query: Query<Entity>) {}
|
||||
Reference in New Issue
Block a user