/// <summary>
        /// Method to draw player name and score
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        private void NameDrawer(object o, PaintEventArgs e)
        {
            //draws tank name and score
            Tank t = o as Tank;

            //Sets up string format to center name on the tank
            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;
            sf.Alignment     = StringAlignment.Center;
            Rectangle rectan = new Rectangle(-150, 30, 300, 15);

            //Draw the player name with scorre
            byte[] imageBytes = Encoding.Unicode.GetBytes(t.GetName());
            e.Graphics.DrawString(t.GetName() + ": " + t.GetScore().ToString(), playerStyle, whitePen.Brush, rectan, sf);
        }
Beispiel #2
0
        /// <summary>
        /// Draws the name and the score of the user
        /// </summary>
        private void NameDrawer(object o, PaintEventArgs e)
        {
            //Converts the object to a Tank
            Tank t = o as Tank;

            //Gets the width of the tank
            int tankWidth = 50;

            //Sets the graphics setting of the name
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

            //Draws the string centered on the player's location, by using a whiteBrush and using an Arial font 8
            using (System.Drawing.SolidBrush whiteBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White))
            {
                Rectangle r = new Rectangle(-(tankWidth / 2), -(tankWidth / 2), tankWidth, tankWidth);
                Font      f = new Font("Arial", 8);
                e.Graphics.DrawString(t.GetName() + ": " + t.GetScore(), f, whiteBrush, r);
            }
        }