|
@@ -5,7 +5,6 @@ use bevy::prelude::*;
|
|
|
use bevy::render::pass::ClearColor;
|
|
|
use rand::prelude::random;
|
|
|
|
|
|
-
|
|
|
const ARENA_WIDTH: u32 = 10;
|
|
|
const ARENA_HEIGHT: u32 = 10;
|
|
|
|
|
@@ -111,7 +110,7 @@ fn main() {
|
|
|
CoreStage::PostUpdate,
|
|
|
SystemSet::new()
|
|
|
.with_system(position_translation.system())
|
|
|
- .with_system(size_scaling.system())
|
|
|
+ .with_system(size_scaling.system()),
|
|
|
)
|
|
|
.add_system_set(
|
|
|
SystemSet::new()
|
|
@@ -131,10 +130,7 @@ fn setup(mut commands: Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-fn food_spawner(
|
|
|
- mut commands: Commands,
|
|
|
- materials: Res<Materials>,
|
|
|
-) {
|
|
|
+fn food_spawner(mut commands: Commands, materials: Res<Materials>) {
|
|
|
commands
|
|
|
.spawn_bundle(SpriteBundle {
|
|
|
material: materials.food_material.clone(),
|
|
@@ -179,21 +175,18 @@ fn spawn_snake(
|
|
|
.insert(SnakeHead {
|
|
|
direction: Direction::Up,
|
|
|
})
|
|
|
- .insert(Position { x: 3, y: 3})
|
|
|
+ .insert(Position { x: 3, y: 3 })
|
|
|
.insert(Size::square(0.8))
|
|
|
.id(),
|
|
|
spawn_segment(
|
|
|
commands,
|
|
|
&materials.segment_material,
|
|
|
- Position { x: 3, y: 2},
|
|
|
+ Position { x: 3, y: 2 },
|
|
|
),
|
|
|
]
|
|
|
}
|
|
|
|
|
|
-fn snake_movement_input(
|
|
|
- keyboard_input: Res<Input<KeyCode>>,
|
|
|
- mut heads: Query<&mut SnakeHead>,
|
|
|
-) {
|
|
|
+fn snake_movement_input(keyboard_input: Res<Input<KeyCode>>, mut heads: Query<&mut SnakeHead>) {
|
|
|
if let Some(mut head) = heads.iter_mut().next() {
|
|
|
let dir = if keyboard_input.pressed(KeyCode::Left) {
|
|
|
Direction::Left
|