/// <summary> /// This method is used to move ship/ /// </summary> /// <param name="s"></param> private static void moveShip(Ship s) { //calls the method shipFuntion from world class. s.shipFunctions(); //sets gravity to 0,0. Vector2D g = new Vector2D(0, 0); //calculate g. g = star.getStarLoc() - s.getShipLoc(); g.Normalize(); //gets the mass of the star from xml file. g = g * star.getStarMass(); Vector2D a = new Vector2D(0, 0); //the ship is thrusting. if (s.getShipThrust()) { Vector2D t = new Vector2D(s.getShipDir()); //calculate the thrust and apply to gravity. t = t * 0.08; a = g + t; } else { //else acceleration is equal to gravity. a = g; } //set thr ships velocity and location. s.setShipVelocity(s.getShipVelocity() + a); s.setShipLoc(s.getShipLoc() + s.getShipVelocity()); }