SimpleSoccer.Net.SoccerBall.Render C# (CSharp) Method

Render() public method

public Render ( Graphics g ) : void
g System.Drawing.Graphics
return void
        public override void Render(Graphics g)
        {
            int imageX = (int)Position.X - SoccerBall.BallImage.Width / 2;
            int imageY = (int)Position.Y - SoccerBall.BallImage.Height / 2;

            g.DrawImage(SoccerBall.BallImage, imageX, imageY);

            //GDI.CurrentPen = Pens.White;
            //GDI.CurrentBrush = Brushes.Black;
            //GDI.DrawCircle(g, Position, BoundingRadius);
        }

Usage Example

Example #1
0
        public void Render(Graphics g)
        {
            //draw the grass
            g.DrawRectangle(Pens.DarkGreen, new Rectangle(0, 0, _clientWidth, _clientHeight));
            g.FillRectangle(Brushes.DarkGreen, new Rectangle(0, 0, _clientWidth, _clientHeight));

            // render regions
            if (ParameterManager.Instance.ShowRegions)
            {
                for (int regionIndex = 0; regionIndex < _regions.Count; regionIndex++)
                {
                    _regions[regionIndex].Render(true, g);
                }
            }

            //render the goals
            g.DrawRectangle(Pens.Red, (float)_playingArea.Left, (float)(_clientHeight - ParameterManager.Instance.GoalWidth) / 2.0f, 40.0f, (float)ParameterManager.Instance.GoalWidth);
            g.DrawRectangle(Pens.Blue, (float)_playingArea.Right - 40.0f, (float)(_clientHeight - ParameterManager.Instance.GoalWidth) / 2.0f, 40.0f, (float)ParameterManager.Instance.GoalWidth);

            //render the pitch markings
            GDI.CurrentBrush = Brushes.Transparent;
            GDI.CurrentPen   = Pens.White;
            GDI.DrawCircle(g, _playingArea.VectorCenter, _playingArea.Width * 0.125f);

            g.DrawLine(Pens.White, (float)_playingArea.VectorCenter.X, (float)_playingArea.Top, (float)_playingArea.VectorCenter.X, (float)_playingArea.Bottom);

            GDI.CurrentBrush = Brushes.White;
            GDI.DrawCircle(g, _playingArea.VectorCenter, 2.0f);

            _ball.Render(g);

            //Render the teams
            _redTeam.Render(g);
            _blueTeam.Render(g);

            //render the walls
            for (int wallIndex = 0; wallIndex < _walls.Count; ++wallIndex)
            {
                _walls[wallIndex].Render(false, g);
            }

            //show the score
            string redGoals = string.Format("Red: {0}", _blueGoal.GoalsScored);

            g.DrawString(redGoals, GDI.TextFont, Brushes.Red, new PointF(_clientWidth / 2 + 10, _clientHeight - GDI.TextFont.Height));

            string blueGoals = string.Format("Blue: {0}", _redGoal.GoalsScored);

            g.DrawString(blueGoals, GDI.TextFont, Brushes.Blue, new PointF(_clientWidth / 2 - g.MeasureString(blueGoals, GDI.TextFont).Width - 10, _clientHeight - GDI.TextFont.Height));
        }