Пример #1
0
 private void MakeTetrimino()
 {
     if (tetrimino.IsStatic)
     {
         tetrimino = new TTetrimino();
     }
 }
Пример #2
0
 public Engine(IUserController controller)
 {
     this.renderer = new ConsoleRenderer(20, 15);
     this.tetrimino = new TTetrimino();
     this.collisionManager = new CollisionManager(renderer, tetrimino);
     this.controller = controller;
     this.staticTetriminos = new char[renderer.Rows, renderer.Cols];
 }
Пример #3
0
 /// <summary>
 /// Creates the next tetrimino that will fall
 /// </summary>
 /// <param name="g"></param>
 public void createTetrimino()
 {
     if (nextTetrimino != null)
     {
         currentTetrimino = nextTetrimino;
     }
     else
     {
         currentTetrimino = Tetriminoes[random.Next(7)];
     }
     nextTetrimino = Tetriminoes[random.Next(7)];
     this.Controls[2].Controls[0].BackgroundImage = nextTetrimino.tetriminoImage;
 }
Пример #4
0
        private void EnqueueFallingTetrimino(Tetrimino tetrimino)
        {
            char[,] tetriminoBody = tetrimino.GetBody();

            int tetriminoBodyRows = tetriminoBody.GetLength(0);
            int tetriminoBodyCols = tetriminoBody.GetLength(1);

            int lastRow = Math.Min(tetrimino.GetTopLeft().Row + tetriminoBodyRows, this.playFieldMatix.GetLength(0));
            int lastCol = Math.Min(tetrimino.GetTopLeft().Col + tetriminoBodyCols, this.playFieldMatix.GetLength(1));

            for (int row = tetrimino.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = tetrimino.GetTopLeft().Col; col < lastCol; col++)
                {
                    this.playFieldMatix[row, col] = tetriminoBody[row - tetrimino.GetTopLeft().Row, col - tetrimino.GetTopLeft().Col];
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Starts the game.
        /// </summary>
        public void startGame()
        {
            playing = true;
            paused  = false;
            score   = 0;
            update  = 0;
            level   = 0;
            updateLevel();
            speed = 1000;
            updateScore(0);
            Point location = new Point(this.Location.X + 10, this.Location.Y + 5);

            board = new Board(20, 10, 20, Color.SeaShell, location);
            addTetriminos();
            timer.Start();
            currentTetrimino = null;
            nextTetrimino    = null;
            createTetrimino();
            Invalidate();
        }
Пример #6
0
 public void EnqueueForRendering(Tetrimino fallingTetrimino, char[,] staticTetriminos)
 {
     this.EnqueueFallingTetrimino(fallingTetrimino);
     this.EnqueueStaticTetriminos(staticTetriminos);
 }
Пример #7
0
 public CollisionManager(ConsoleRenderer renderer, Tetrimino tetrimino)
 {
     this.renderer = renderer;
     this.tetrimino = tetrimino;
 }