コード例 #1
0
        void PaintGrid()
        {
            Position        p          = new Position();
            SolidColorBrush brushColor = SnakeColor.GetColorBrush(SnakeColor.ColorPalette.WHITE);

            for (int y = 0; y < GameState.sideCellCount; y++)
            {
                p.Y = y;
                for (byte x = 0; x < GameState.sideCellCount; x++)
                {
                    p.X = x;
                    var cellContent = GameState.grid.GetCellAt(p).content;

                    switch (cellContent)
                    {
                    case CellContent.Empty:
                        var color = Color.FromRgb((byte)((x * 6) + (y * 5)), (byte)((x * 3) + (y * 0)), (byte)((x * 1) + (y * 3)));
                        brushColor = new SolidColorBrush(color);
                        break;

                    case CellContent.Apple:
                        brushColor = SnakeColor.GetColorBrush(SnakeColor.ColorPalette.RED);
                        break;

                    case CellContent.Spikes:
                        brushColor = SnakeColor.GetColorBrush(SnakeColor.ColorPalette.BLACK);
                        break;
                    }

                    SetCellColor(p, brushColor);
                }
            }
        }
コード例 #2
0
 private void Window_ContentRendered(object sender, EventArgs e)
 {
     SetCellColor(GameState.snake.GetHeadPosition(), SnakeColor.GetColorBrush(SnakeColor.ColorPalette.GREEN));
 }