From 54a1a26a2ca81a79797026645480e0c51dec9314 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 29 Dec 2023 16:01:15 -0800 Subject: [PATCH] More cleanup --- src/game/game.rs | 4 ++-- src/game/mod.rs | 4 ++-- src/main.rs | 1 + src/{game => }/objects/mod.rs | 2 ++ src/{game => }/objects/projectile.rs | 6 ++++-- src/{game => }/objects/ship.rs | 12 +++++++----- src/physics/mod.rs | 1 + src/physics/physics.rs | 6 +----- src/{game => physics}/util.rs | 0 9 files changed, 20 insertions(+), 16 deletions(-) rename src/{game => }/objects/mod.rs (54%) rename src/{game => }/objects/projectile.rs (94%) rename src/{game => }/objects/ship.rs (95%) rename src/{game => physics}/util.rs (100%) diff --git a/src/game/game.rs b/src/game/game.rs index 29ea89d..27aaa04 100644 --- a/src/game/game.rs +++ b/src/game/game.rs @@ -2,12 +2,12 @@ use cgmath::Point2; use std::time::Instant; use winit::event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode}; -use super::{camera::Camera, outfits, system::System, util}; +use super::{camera::Camera, outfits, system::System}; use crate::{ consts, content::Content, inputstatus::InputStatus, - physics::{Physics, ShipHandle}, + physics::{util, Physics, ShipHandle}, render::Sprite, }; diff --git a/src/game/mod.rs b/src/game/mod.rs index 918b090..a14e585 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -1,10 +1,10 @@ +//! This module contains high-level game control routines. + mod camera; mod game; -pub mod objects; pub mod outfits; mod system; mod systemobject; -mod util; pub use game::Game; pub use systemobject::SystemObject; diff --git a/src/main.rs b/src/main.rs index b3cd953..81c0ef4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod consts; mod game; mod inputstatus; +mod objects; mod physics; mod render; diff --git a/src/game/objects/mod.rs b/src/objects/mod.rs similarity index 54% rename from src/game/objects/mod.rs rename to src/objects/mod.rs index 5e8aba8..1802a05 100644 --- a/src/game/objects/mod.rs +++ b/src/objects/mod.rs @@ -1,3 +1,5 @@ +//! This module contains game objects that may interact with the physics engine. + mod projectile; mod ship; diff --git a/src/game/objects/projectile.rs b/src/objects/projectile.rs similarity index 94% rename from src/game/objects/projectile.rs rename to src/objects/projectile.rs index cfd3226..12cc6bd 100644 --- a/src/game/objects/projectile.rs +++ b/src/objects/projectile.rs @@ -4,8 +4,10 @@ use rapier2d::{ geometry::{ColliderBuilder, ColliderHandle}, }; -use super::super::util; -use crate::render::{Sprite, SpriteTexture}; +use crate::{ + physics::util, + render::{Sprite, SpriteTexture}, +}; pub struct ProjectileBuilder { pub rigid_body: RigidBodyBuilder, diff --git a/src/game/objects/ship.rs b/src/objects/ship.rs similarity index 95% rename from src/game/objects/ship.rs rename to src/objects/ship.rs index 5cea722..aef5eea 100644 --- a/src/game/objects/ship.rs +++ b/src/objects/ship.rs @@ -1,16 +1,18 @@ use cgmath::{Deg, EuclideanSpace, Matrix2, Rad, Vector2}; use nalgebra::vector; use rand::Rng; -use rapier2d::dynamics::{RigidBody, RigidBodyBuilder}; -use rapier2d::geometry::ColliderBuilder; -use rapier2d::pipeline::ActiveEvents; +use rapier2d::{ + dynamics::{RigidBody, RigidBodyBuilder}, + geometry::ColliderBuilder, + pipeline::ActiveEvents, +}; use super::ProjectileBuilder; use crate::{ content, - game::{outfits, util}, + game::outfits, inputstatus::InputStatus, - physics::ShipHandle, + physics::{util, ShipHandle}, render::{Sprite, SpriteTexture}, }; diff --git a/src/physics/mod.rs b/src/physics/mod.rs index 2c37c70..6215e5f 100644 --- a/src/physics/mod.rs +++ b/src/physics/mod.rs @@ -1,4 +1,5 @@ mod physics; +pub mod util; mod wrapper; pub use physics::Physics; diff --git a/src/physics/physics.rs b/src/physics/physics.rs index 0a2df18..54abc3d 100644 --- a/src/physics/physics.rs +++ b/src/physics/physics.rs @@ -9,11 +9,7 @@ use rapier2d::{ use std::collections::HashMap; use super::{wrapper::Wrapper, ShipHandle}; -use crate::{ - content, - game::{objects, outfits}, - render::Sprite, -}; +use crate::{content, game::outfits, objects, render::Sprite}; /// Keeps track of all objects in the world that we can interact with. /// Also wraps our physics engine diff --git a/src/game/util.rs b/src/physics/util.rs similarity index 100% rename from src/game/util.rs rename to src/physics/util.rs