The beginning of a snake

This commit is contained in:
Timothy Warren 2020-12-24 13:41:55 -05:00
parent 3218ee8307
commit e623fb6553
1 changed files with 20 additions and 1 deletions

View File

@ -1,12 +1,31 @@
use bevy::prelude::*;
fn setup(commands: &mut Commands) {
struct SnakeHead;
struct Materials {
head_material: Handle<ColorMaterial>,
}
fn setup(commands: &mut Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
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<Materials>) {
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();
}