The beginning of a snake
This commit is contained in:
parent
3218ee8307
commit
e623fb6553
21
src/main.rs
21
src/main.rs
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user