From fc423310557d7d918b840248469b2fdb9a7592b4 Mon Sep 17 00:00:00 2001 From: "a.yamaev" Date: Tue, 5 Dec 2023 15:58:11 +0300 Subject: [PATCH] Dog movement --- src/lib.rs | 13 ++++ src/physics.rs | 19 +++++ src/player.rs | 178 ++++++++++++++++++++++++++++++++++++++++++++++ src/test_level.rs | 7 ++ 4 files changed, 217 insertions(+) create mode 100644 src/physics.rs create mode 100644 src/player.rs diff --git a/src/lib.rs b/src/lib.rs index f4c02e1..6baad67 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,10 @@ pub mod debug_diagnostic; pub mod test_level; +pub mod player; +pub mod physics; + +use std::f32::consts::PI; use bevy::app::App; #[cfg(debug_assertions)] @@ -34,6 +38,15 @@ impl Plugin for GamePlugin { app.add_plugins((FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default())); } + app.add_plugins(( + player::PlayerPlugin, + physics::PhysicsPlugin, + )); + app.add_systems(Startup, test_level::setup); } } + +pub fn get_sprite_rotation() -> Quat { + Quat::from_euler(EulerRot::XYZ, PI / 2.0 - PI / 4.0, 0.0, 0.0) +} \ No newline at end of file diff --git a/src/physics.rs b/src/physics.rs new file mode 100644 index 0000000..e27b241 --- /dev/null +++ b/src/physics.rs @@ -0,0 +1,19 @@ +use bevy::prelude::*; + + +pub struct PhysicsPlugin; + +impl Plugin for PhysicsPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Update, apply_velocity); + } +} + +#[derive(Component, Default)] +pub struct Velocity(pub Vec3); + +fn apply_velocity(mut query: Query<(&Velocity, &mut Transform)>, time: Res