Exemple #1
0
        private void InitializeView( )
        {
            // Centers this window to parent
            Center();

            Title = "Snake";

            Board          = new SnakeBoard(boardWidth, boardHeight);
            Board.Position = new Point(Width / 2 - boardWidth / 2, 5);

            Board.DeathHandler += OnSnakeDeath;
            Board.EatHandler   += OnSnakeEat;

            Print(Board.Position.X, 3, "SCORE:");

            // Add Border around the board
            var border = new SadConsole.Surfaces.Basic(boardWidth + 2, boardHeight + 2);

            border.DrawBox(new Rectangle(0, 0, border.Width, border.Height), new Cell(DefaultForeground, DefaultBackground), connectedLineStyle: SurfaceBase.ConnectedLineThin);

            border.Position = new Point(-1, -1);

            // Add border to Board children so it draws later
            Board.Children.Add(border);
            Children.Add(Board);

            Score = 0;
        }
Exemple #2
0
        private void InitializeView( )
        {
            // Centers this window to parent
            Center();

            Title = "Tetris";

            // Calculate PlayArea position so its centered on X
            int playAreaX = Width / 2 - playWidth / 2;
            int playAreaY = 2;

            // Create the board
            Board          = new TetrisBoard(playWidth, playHeight);
            Board.Position = new Point(playAreaX, playAreaY);

            // Add Border around the board
            var border = new SadConsole.Surfaces.Basic(playWidth + 2, playHeight + 2);

            border.DrawBox(new Rectangle(0, 0, border.Width, border.Height), new Cell(DefaultForeground, DefaultBackground), connectedLineStyle: SurfaceBase.ConnectedLineThin);

            border.Draw(TimeSpan.Zero);
            border.Position = new Point(-1, -1);

            // Add border to Board children so it draws later
            Board.Children.Add(border);
            Children.Add(Board);
        }