~starkingdoms/starkingdoms

07e8dcf569077e555d5b6c6fbcd3803435efceb7 — ghostlyzsh 2 years ago b8f880c
gravity fix
M server/src/planet.rs => server/src/planet.rs +6 -5
@@ 1,3 1,4 @@
use log::debug;
use nalgebra::{Vector2, vector};
use rapier2d_f64::prelude::{RigidBodyHandle, RigidBodySet, ColliderBuilder, RigidBodyBuilder, ColliderSet};
use starkingdoms_protocol::{PlanetType, ProtocolPlanet};


@@ 5,7 6,7 @@ use starkingdoms_protocol::{PlanetType, ProtocolPlanet};
use crate::{SCALE, manager::ClientHandlerMessage};

//const GRAVITY: f64 = 0.001;
const GRAVITY: f64 = 0.00006674;
const GRAVITY: f64 = 6.6674;

#[derive(Clone)]
pub struct Planet {


@@ 19,7 20,7 @@ pub struct Planet {
impl Planet {
    pub fn gravity(&self, position: (f64, f64), mass: f64) -> (f64, f64) {
        let distance = ((position.0 - self.position.0).powi(2) + (position.1 - self.position.1).powi(2)).sqrt();
        let force = GRAVITY * ((self.mass * mass) / distance * distance);
        let force = GRAVITY * ((self.mass * mass) / (distance * distance));
        let mut direction = Vector2::new(self.position.0 - position.0, self.position.1 - position.1);
        direction.set_magnitude(force);
        (direction.x, direction.y)


@@ 57,7 58,7 @@ impl Planets {
        Planets::make_planet(
            &mut planets,
            PlanetType::Earth,
            2000.0,
            4000.0,
            1000.0,
            (100.0, 100.0),
            rigid_body_set,


@@ 88,8 89,8 @@ impl Planets {
        let mut direction = Vector2::zeros();
        for planet in self.planets.clone() {
            let planet_grav = planet.gravity(position, mass);
            direction.x = planet_grav.0;
            direction.y = planet_grav.1;
            direction.x += planet_grav.0;
            direction.y += planet_grav.1;
        }
        (direction.x, direction.y)
    }

M server/src/timer.rs => server/src/timer.rs +1 -1
@@ 1,6 1,6 @@

use std::{time::Duration, sync::Arc};
use log::{error};
use log::{error, debug};

use nalgebra::vector;
use rapier2d_f64::prelude::{PhysicsPipeline, RigidBodyHandle};

M spacetime_py/__pycache__/ninja_syntax.cpython-310.pyc => spacetime_py/__pycache__/ninja_syntax.cpython-310.pyc +0 -0