diff --git a/app/src/main.rs b/app/src/main.rs index f85f667..70ddcaa 100644 --- a/app/src/main.rs +++ b/app/src/main.rs @@ -2,12 +2,13 @@ use bevy::color::palettes::basic::RED; use bevy::log; use bevy::prelude::*; // Core Bevy types +const GRAVITY: f32 = -20.0; fn main() { App::new() .add_plugins(DefaultPlugins) .add_systems(Startup, setup) - .add_systems(Update, velocity_timestep) + .add_systems(Update, (apply_gravity, velocity_timestep).chain()) .run(); } @@ -17,10 +18,17 @@ fn setup(mut commands: Commands, mut meshes: ResMut>, mut materials let shape =meshes.add(Circle::new(50.0)); - commands.spawn((Mesh2d(shape.clone()), MeshMaterial2d(materials.add(Color::from(RED))), Transform::from_xyz(100.0, 0.0, 0.0), Velocity(vec3(0.0, 100.0, 0.0)))); + commands.spawn((Mesh2d(shape.clone()), MeshMaterial2d(materials.add(Color::from(RED))), Transform::from_xyz(100.0, 0.0, 0.0), Velocity(vec3( + 0.0, + 100.0, + 0.0 + )))); - commands.spawn((Mesh2d(shape.clone()), MeshMaterial2d(materials.add(Color::from(RED))), Transform::from_xyz(0.0, 0.0, 0.0), Velocity(vec3(0.0, 100.0, 0.0)))); -} + commands.spawn((Mesh2d(shape.clone()), MeshMaterial2d(materials.add(Color::from(RED))), Transform::from_xyz(300.0, 0.0, 0.0), Velocity(vec3( + 0.0, + 50.0, + 0.0 + ))));} #[derive(Component)] struct Velocity(Vec3); @@ -29,4 +37,10 @@ fn velocity_timestep(time: Res