Skip to content

Commit

Permalink
docs(examples): Add a debug example (jcornaz#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornaz authored Mar 1, 2021
1 parent 9f5ce0d commit 2dd2e23
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ bevy = "0.4"
name = "demo"
required-features = ["2d"]

[[example]]
name = "debug"
required-features = ["2d", "debug"]

[[package.metadata.release.pre-release-replacements]]
file = "CHANGELOG.md"
search = "## \\[Unreleased\\]"
Expand Down
44 changes: 44 additions & 0 deletions examples/debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use bevy::prelude::*;

use heron::*;

fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(PhysicsPlugin::default()) // Add the plugin
.add_startup_system(spawn.system())
.run();
}

fn spawn(commands: &mut Commands) {
commands.spawn(Camera2dBundle::default());

// Sphere
commands
.spawn((Transform::default(), GlobalTransform::default()))
.with(Body::Sphere { radius: 50.0 })
.with(BodyType::Static);

// Cuboid
commands
.spawn((
Transform::from_translation(Vec3::unit_x() * 300.0),
GlobalTransform::default(),
))
.with(Body::Cuboid {
half_extends: Vec2::new(50.0, 50.0).extend(0.0),
})
.with(BodyType::Static);

// Capsule
commands
.spawn((
Transform::from_translation(Vec3::unit_x() * -300.0),
GlobalTransform::default(),
))
.with(Body::Capsule {
radius: 50.0,
half_segment: 50.0,
})
.with(BodyType::Static);
}

0 comments on commit 2dd2e23

Please sign in to comment.