Skip to content

Commit

Permalink
Display snake head
Browse files Browse the repository at this point in the history
  • Loading branch information
merwan committed Jul 7, 2024
1 parent cf309ed commit 9229f61
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
use bevy::prelude::*;

#[derive(Component)]
struct SnakeHead;

const SNAKE_HEAD_COLOR: Color = Color::srgb(0.7, 0.7, 0.7);

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup_camera)
.add_systems(Startup, (setup_camera, spawn_snake))
.run();
}

fn setup_camera(mut commands: Commands) {
commands.spawn(Camera2dBundle {..default()});
commands.spawn(Camera2dBundle { ..default() });
}

fn spawn_snake(mut commands: Commands) {
commands
.spawn(SpriteBundle {
sprite: Sprite {
color: SNAKE_HEAD_COLOR,
..default()
},
transform: Transform {
scale: Vec3::new(10.0, 10.0, 10.0),
..default()
},
..default()
})
.insert(SnakeHead);
}

0 comments on commit 9229f61

Please sign in to comment.