From 676dbf0a96f92ec48e8cc0175c20396c9bd7a921 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 5 Nov 2020 11:09:57 -0500 Subject: [PATCH] Add the tail --- src/main.rs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 491723d..f1801f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,10 +43,11 @@ impl Direction { } } } +struct SegmentMaterial(Handle); #[derive(Default)] struct SnakeSegment { - next_segment: Option + next_segment: Option, } struct SnakeHead { @@ -56,6 +57,17 @@ struct SnakeHead { struct SnakeMoveTimer(Timer); struct HeadMaterial(Handle); +fn spawn_segment(commands: &mut Commands, material: Handle, position: Position) { + commands + .spawn(SpriteComponents { + material, + ..Default::default() + }) + .with(SnakeSegment { next_segment: None }) + .with(position) + .with(Size::square(0.65)); +} + fn snake_movement( time: Res