Skip to content

Commit b487fac

Browse files
committed
Beginnings of a snake
1 parent d7f2637 commit b487fac

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
use bevy::prelude::*;
22

3+
const SNAKE_HEAD_COLOR: Color = Color::rgb(0.7, 0.7, 0.7);
4+
5+
#[derive(Component)]
6+
struct SnakeHead;
7+
38
fn setup_camera(mut commands: Commands) {
49
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
510
}
611

12+
fn spawn_snake(mut commands: Commands) {
13+
commands
14+
.spawn_bundle(SpriteBundle {
15+
sprite: Sprite {
16+
color: SNAKE_HEAD_COLOR,
17+
..default()
18+
},
19+
transform: Transform {
20+
scale: Vec3::new(10.0, 10.0, 10.0),
21+
..default()
22+
},
23+
..default()
24+
})
25+
.insert(SnakeHead);
26+
}
27+
728
fn main() {
829
App::new()
930
.add_startup_system(setup_camera)
31+
.add_startup_system(spawn_snake)
1032
.add_plugins(DefaultPlugins)
1133
.run();
1234
}

0 commit comments

Comments
 (0)