From eca6422f71b5811a535b3330fb7d58c02d9b1e55 Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Mon, 15 Jun 2026 16:30:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20-=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snake-game/src/game/core.rs | 90 ------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 snake-game/src/game/core.rs diff --git a/snake-game/src/game/core.rs b/snake-game/src/game/core.rs deleted file mode 100644 index 091891f..0000000 --- a/snake-game/src/game/core.rs +++ /dev/null @@ -1,90 +0,0 @@ -use bevy::{color::palettes::tailwind::*, prelude::*}; - -use crate::{ - domain::{End, FIELD_SIZE, GRID_SIZE, Tail}, - observers::schedule_set_velocity, -}; - -/// Создать границу игрового поля -pub fn spawn_bounds(commands: &mut Commands) { - commands.spawn(( - Sprite::from_color(AMBER_500, vec2((FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32, 5.0)), // - Transform { - translation: vec3(0.0, (FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32 / 2.0, 0.0), - ..Default::default() - }, - )); - commands.spawn(( - Sprite::from_color(AMBER_500, vec2((FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32, 5.0)), // - Transform { - translation: vec3(0.0, -(FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32 / 2.0, 0.0), - ..Default::default() - }, - )); - commands.spawn(( - Sprite::from_color(AMBER_500, vec2(5.0, (FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32)), // - Transform { - translation: vec3((FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32 / 2.0, 0.0, 0.0), - ..Default::default() - }, - )); - commands.spawn(( - Sprite::from_color(AMBER_500, vec2(5.0, (FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32)), // - Transform { - translation: vec3(-(FIELD_SIZE as f32 + 1.0) * GRID_SIZE as f32 / 2.0, 0.0, 0.0), - ..Default::default() - }, - )); -} - -/// Создать змейку -pub fn spawn_snake(commands: &mut Commands) { - use crate::domain::{Direction, HEAD_SIZE, Head, SNAKE_VELOCITY, Velocity}; - - commands.spawn(Observer::new(crate::debug::trace_snake_moving)); - commands.spawn(Observer::new(crate::observers::handle_collisions)); - - let head = commands - .spawn(( - Head(Direction::default()), - Direction::default(), - Velocity(SNAKE_VELOCITY 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() - }, - )) - .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, 1.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, 1.0), - ..Default::default() - }, - ChildOf(head), - )); - - let tail = commands - .spawn(( - Tail(head), - End, - Direction::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)), - Transform { - translation: vec3(0.0, 0.0, 0.0), - ..Default::default() - }, - )) - .id(); - commands.entity(head).observe(schedule_set_velocity(tail)); -}