Разработка программы «хождение по лабиринту», курсовая работа по системному по, страница 8

        }

        Graphics g = Graphics.FromImage(Buffer);

        Pen BorderPen = new Pen(Color.Black);

        Brush CellBrush;

        if (OnlyPlayer)

        {

            CellBrush = new SolidBrush(Color.WhiteSmoke);

            g.FillEllipse(CellBrush, (OldPosition.X) * this.CellSize.Width+1, (OldPosition.Y) * CellSize.Height+1, CellSize.Width-1, CellSize.Height-1);

        }

        else

        {

            for (int x = 0; x < Maze.Size.Width; x++)

                for (int y = 0; y < Maze.Size.Height; y++)

                {

                    if (Maze.Walls(new Point(x, y)).Noth) g.DrawLine(BorderPen,

x * CellSize.Width, y * CellSize.Height,

(x + 1) * CellSize.Width, y * CellSize.Height);

                    if (Maze.Walls(new Point(x, y)).West) g.DrawLine(BorderPen,

x * CellSize.Width, y * CellSize.Height,

x * CellSize.Width, (y + 1) * CellSize.Height);

                }

            g.DrawLine(BorderPen, 0, Maze.Size.Height * CellSize.Height, (Maze.Size.Width) * CellSize.Width, Maze.Size.Height * CellSize.Height);

            g.DrawLine(BorderPen, Maze.Size.Width * CellSize.Width, 0, Maze.Size.Width * CellSize.Width, (Maze.Size.Height) * CellSize.Height);

        }

        CellBrush = new SolidBrush(Color.FromArgb(255, 255, 100));

        g.FillRectangle(CellBrush, Maze.Player.EnterPoint.X * CellSize.Width+1, Maze.Player.EnterPoint.Y*CellSize.Height+1, CellSize.Width-1,CellSize.Height-1);

        CellBrush = new SolidBrush(Color.FromArgb(100, 255, 100));

        g.FillRectangle(CellBrush, Maze.Player.ExitPoint.X * CellSize.Width+1, Maze.Player.ExitPoint.Y*CellSize.Height+1, CellSize.Width-1,CellSize.Height-1);

        CellBrush = new SolidBrush(Color.FromArgb(200, 0, 0));

        g.FillEllipse(CellBrush, (Maze.Player.CurrentPosition.X) * this.CellSize.Width+1, (Maze.Player.CurrentPosition.Y) * CellSize.Height+1, CellSize.Width-1, CellSize.Height-1);

    }

}

Поведение данной функции зависит от параметра OnlyPlayer, при этом если передать true, то будет перерисован только игрок, если передать false,то перерисовываем лабиринт полностью.