-
-
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.
dev: the basics are still kicking my ass
- Loading branch information
1 parent
8638309
commit d2a9fbc
Showing
14 changed files
with
269 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
# Physics | ||
- [ ] Spawn a central body and an orbiting body. | ||
- [ ] Speed up or slow down the simulation clock. | ||
|
||
# UI | ||
- [ ] Add panning and zooming to the camera. | ||
- [ ] Allow the camera to follow an entity, and to change which entity is followed. | ||
|
||
# Config | ||
- [ ] Set up systems to save and load scenes as RON files. | ||
|
||
# Docs | ||
- [ ] Take a look at [mdBook](https://github.com/rust-lang/mdBook) as an alternative to in-code docs. |
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,46 @@ | ||
use avian2d::prelude::*; | ||
use bevy::prelude::*; | ||
use bevy_prototype_lyon::prelude::*; | ||
|
||
#[derive(Component)] | ||
pub struct Planetoid; | ||
|
||
#[derive(Bundle)] | ||
pub struct PlanetoidBundle { | ||
physics_body: RigidBody, | ||
collider_shape: Collider, | ||
graphics_shape: ShapeBundle, | ||
fill: Fill, | ||
} | ||
|
||
impl Default for PlanetoidBundle { | ||
fn default() -> Self { | ||
let default_radius = 10.0; | ||
Self::from_radius(default_radius) | ||
} | ||
} | ||
|
||
impl PlanetoidBundle { | ||
pub fn from_radius(radius: f32) -> Self { | ||
let points = [ | ||
Vec2::new(1.0, -1.0), | ||
Vec2::new(1.0, 1.0), | ||
Vec2::new(-1.0, 1.0), | ||
Vec2::new(-1.0, -1.0), | ||
].map(|x| x * radius); | ||
let shape = shapes::RoundedPolygon { | ||
points: points.into_iter().collect(), | ||
radius: radius, | ||
..default() | ||
}; | ||
PlanetoidBundle { | ||
physics_body: RigidBody::Dynamic, | ||
collider_shape: Collider::circle(radius), | ||
graphics_shape: ShapeBundle { | ||
path: GeometryBuilder::build_as(&shape), | ||
..default() | ||
}, | ||
fill: Fill::color(bevy::color::palettes::basic::WHITE), | ||
} | ||
} | ||
} |
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,8 @@ | ||
use bevy::prelude::*; | ||
use bevy_prototype_lyon::plugin::ShapePlugin; | ||
|
||
pub mod bodies; | ||
|
||
pub(super) fn plugin(app: &mut App) { | ||
app.add_plugins(ShapePlugin); | ||
} |
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
File renamed without changes.
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,9 @@ | ||
use avian2d::prelude::*; | ||
use bevy::prelude::*; | ||
|
||
pub(super) fn plugin(app: &mut App) { | ||
app.add_plugins(PhysicsPlugins::default().with_length_unit(1.0)); | ||
|
||
// we will handle gravity ourselves | ||
app.insert_resource(Gravity(Vec2::ZERO.into())); | ||
} |
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,21 @@ | ||
use crate::components::bodies::PlanetoidBundle; | ||
use bevy::prelude::*; | ||
|
||
pub(super) fn plugin(app: &mut App) { | ||
app.add_event::<SpawnPlanetoid>(); | ||
app.add_systems(Update, spawn_planetoid); | ||
} | ||
|
||
#[derive(Event)] | ||
pub struct SpawnPlanetoid { | ||
pub position: Vec2, | ||
pub velocity: Vec2, | ||
pub mass: f32, | ||
pub radius: f32, | ||
} | ||
|
||
fn spawn_planetoid(mut commands: Commands, mut events: EventReader<SpawnPlanetoid>) { | ||
for e in events.read(){ | ||
commands.spawn(PlanetoidBundle::from_radius(e.radius)); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,19 +1,15 @@ | ||
use bevy::prelude::*; | ||
use bevy_mod_picking::prelude::*; | ||
|
||
pub struct CursorPlugin; | ||
|
||
impl Plugin for CursorPlugin { | ||
fn build(&self, app: &mut App) { | ||
let debug_level: DebugPickingMode; | ||
#[cfg(not(feature = "dev"))] | ||
{ | ||
debug_level = DebugPickingMode::Disabled; | ||
} | ||
#[cfg(feature = "dev")] | ||
{ | ||
debug_level = DebugPickingMode::Normal; | ||
} | ||
app.add_plugins(DefaultPickingPlugins).insert_resource(debug_level); | ||
pub(super) fn plugin(app: &mut App) { | ||
let debug_level: DebugPickingMode; | ||
#[cfg(not(feature = "dev"))] | ||
{ | ||
debug_level = DebugPickingMode::Disabled; | ||
} | ||
#[cfg(feature = "dev")] | ||
{ | ||
debug_level = DebugPickingMode::Normal; | ||
} | ||
app.add_plugins(DefaultPickingPlugins).insert_resource(debug_level); | ||
} |
Oops, something went wrong.