Проектная работа - WIP
This commit is contained in:
+12
-17
@@ -1,7 +1,7 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
domain::{End, SnakePath, Tail},
|
||||
domain::{End, GridBarier, SnakePath, Tail},
|
||||
observers::{cleanup_snake_path, schedule_set_velocity, tail_observer},
|
||||
};
|
||||
|
||||
@@ -20,16 +20,20 @@ fn spawn_snake(commands: &mut Commands) {
|
||||
commands.insert_resource(SnakePath::default());
|
||||
commands.spawn(Observer::new(cleanup_snake_path));
|
||||
|
||||
commands.spawn(Observer::new(|e: On<GridBarier>| {
|
||||
let entity = e.entity;
|
||||
let src = e.src_pos;
|
||||
let dst = e.dst_pos;
|
||||
trace!("...<{entity:?}> moving {src:>16} => {dst:>16}");
|
||||
}));
|
||||
|
||||
let head = commands
|
||||
.spawn((
|
||||
Head,
|
||||
Direction::default(),
|
||||
Inert::default(),
|
||||
Velocity(SNAKE_VELOCITY as f32),
|
||||
Sprite::from_color(
|
||||
Color::srgb(1., 1., 1.),
|
||||
vec2(HEAD_SIZE as f32, HEAD_SIZE as f32),
|
||||
),
|
||||
Sprite::from_color(Color::srgb(1., 1., 1.), vec2(HEAD_SIZE as f32, HEAD_SIZE as f32)),
|
||||
Transform {
|
||||
translation: vec3(0.0, 0.0, 1.0),
|
||||
..Default::default()
|
||||
@@ -37,10 +41,7 @@ fn spawn_snake(commands: &mut Commands) {
|
||||
))
|
||||
.id();
|
||||
commands.spawn((
|
||||
Sprite::from_color(
|
||||
Color::srgb(1., 0., 0.),
|
||||
vec2(HEAD_SIZE as f32 * 0.3, HEAD_SIZE as f32 * 0.3),
|
||||
),
|
||||
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, 1.0),
|
||||
..Default::default()
|
||||
@@ -48,10 +49,7 @@ fn spawn_snake(commands: &mut Commands) {
|
||||
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),
|
||||
),
|
||||
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, 1.0),
|
||||
..Default::default()
|
||||
@@ -66,10 +64,7 @@ fn spawn_snake(commands: &mut Commands) {
|
||||
Direction::default(),
|
||||
Inert::default(),
|
||||
Velocity(0.0),
|
||||
Sprite::from_color(
|
||||
Color::srgb(0.7, 0.7, 0.7),
|
||||
vec2(HEAD_SIZE as f32 * 0.8, HEAD_SIZE as f32 * 0.8),
|
||||
),
|
||||
Sprite::from_color(Color::srgb(0.7, 0.7, 0.7), vec2(HEAD_SIZE as f32 * 0.8, HEAD_SIZE as f32 * 0.8)),
|
||||
Transform {
|
||||
translation: vec3(0.0, 0.0, 0.0),
|
||||
..Default::default()
|
||||
|
||||
Reference in New Issue
Block a user