Проектная работа - WIP
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
/// ДЛЯ ОТЛАДКИ - вывод всех сущностей мира
|
||||
pub fn print_all_entities(mut commands: Commands, query: Query<Entity>) {
|
||||
for entity in query {
|
||||
commands.entity(entity).log_components();
|
||||
}
|
||||
}
|
||||
|
||||
/// ДЛЯ ОТЛАДКИ - вывод всех сущностей мира по нажатию Enter
|
||||
pub fn print_all_entities_by_press_enter(
|
||||
input: Res<ButtonInput<KeyCode>>,
|
||||
mut commands: Commands,
|
||||
query: Query<Entity>,
|
||||
) {
|
||||
if input.just_pressed(KeyCode::Enter) {
|
||||
for entity in query {
|
||||
commands.entity(entity).log_components();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Координатная сетка
|
||||
#[derive(Component)]
|
||||
pub struct Grid;
|
||||
|
||||
/// Создать координатную сетку
|
||||
pub fn spawn_grid(commands: &mut Commands) {
|
||||
use crate::domain::GRID_SIZE;
|
||||
|
||||
let grid = commands
|
||||
.spawn((Grid, Transform::default(), Visibility::default()))
|
||||
.id();
|
||||
|
||||
for x in -20..=20 {
|
||||
commands.spawn((
|
||||
Sprite::from_color(Color::srgb(1.0, 1.0, 0.5), vec2(0.5, 2000.0)),
|
||||
Transform {
|
||||
translation: vec3(x as f32 * GRID_SIZE as f32, 0.0, -1.0),
|
||||
..Default::default()
|
||||
},
|
||||
ChildOf(grid),
|
||||
));
|
||||
}
|
||||
for y in -20..=20 {
|
||||
commands.spawn((
|
||||
Sprite::from_color(Color::srgb(1.0, 1.0, 0.5), vec2(2000.0, 0.5)),
|
||||
Transform {
|
||||
translation: vec3(0.0, y as f32 * GRID_SIZE as f32, -1.0),
|
||||
..Default::default()
|
||||
},
|
||||
ChildOf(grid),
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user