use bevy::prelude::*; 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(); }