diff --git a/src/game/game.rs b/src/game/game.rs index 3dcc344..e5f28da 100644 --- a/src/game/game.rs +++ b/src/game/game.rs @@ -43,15 +43,15 @@ impl Game { let t: Pfloat = self.last_update.elapsed().as_secs_f32(); if self.input.key_thrust { - self.player.body.thrust(50.0 * t); + self.player.physicsbody.thrust(50.0 * t); } if self.input.key_right { - self.player.body.rot(Deg(35.0) * t); + self.player.physicsbody.rot(Deg(35.0) * t); } if self.input.key_left { - self.player.body.rot(Deg(-35.0) * t); + self.player.physicsbody.rot(Deg(-35.0) * t); } if self.input.v_scroll != 0.0 { @@ -60,8 +60,8 @@ impl Game { self.input.v_scroll = 0.0; } - self.player.body.tick(t); - self.camera.pos = self.player.body.pos; + self.player.physicsbody.tick(t); + self.camera.pos = self.player.physicsbody.pos; self.last_update = Instant::now(); } diff --git a/src/game/mod.rs b/src/game/mod.rs index c3f5290..993fc86 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -1,13 +1,13 @@ mod camera; -mod doodad; mod game; mod inputstatus; mod ship; mod system; +mod systemobject; pub use camera::Camera; -pub use doodad::Doodad; pub use game::Game; pub use inputstatus::InputStatus; pub use ship::Ship; pub use system::System; +pub use systemobject::SystemObject; diff --git a/src/game/ship.rs b/src/game/ship.rs index 8e33ab2..c1febe4 100644 --- a/src/game/ship.rs +++ b/src/game/ship.rs @@ -1,7 +1,8 @@ use cgmath::Point2; use crate::{ - physics::Pfloat, physics::PhysBody, render::Sprite, render::SpriteTexture, render::Spriteable, + physics::Pfloat, physics::PhysicsBody, render::Sprite, render::SpriteTexture, + render::Spriteable, }; pub enum ShipKind { @@ -25,14 +26,14 @@ impl ShipKind { } pub struct Ship { - pub body: PhysBody, + pub physicsbody: PhysicsBody, kind: ShipKind, } impl Ship { pub fn new(kind: ShipKind, pos: Point2) -> Self { Ship { - body: PhysBody::new(pos), + physicsbody: PhysicsBody::new(pos), kind, } } @@ -41,9 +42,9 @@ impl Ship { impl Spriteable for Ship { fn get_sprite(&self) -> Sprite { return Sprite { - pos: (self.body.pos.x, self.body.pos.y, 1.0).into(), + pos: (self.physicsbody.pos.x, self.physicsbody.pos.y, 1.0).into(), texture: self.kind.sprite(), - angle: self.body.angle, + angle: self.physicsbody.angle, scale: 1.0, size: self.kind.size(), }; diff --git a/src/game/system.rs b/src/game/system.rs index 8d782b7..0367e86 100644 --- a/src/game/system.rs +++ b/src/game/system.rs @@ -1,7 +1,7 @@ use cgmath::{Point3, Vector2}; use rand::{self, Rng}; -use super::Doodad; +use super::SystemObject; use crate::{ consts, content, physics::Pfloat, render::Sprite, render::SpriteTexture, render::Spriteable, }; @@ -22,7 +22,7 @@ pub struct StarfieldStar { pub struct System { pub name: String, - bodies: Vec, + bodies: Vec, pub starfield: Vec, } @@ -50,7 +50,7 @@ impl System { }; for o in &ct.objects { - s.bodies.push(Doodad { + s.bodies.push(SystemObject { pos: o.position, sprite: SpriteTexture(o.sprite.to_owned()), size: o.size, diff --git a/src/game/doodad.rs b/src/game/systemobject.rs similarity index 86% rename from src/game/doodad.rs rename to src/game/systemobject.rs index f2534f1..4cd2349 100644 --- a/src/game/doodad.rs +++ b/src/game/systemobject.rs @@ -2,14 +2,14 @@ use cgmath::{Deg, Point3}; use crate::{physics::Pfloat, render::Sprite, render::SpriteTexture, render::Spriteable}; -pub struct Doodad { +pub struct SystemObject { pub sprite: SpriteTexture, pub pos: Point3, pub size: Pfloat, pub angle: Deg, } -impl Spriteable for Doodad { +impl Spriteable for SystemObject { fn get_sprite(&self) -> Sprite { return Sprite { texture: self.sprite.clone(), diff --git a/src/physics/body.rs b/src/physics/body.rs index bb55741..bb41062 100644 --- a/src/physics/body.rs +++ b/src/physics/body.rs @@ -1,16 +1,16 @@ use super::Pfloat; use cgmath::{Angle, Deg, Point2, Vector2}; -pub struct PhysBody { +pub struct PhysicsBody { pub pos: Point2, pub vel: Vector2, pub mass: Pfloat, pub angle: Deg, } -impl PhysBody { +impl PhysicsBody { pub fn new(pos: Point2) -> Self { - return PhysBody { + return PhysicsBody { pos, vel: (0.0, 0.0).into(), mass: 0.3, diff --git a/src/physics/mod.rs b/src/physics/mod.rs index 1b8365c..76ebe5b 100644 --- a/src/physics/mod.rs +++ b/src/physics/mod.rs @@ -4,5 +4,5 @@ mod polar; // What kind of float shoud we use for physics? pub type Pfloat = f32; -pub use body::PhysBody; +pub use body::PhysicsBody; pub use polar::Polar;