fly_b/simul/motion/
compos.rs1pub mod velocity {
2 use bevy::prelude::*;
3 use derive_more::{Deref, DerefMut, From, Into};
4
5 #[derive(Default, Clone, Copy, From, Component, Reflect, Debug, Deref, DerefMut, Into)]
6 #[reflect(Component)]
7 pub struct Velocity(Vec2);
8
9 impl From<[f32; 2]> for Velocity {
10 fn from([x, y]: [f32; 2]) -> Self {
11 Vec2::new(x, y).into()
12 }
13 }
14
15 impl Into<[f32; 2]> for Velocity {
16 fn into(self) -> [f32; 2] {
17 Vec2::from(self).into()
18 }
19 }
20}
21pub mod acceleration {
22 use bevy::prelude::*;
23 use derive_more::{Deref, DerefMut, From, Into};
24
25 #[derive(Default, Clone, Copy, From, Component, Reflect, Debug, Deref, DerefMut, Into)]
26 #[reflect(Component)]
27 pub struct Acceleration(Vec2);
28
29 impl From<[f32; 2]> for Acceleration {
30 fn from([x, y]: [f32; 2]) -> Self {
31 Vec2::new(x, y).into()
32 }
33 }
34
35 impl Into<[f32; 2]> for Acceleration {
36 fn into(self) -> [f32; 2] {
37 Vec2::from(self).into()
38 }
39 }
40}
41pub mod gravitation {
42 use bevy::prelude::*;
43
44 #[derive(Default, Clone, Copy, Component, Reflect, Debug)]
45 #[reflect(Component)]
46 pub struct Gravitation;
47}