Skip to content

Commit

Permalink
Ship trail fix for elliptical orbits + ships speed displayed using km/s
Browse files Browse the repository at this point in the history
  • Loading branch information
Vollch committed Dec 21, 2021
1 parent 9682a95 commit 4a862e1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/truepath.js
Original file line number Diff line number Diff line change
Expand Up @@ -1425,8 +1425,8 @@ export function drawShipYard(){
return sensorRange(global.space.shipyard.blueprint.sensor) + 'km';
},
speedText(){
let speed = shipSpeed(global.space.shipyard.blueprint);
return +speed.toFixed(2);
let speed = (149597870.7/225/24/3600) * shipSpeed(global.space.shipyard.blueprint);
return Math.round(speed) + 'km/s';
},
fuelText(){
let fuel = shipFuelUse(global.space.shipyard.blueprint);
Expand Down Expand Up @@ -2110,8 +2110,8 @@ function drawShips(){
return sensorRange(global.space.shipyard.ships[id].sensor) + 'km';
},
speedText(id){
let speed = shipSpeed(global.space.shipyard.ships[id]);
return +speed.toFixed(2);
let speed = (149597870.7/225/24/3600) * shipSpeed(global.space.shipyard.ships[id]);
return Math.round(speed) + 'km/s';
},
fuelText(id){
let fuel = shipFuelUse(global.space.shipyard.ships[id]);
Expand Down Expand Up @@ -2168,12 +2168,18 @@ function drawShips(){
}

function calcLandingPoint(ship, planet) {
let ship_dist = Math.sqrt((ship.xy.x ** 2) + (ship.xy.y ** 2));
let ship_dist = Math.sqrt(((ship.xy.x - xShift(planet)) ** 2) + (ship.xy.y ** 2));
let ship_speed = shipSpeed(ship) / 225;
let width = xPosition(1, planet);
let cross1_dist = Math.abs(ship_dist - spacePlanetStats[planet].dist);
let cross2_dist = Math.abs(ship_dist + spacePlanetStats[planet].dist);
let cross1_days = Math.floor(Math.min(cross1_dist, cross2_dist) / ship_speed);
let cross2_days = Math.ceil(Math.max(cross1_dist, cross2_dist) / ship_speed);
let cross1w_dist = Math.abs(ship_dist - spacePlanetStats[planet].dist * width);
let cross2w_dist = Math.abs(ship_dist + spacePlanetStats[planet].dist * width);
let cross1_days = Math.floor(Math.min(cross1_dist, cross1w_dist, cross2_dist, cross2w_dist) / ship_speed);
let cross2_days = Math.ceil(Math.max(cross1_dist, cross1w_dist, cross2_dist, cross2w_dist) / ship_speed);
if (ship_dist >= spacePlanetStats[planet].dist && ship_dist <= spacePlanetStats[planet].dist * width) {
cross1_days = 0;
}
let planet_orbit = spacePlanetStats[planet].orbit === -1
? global.city.calendar.orbit
: spacePlanetStats[planet].orbit;
Expand Down

0 comments on commit 4a862e1

Please sign in to comment.