From e623fb6553df03d3fde445f8e4092851a1961e5a Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 24 Dec 2020 13:41:55 -0500 Subject: [PATCH] The beginning of a snake --- src/main.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c40348c..73f0e36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,31 @@ use bevy::prelude::*; -fn setup(commands: &mut Commands) { +struct SnakeHead; +struct Materials { + head_material: Handle, +} + +fn setup(commands: &mut Commands, mut materials: ResMut>) { commands.spawn(Camera2dBundle::default()); + commands.insert_resource(Materials { + head_material: materials.add(Color::rgb(0.7, 0.7, 0.7).into()), + }); +} + +fn spawn_snake(commands: &mut Commands, materials: Res) { + commands + .spawn(SpriteBundle { + material: materials.head_material.clone(), + sprite: Sprite::new(Vec2::new(10.0, 10.0)), + ..Default::default() + }) + .with(SnakeHead); } fn main() { App::build() .add_startup_system(setup.system()) + .add_startup_stage("game_setup", SystemStage::single(spawn_snake.system())) .add_plugins(DefaultPlugins) .run(); }