Example #1
0
        public void CurrTetraminoMoveDown()
        {
            MediaElement player2  = new MediaElement();
            Point        Position = currTetramino.getCurrPosition();

            Point[] Shape = currTetramino.getCurrShape();
            movedown = true;

            currTetraminoErase();
            foreach (Point S in Shape)
            {
                if (((int)(S.Y + Position.Y) + 2 + 1) >= Rows)
                {
                    movedown = false;
                }

                else if (wb.GetPixel((int)((S.X + Position.X) + ((Cols / 2) - 1)), ((int)(S.Y + Position.Y) + 2 + 1)) != Colors.Black)
                {
                    movedown = false;
                }

                if (wb.GetPixel((int)((S.X) + ((Cols / 2) - 1)), ((int)(S.Y) + 4)) != Colors.Black)
                {
                    movedown = false;
                    lose     = true;
                    for (int i = 0; i < wb.PixelHeight; i++)
                    {
                        for (int j = 0; j < wb.PixelWidth; j++)
                        {
                            wb.SetPixel(j, i, Colors.Black);
                        }
                    }
                    _level = 1;
                    Level  = _level;
                }
            }


            if (movedown)
            {
                currTetramino.MoveDown();
                currTetraminoDraw();
                tetr = false;
            }
            else
            {
                tetr = true;
                currTetraminoDraw();
                CheckRows();
                currTetramino = new Tetramino();
            }
        }
Example #2
0
        public void CurrTetraminoMoveFastDown()
        {
            MediaElement player2  = new MediaElement();
            Point        Position = currTetramino.getCurrPosition();

            Point[] Shape = currTetramino.getCurrShape();


            movedown = true;
            currTetraminoErase();
            foreach (Point S in Shape)
            {
                if (((int)(S.Y + Position.Y) + 2 + 1) >= Rows)
                {
                    movedown = false;
                }

                else if (wb.GetPixel(((int)(S.X + Position.X) + ((Cols / 2) - 1)),
                                     ((int)(S.Y + Position.Y) + 2 + 1)) != Colors.Black)
                {
                    movedown = false;
                }

                if (wb.GetPixel(((int)(S.X) + ((Cols / 2) - 1)),
                                ((int)(S.Y) + 2 + 2)) != Colors.Black)
                {
                    movedown = false;
                    lose     = true;
                }
            }
            if (movedown)
            {
                currTetramino.MoveDown();
                currTetraminoDraw();
                tetr = false;
            }
            else
            {
                tetr = true;
                currTetraminoDraw();
                CheckRows();
                currTetramino = new Tetramino();
            }
        }
Example #3
0
        public Tetris(WriteableBitmap wbm)
        {
            this.wbm = wbm;
            this.wb  = BitmapFactory.New(wbm.PixelWidth / 2, wbm.PixelHeight / 2);



            for (int i = 0; i < wb.PixelHeight; i++)
            {
                for (int j = 0; j < wb.PixelWidth; j++)
                {
                    wb.SetPixel(j, i, Colors.Black);
                }
            }
            Rows   = this.wb.PixelHeight;
            Cols   = this.wb.PixelWidth;
            _score = 0;
            _level = 1;

            Level         = _level;
            LinesFilled   = 0;
            currTetramino = new Tetramino();
            currTetraminoDraw();
        }
Example #4
0
        public void CurrTetraminoMoveFastDown()
        {
            MediaElement player2 = new MediaElement();
            Point Position = currTetramino.getCurrPosition();
            Point[] Shape = currTetramino.getCurrShape();

            movedown = true;
            currTetraminoErase();
            foreach (Point S in Shape)
            {
                if (((int)(S.Y + Position.Y) + 2 + 1) >= Rows)
                {

                    movedown = false;

                }

                else if (wb.GetPixel(((int)(S.X + Position.X) + ((Cols / 2) - 1)),
                    ((int)(S.Y + Position.Y) + 2 + 1)) !=Colors.Black)
                {
                    movedown = false;

                }

                if (wb.GetPixel(((int)(S.X) + ((Cols / 2) - 1)),
                    ((int)(S.Y) + 2 + 2)) != Colors.Black)
                {
                    movedown = false;
                    lose = true;

                }

            }
            if (movedown)
            {
                currTetramino.MoveDown();
                currTetraminoDraw();
                tetr = false;

            }
            else
            {
                tetr = true;
                currTetraminoDraw();
                CheckRows();
                currTetramino = new Tetramino();

            }
        }
Example #5
0
        public void CurrTetraminoMoveDown()
        {
            MediaElement player2 = new MediaElement();
            Point Position = currTetramino.getCurrPosition();
            Point[] Shape = currTetramino.getCurrShape();
            movedown = true;

            currTetraminoErase();
            foreach (Point S in Shape)
            {
                if (((int)(S.Y + Position.Y) + 2 + 1) >= Rows)
                {
                    movedown = false;

                }

                else if (wb.GetPixel((int)((S.X + Position.X) + ((Cols / 2) - 1)),((int)(S.Y + Position.Y) + 2 + 1)) != Colors.Black)
                {
                    movedown = false;
                }

                if (wb.GetPixel((int)((S.X) + ((Cols / 2) - 1)),((int)(S.Y)+4))!= Colors.Black)
                {
                    movedown = false;
                    lose = true;
                    for (int i = 0; i < wb.PixelHeight; i++)
                    {
                        for (int j = 0; j < wb.PixelWidth; j++)
                        {

                            wb.SetPixel(j, i, Colors.Black);
                        }
                    }
                    _level = 1;
                    Level = _level;
                }

            }

            if (movedown)
            {
                currTetramino.MoveDown();
                currTetraminoDraw();
                tetr = false;

            }
            else
            {
                tetr = true;
                currTetraminoDraw();
                CheckRows();
                currTetramino = new Tetramino();
            }
        }
Example #6
0
        public Tetris(WriteableBitmap wbm)
        {
            this.wbm = wbm;
            this.wb = BitmapFactory.New(wbm.PixelWidth / 2, wbm.PixelHeight / 2);

            for (int i = 0; i < wb.PixelHeight; i++)
            {
                for (int j = 0; j < wb.PixelWidth; j++)
                {

                    wb.SetPixel(j, i,Colors.Black);
                }
            }
            Rows = this.wb.PixelHeight;
            Cols = this.wb.PixelWidth;
            _score = 0;
            _level = 1;

            Level = _level;
            LinesFilled = 0;
            currTetramino = new Tetramino();
            currTetraminoDraw();
        }