starter with a shape

This commit is contained in:
Jonathan Jara 2025-05-02 16:19:52 -07:00
parent e3fa910bd0
commit 34079860bf
2 changed files with 16 additions and 4 deletions

View File

@ -1,15 +1,16 @@
use bevy::{color::palettes::css::{BLUE, PURPLE}, prelude::*};
use bevy::prelude::*;
pub mod shape;
fn main() {
App::new()
.insert_resource(ClearColor(Color::srgb(1.0, 1.0, 1.0)))
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, shape::display_shape)
.run();
}
fn setup(mut commands: Commands){
fn setup(mut commands: Commands,) {
commands.spawn(Camera2d);
}

11
src/shape.rs Normal file
View File

@ -0,0 +1,11 @@
use bevy::prelude::*;
pub fn display_shape(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<ColorMaterial>>) {
let shape = meshes.add(Capsule2d::new(25.0, 50.0));
let color = Color::hsl(360. * 5 as f32 / 10 as f32, 0.95, 0.7);
commands.spawn((
Mesh2d(shape),
MeshMaterial2d(materials.add(color)),
Transform::from_xyz(100.0, 0.0, 0.0)));
}