1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
//! physme is a simple 2d and 3d physics library that doesn't aim for physical
//! accuracy, but instead for a good feel and ergonomics.  The engine provides
//! primitives and systems for all the physics goodies you'd expect:
//!
//! - Broad phase
//! - Narrow phase
//! - Manifold solving
//! - Physics step
//! - Draw transform synchronization
//!
//! Creating your first game with physme is as simple as adding one of the
//! physics plugin
//!
//! ```
//! # use bevy::prelude::*;
//! use physme::prelude2d::*;
//! let mut builder = App::build();
//! builder
//!     .add_plugin(Physics2dPlugin);
//! ```
//!
//! optionally setting some parameters
//!
//! ```
//! # use bevy::prelude::*;
//! # use physme::prelude2d::*;
//! # let mut builder = App::build();
//! # builder
//! #     .add_plugin(Physics2dPlugin)
//!     .add_resource(GlobalGravity(Vec2::new(0.0, -500.0)))
//!     .add_resource(GlobalFriction(0.90))
//!     .add_resource(GlobalStep(15.0));
//! ```
//!
//! and then, in your `setup` function, adding a `RigidBody` component to your
//! entities
//!
//! ```
//! # use bevy::prelude::*;
//! # use physme::prelude2d::*;
//! fn setup(
//!     mut commands: Commands,
//!     asset_server: Res<AssetServer>,
//!     mut materials: ResMut<Assets<ColorMaterial>>,
//! ) {
//!     let icon = asset_server.load("assets/icon.png");
//!     commands
//!         .spawn(SpriteComponents {
//!             material: materials.add(icon.into()),
//!             ..Default::default()
//!         })
//!         .with(
//!             RigidBody::new(Mass::Real(1.0))
//!                 .with_status(Status::Semikinematic)
//!                 .with_position(Vec2::new(0.0, 0.0))
//!                 .with_terminal(Vec2::new(500.0, 1000.0)),
//!         );
//! }
//! ```
//!
//! as well as some children with an arbitrary amount of  `Shape` components.
//!
//! ```
//! # use bevy::prelude::*;
//! # use physme::prelude2d::*;
//! # fn setup(
//! #     mut commands: Commands,
//! #     asset_server: Res<AssetServer>,
//! #     mut materials: ResMut<Assets<ColorMaterial>>,
//! # ) {
//! #     let icon = asset_server.load("assets/icon.png");
//! #     commands
//! #         .spawn(SpriteComponents {
//! #             material: materials.add(icon.into()),
//! #             ..Default::default()
//! #         })
//! #         .with(
//! #             RigidBody::new(Mass::Real(1.0))
//! #                 .with_status(Status::Semikinematic)
//! #                 .with_position(Vec2::new(0.0, 0.0))
//! #                 .with_terminal(Vec2::new(500.0, 1000.0)),
//! #         )
//!         .with_children(|parent| {
//!             parent.spawn((Shape::from(Size2::new(28.0, 28.0)),));
//!         });
//! # }
//! ```
//!
//! And there you go! This will perform all the physics updates on every
//! frame of the game.

pub mod common;
pub mod plugin;
pub mod bodies;
pub mod shapes;

pub mod prelude {
    //! This module re-exports all the things you might need for 2d physics
    //! simulation.
    pub use crate::common::*;
    pub use crate::plugin::{
        PhysicsSettings,
        Physics2dPlugin, 
        RotationMode, 
        TranslationMode,
    };
    // TODO Maybe restrict it a bit more?
    pub use crate::bodies::*;
    pub use crate::shapes::*;
}