Commit 5fdc9eb1 authored by Rahix's avatar Rahix 🦀
Browse files

components: Rename Movable to OrbitBody

parent 20688a8e
mod edge;
mod movable;
mod node;
mod orbitbody;
mod player;
mod position;
mod thesun;
pub use edge::Edge;
pub use movable::{Gravity, Movable};
pub use node::Node;
pub use orbitbody::{Gravity, OrbitBody};
pub use player::Player;
pub use position::Position;
pub use thesun::TheSun;
pub use edge::draw_edges_system;
pub use movable::{update_gravity_system, update_movement_system};
pub use node::{draw_nodes_system, update_nodes_system};
pub use orbitbody::{update_gravity_system, update_movement_system};
pub use thesun::draw_thesun_system;
use crate::components;
pub struct Movable {
pub struct OrbitBody {
velocity: nalgebra::Vector2<f32>,
acceleration: nalgebra::Vector2<f32>,
}
impl Movable {
pub fn new(vel_x: f32, vel_y: f32) -> Movable {
Movable {
impl OrbitBody {
pub fn new(vel_x: f32, vel_y: f32) -> OrbitBody {
OrbitBody {
velocity: nalgebra::Vector2::new(vel_x, vel_y),
acceleration: nalgebra::Vector2::new(0.0, 0.0),
}
......@@ -15,7 +15,7 @@ impl Movable {
}
#[legion::system(for_each)]
pub fn update_movement(pos: &mut components::Position, mov: &mut Movable) {
pub fn update_movement(pos: &mut components::Position, mov: &mut OrbitBody) {
let delta = 0.3;
mov.velocity += mov.acceleration * delta;
pos.0 += mov.velocity * delta;
......@@ -24,7 +24,7 @@ pub fn update_movement(pos: &mut components::Position, mov: &mut Movable) {
pub struct Gravity;
#[legion::system(for_each)]
pub fn update_gravity(_: &Gravity, mov: &mut Movable, pos: &components::Position) {
pub fn update_gravity(_: &Gravity, mov: &mut OrbitBody, pos: &components::Position) {
let sun = nalgebra::Point2::new(600.0, 540.0);
let distance_vector = sun - pos.0;
......
......@@ -22,31 +22,31 @@ impl HeavenState {
let n0 = node_world.push((
components::Node::new(),
components::Position::new(800.0, 340.0),
components::Movable::new(5.0, 10.0),
components::OrbitBody::new(5.0, 10.0),
components::Gravity,
));
let n1 = node_world.push((
components::Node::new(),
components::Position::new(120.0, 300.0),
components::Movable::new(5.0, -5.0),
components::OrbitBody::new(5.0, -5.0),
components::Gravity,
));
let n2 = node_world.push((
components::Node::new(),
components::Position::new(700.0, 740.0),
components::Movable::new(8.0, -4.0),
components::OrbitBody::new(8.0, -4.0),
components::Gravity,
));
let n3 = node_world.push((
components::Node::new(),
components::Position::new(340.0, 290.0),
components::Movable::new(10.0, 0.0),
components::OrbitBody::new(10.0, 0.0),
components::Gravity,
));
let n4 = node_world.push((
components::Node::new(),
components::Position::new(300.0, 400.0),
components::Movable::new(0.0, 10.0),
components::OrbitBody::new(0.0, 10.0),
components::Gravity,
));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment