mirror of
https://github.com/bevyengine/bevy
synced 2024-11-30 00:20:20 +00:00
43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
|
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
||
|
|
||
|
fn main() {
|
||
|
App::new()
|
||
|
.add_plugins(DefaultPlugins)
|
||
|
.add_startup_system(setup)
|
||
|
.run();
|
||
|
}
|
||
|
|
||
|
fn setup(
|
||
|
mut commands: Commands,
|
||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||
|
) {
|
||
|
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
|
||
|
|
||
|
// Rectangle
|
||
|
commands.spawn_bundle(SpriteBundle {
|
||
|
sprite: Sprite {
|
||
|
color: Color::rgb(0.25, 0.25, 0.75),
|
||
|
custom_size: Some(Vec2::new(50.0, 100.0)),
|
||
|
..default()
|
||
|
},
|
||
|
..default()
|
||
|
});
|
||
|
|
||
|
// Circle
|
||
|
commands.spawn_bundle(MaterialMesh2dBundle {
|
||
|
mesh: meshes.add(shape::Circle::new(50.).into()).into(),
|
||
|
material: materials.add(ColorMaterial::from(Color::PURPLE)),
|
||
|
transform: Transform::from_translation(Vec3::new(-100., 0., 0.)),
|
||
|
..default()
|
||
|
});
|
||
|
|
||
|
// Hexagon
|
||
|
commands.spawn_bundle(MaterialMesh2dBundle {
|
||
|
mesh: meshes.add(shape::RegularPolygon::new(50., 6).into()).into(),
|
||
|
material: materials.add(ColorMaterial::from(Color::TURQUOISE)),
|
||
|
transform: Transform::from_translation(Vec3::new(100., 0., 0.)),
|
||
|
..default()
|
||
|
});
|
||
|
}
|