Beispiel #1
0
 /// <summary>
 /// Helper method that helps to draw the ship. Picks the correct sprite for current ship.
 /// </summary>
 /// <param name="s">a ship object</param>
 /// <returns>the corresponding Image sprite</returns>
 private Image DrawShip(Ship s)
 {
     // if coasting, return coasting
     if (!s.IsThrusting())
     {
         // retrieve image from CoastingShips image dictionary
         return(CoastingShips[s.GetID() % 8]);
     }
     // else, return thrusting
     else
     {
         // retrieve image from CoastingShips image dictionary
         return(ThrustingShips[s.GetID() % 8]);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Calculates the instant acceleration from stars and engine thrusts.
        /// </summary>
        /// <param name="ship"></param>
        /// <returns></returns>
        private Vector2D CalculateInstantAcceleration(Ship ship)
        {
            Vector2D totalAcc = new Vector2D(0, 0);

            // add gravity from each star
            foreach (Star star in theStars.Values)
            {
                totalAcc += CalculateForce(ship, star);
            }

            // if thrust add enginestrength
            if (ship.IsThrusting())
            {
                totalAcc += (ship.GetOrientation() * engineStrength);
            }

            // return accumulated vector
            return(totalAcc);
        }