Проектная работа - WIP

голова змеи и ее вращение
This commit is contained in:
6 changed files with 113 additions and 29 deletions
+52
View File
@@ -0,0 +1,52 @@
use std::time::Duration;
use bevy::{prelude::*, winit::WinitSettings};
use crate::domain::constants::FRAMES_PER_SECOND;
/// Инициализация игрового мира
pub fn startup(mut commands: Commands, mut winit: ResMut<WinitSettings>) {
use crate::domain::{Head, constants::HEAD_SIZE};
winit.focused_mode =
bevy::winit::UpdateMode::reactive(Duration::from_secs_f32(1. / FRAMES_PER_SECOND as f32));
winit.unfocused_mode =
bevy::winit::UpdateMode::reactive(Duration::from_secs_f32(1. / FRAMES_PER_SECOND as f32));
let head = commands
.spawn((
Head,
Sprite::from_color(
Color::srgb(1., 1., 1.),
vec2(HEAD_SIZE as f32, HEAD_SIZE as f32),
),
Transform {
translation: vec3(0., 0., 0.),
..Default::default()
},
))
.id();
commands.spawn((
Sprite::from_color(
Color::srgb(1., 0., 0.),
vec2(HEAD_SIZE as f32 * 0.3, HEAD_SIZE as f32 * 0.3),
),
Transform {
translation: vec3(HEAD_SIZE as f32 * -0.25, HEAD_SIZE as f32 * 0.25, 0.),
..Default::default()
},
ChildOf(head),
));
commands.spawn((
Sprite::from_color(
Color::srgb(0., 0., 1.),
vec2(HEAD_SIZE as f32 * 0.2, HEAD_SIZE as f32 * 0.2),
),
Transform {
translation: vec3(HEAD_SIZE as f32 * 0.25, HEAD_SIZE as f32 * 0.25, 0.),
..Default::default()
},
ChildOf(head),
));
commands.spawn(Camera2d);
}