-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to apply forces on physics entities (#255)
* Add force, torque, mass, angular inertia, damping and angular damping to `Dynamics2D`
1 parent
366fb84
commit 4080759
Showing
11 changed files
with
237 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#![allow(missing_docs)] | ||
|
||
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))] | ||
pub fn main() { | ||
modor_examples::physics_2d::main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#![allow(missing_docs)] | ||
|
||
pub fn main() { | ||
modor_examples::physics_2d::main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use modor::{App, BuiltEntity}; | ||
use modor_graphics::{model_2d, window_target, Model2DMaterial, WINDOW_CAMERA_2D}; | ||
use modor_math::Vec2; | ||
use modor_physics::{Dynamics2D, Transform2D}; | ||
|
||
pub fn main() { | ||
App::new() | ||
.with_entity(modor_graphics::module()) | ||
.with_entity(window_target()) | ||
.with_entity(object()) | ||
.run(modor_graphics::runner); | ||
} | ||
|
||
fn object() -> impl BuiltEntity { | ||
model_2d(WINDOW_CAMERA_2D, Model2DMaterial::Ellipse) | ||
.updated(|t: &mut Transform2D| t.position = Vec2::new(-0.5, 0.)) | ||
.updated(|t: &mut Transform2D| t.size = Vec2::ONE * 0.04) | ||
.component(Dynamics2D::new()) | ||
.with(|d| d.velocity = Vec2::ONE * 0.3) | ||
.with(|d| d.force = -Vec2::Y * 0.2) | ||
.with(|d| d.mass = 1.) | ||
} |