Skip to content

Commit

Permalink
compartmentalise all code into core, ui and world modules
Browse files Browse the repository at this point in the history
  • Loading branch information
thombruce committed Oct 10, 2023
1 parent baf3685 commit 11e6f4e
Show file tree
Hide file tree
Showing 29 changed files with 42 additions and 38 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Separate nav and speedometer UI features into own modules
- Open game centered on primary monitor
- Hide cursor
- Compartmentalise main plugins into core, ui and world modules
- Compartmentalise code into core, ui and world modules

## [0.0.13] - 2023-10-10

Expand Down
2 changes: 1 addition & 1 deletion src/effects/animate.rs → src/core/effects/animate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::prelude::*;

use crate::resources::state::GameState;
use super::super::resources::state::GameState;

pub struct AnimatePlugin;
impl Plugin for AnimatePlugin {
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use bevy::prelude::*;

use crate::{
pub mod effects;
pub mod resources;

use self::{
effects::{animate::AnimatePlugin, blink::EffectsPlugin},
resources::{game_time::GameTimePlugin, state::StatePlugin},
};
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{prelude::*, time::Stopwatch};

use crate::resources::state::GameState;
use super::state::GameState;

#[derive(Resource, Deref)]
pub struct GameTime(Stopwatch);
Expand Down
2 changes: 0 additions & 2 deletions src/resources/mod.rs → src/core/resources/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub mod assets;
pub mod camera;
pub mod game_time;
pub mod spatial;
pub mod state;
2 changes: 1 addition & 1 deletion src/resources/state.rs → src/core/resources/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy::{
prelude::*,
};

use crate::resources::assets::AudioAssets;
use super::assets::AudioAssets;

#[derive(States, Debug, Copy, Clone, Hash, Eq, PartialEq, Default)]
pub enum GameState {
Expand Down
10 changes: 2 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@ use bevy_asset_loader::prelude::*;
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_rapier2d::prelude::*;

mod astronomy;
mod core;
mod effects;
mod hud;
mod menus;
mod resources;
mod shaders;
mod ship;
mod ui;
mod world;

use crate::{
core::CorePlugin,
resources::{
core::resources::{
assets::{AudioAssets, SpriteAssets, UiAssets},
state::GameState,
},
core::CorePlugin,
ui::UiPlugin,
world::WorldPlugin,
};
Expand Down
2 changes: 1 addition & 1 deletion src/resources/camera.rs → src/ui/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::shaders::{
pixelate::{PixelatePlugin, PixelateSettings},
};

use crate::{resources::state::GameState, ship::Ship};
use crate::{core::resources::state::GameState, world::ship::Ship};

pub struct CameraPlugin;
impl Plugin for CameraPlugin {
Expand Down
2 changes: 1 addition & 1 deletion src/hud/indicator.rs → src/ui/hud/indicator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{math::Vec3Swizzles, prelude::*};

use crate::{resources::state::GameState, ship::Ship};
use crate::{core::resources::state::GameState, world::ship::Ship};

pub struct IndicatorPlugin;
impl Plugin for IndicatorPlugin {
Expand Down
2 changes: 1 addition & 1 deletion src/hud/mod.rs → src/ui/hud/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::prelude::*;

use crate::{resources::assets::UiAssets, resources::state::GameState};
use crate::core::{resources::assets::UiAssets, resources::state::GameState};

pub mod indicator;
pub mod nav;
Expand Down
2 changes: 1 addition & 1 deletion src/hud/nav.rs → src/ui/hud/nav.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::{math::Vec3Swizzles, prelude::*};
use bevy_spatial::{kdtree::KDTree2, SpatialAccess};

use crate::{resources::spatial::KDNode, ship::Ship};
use crate::{world::ship::Ship, world::spatial::KDNode};

/// UI Location component
#[derive(Component)]
Expand Down
2 changes: 1 addition & 1 deletion src/hud/speedometer.rs → src/ui/hud/speedometer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::prelude::*;
use bevy_rapier2d::prelude::Velocity;

use crate::ship::Ship;
use crate::world::ship::Ship;

/// UI Speed component
#[derive(Component)]
Expand Down
2 changes: 1 addition & 1 deletion src/menus/credits.rs → src/ui/menus/credits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::prelude::*;

use crate::resources::{
use crate::core::resources::{
assets::UiAssets,
state::{ForState, GameState},
};
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/menus/pause.rs → src/ui/menus/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use leafwing_input_manager::{
Actionlike,
};

use crate::{
use crate::core::{
effects::blink::DrawBlinkTimer,
resources::{
assets::UiAssets,
Expand Down
2 changes: 1 addition & 1 deletion src/menus/start_menu.rs → src/ui/menus/start_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use leafwing_input_manager::{
Actionlike,
};

use crate::{
use crate::core::{
effects::blink::DrawBlinkTimer,
resources::{
assets::{AudioAssets, UiAssets},
Expand Down
8 changes: 6 additions & 2 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use bevy::prelude::*;

use crate::{
pub mod camera;
pub mod hud;
pub mod menus;

use self::{
camera::CameraPlugin,
hud::HudPlugin,
menus::{credits::CreditsPlugin, pause::PausePlugin, start_menu::MenuPlugin},
resources::camera::CameraPlugin,
};

pub struct UiPlugin;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/astronomy/orbit.rs → src/world/astronomy/orbit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::prelude::*;

use crate::resources::{game_time::GameTime, state::GameState};
use crate::core::resources::{game_time::GameTime, state::GameState};

const ORBITAL_PERIOD_SCALING_FACTOR: f32 = 1.0;

Expand Down
6 changes: 3 additions & 3 deletions src/astronomy/planet.rs → src/world/astronomy/planet.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use bevy::prelude::*;

use crate::{
effects::animate::{AnimationBundle, AnimationIndices, AnimationTimer},
hud::indicator::Indicated,
resources::spatial::KDNode,
core::effects::animate::{AnimationBundle, AnimationIndices, AnimationTimer},
ui::hud::indicator::Indicated,
world::spatial::KDNode,
};

use super::orbit::{Orbit, Orbitable};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use bevy::prelude::*;

use crate::{
hud::indicator::Indicated,
resources::{assets::SpriteAssets, state::GameState},
core::resources::{assets::SpriteAssets, state::GameState},
ui::hud::indicator::Indicated,
};

use super::{
Expand Down
7 changes: 4 additions & 3 deletions src/astronomy/star.rs → src/world/astronomy/star.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use bevy::prelude::*;

use crate::{
effects::animate::{AnimationBundle, AnimationIndices, AnimationTimer},
hud::indicator::Indicated,
resources::{assets::SpriteAssets, spatial::KDNode},
core::effects::animate::{AnimationBundle, AnimationIndices, AnimationTimer},
core::resources::assets::SpriteAssets,
ui::hud::indicator::Indicated,
world::spatial::KDNode,
};

use super::orbit::Orbitable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_tiling_background::{
BackgroundImageBundle, BackgroundMaterial, SetImageRepeatingExt, TilingBackgroundPlugin,
};

use crate::resources::{assets::SpriteAssets, state::GameState};
use crate::core::resources::{assets::SpriteAssets, state::GameState};

pub struct StarfieldPlugin;
impl Plugin for StarfieldPlugin {
Expand Down
8 changes: 6 additions & 2 deletions src/world/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use bevy::prelude::*;
use bevy_rapier2d::prelude::*;

use crate::{
pub mod astronomy;
pub mod ship;
pub mod spatial;

use self::{
astronomy::{planetary_system::PlanetarySystemPlugin, starfield::StarfieldPlugin},
resources::spatial::SpatialPlugin,
ship::ShipPlugin,
spatial::SpatialPlugin,
};

pub struct WorldPlugin;
Expand Down
2 changes: 1 addition & 1 deletion src/ship.rs → src/world/ship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
use leafwing_input_manager::prelude::*;

use crate::resources::{assets::SpriteAssets, state::GameState};
use crate::core::resources::{assets::SpriteAssets, state::GameState};

#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)]
pub enum ShipAction {
Expand Down
File renamed without changes.

0 comments on commit 11e6f4e

Please sign in to comment.