Beispiel #1
0
        /// <summary>
        /// Draws a star object from the world.
        /// </summary>
        private void StarDrawer(object o, PaintEventArgs e)
        {
            Star s         = o as Star;
            int  starWidth = 45 + Convert.ToInt32(s.GetSize() * 1000);

            Rectangle r = new Rectangle(-(starWidth / 2), -(starWidth / 2), starWidth, starWidth);

            e.Graphics.DrawImage(starImage, r);
        }
Beispiel #2
0
        /// <summary>
        /// Calculates gravity between a ship and a star.
        /// </summary>
        /// <returns>a Vector2D gravity</returns>
        private Vector2D CalculateForce(Ship ship, Star star)
        {
            // get direction
            Vector2D g = star.GetLocation() - ship.GetLocation();

            g.Normalize();

            // get magnitude
            g *= star.GetSize();

            return(g);
        }