Exemple #1
0
 public void BadBigBlockPlacementTest( int x, int y )
 {
     Field field = new Field( 5, 10 );
     IBlock block = new Block();
     createBigBlock( block );
     field.SetBlock( block, new Point( x, y ) );
 }
Exemple #2
0
        static void Main(string[] args)
        {
            //fixedBlocks anders invullen, want property hoort private te zijn

            var field = new Field(3,3);
            field.fixedBlocks = new Grid(
                new Square[,] {
                    {_,_,_},
                    {_,_,_},
                    {x,_,_}
            });
            field.Position = new Vector2(1,1);

            var block = new Block(); //!!moet interface worden
            block.vectors = new List<Vector2>
            {
                new Vector2(0,1), //ToSelf: let op [x,y] , niet [y,x] overigens
                new Vector2(1,0)
            };
            block.squareType = x;
            field.Block = block;

            bool ClippingOccured = false;
            Grid gridSuperposition = field.getSuperposition(out ClippingOccured);

            var gridForCheck = new Grid(
                new Square[,] {
                    {_,_,_},
                    {_,_,x},
                    {x,x,_}
            });

            bool r = gridSuperposition.Equals(gridForCheck);
            bool c = ClippingOccured;
        }
Exemple #3
0
        public void ColorAtPositionNegativeTest( int x, int y )
        {
            Point position = new Point( x, y );
            Block block = new Block();

            Assert.AreEqual( null, block.ColorAt( position ) );
        }
Exemple #4
0
 public void BadBlockPlacementTest( int x, int y )
 {
     Field field = new Field( 2, 10 );
     IBlock block = new Block();
     block.Grid [ 2 ] [ 2 ] = Color.Tomato;
     field.SetBlock( block, new Point( x, y ) );
 }
Exemple #5
0
 private void insertStraight(Block block)
 {
     List<List<Color?>> grid = block.Grid;
     grid [ 2 ] [ 1 ] = Color.Tomato;
     grid [ 2 ] [ 2 ] = Color.Tomato;
     grid [ 2 ] [ 3 ] = Color.Tomato;
     grid [ 2 ] [ 4 ] = Color.Tomato;
 }
        public void Test_WhenBlockHasOneShape_ItShouldNotChangeShape()
        {
            Color color = Color.Beige;

            Block subject = new Block(oShape, color);

            CompareAllShapesRight(subject, oShape, color);
        }
        public void Test_WhenBlockHasFourShapes_RotateRightShouldCycleThroughThem()
        {
            Color color = Color.Azure;

            Block subject = new Block(lShape, color);

            CompareAllShapesRight(subject, lShape, color);
        }
Exemple #8
0
        public void ColorAtPositionTest( int x, int y )
        {
            Point position = new Point( x, y );
            Block block = new Block();

            block.Grid [ position.Y ] [ position.X ] = Color.Tomato;
            Assert.AreEqual( Color.Tomato, block.ColorAt( position ) );
        }
Exemple #9
0
 public IBlock MakeBlock()
 {
     var block = new Block();
     var definition = this.TetrominoDefinitions[random.Next(0, this.TetrominoDefinitions.Length - 1)];
     block.color = definition.color;
     block.TetrominoGrid = definition.Grid;
     return block;
 }
        private void CompareAllShapesLeft(Block subject, List<bool[,]> shapes, Color color)
        {
            for (int i = shapes.Count -1; i >= 0; i--)
            {
                int currentShape = i % shapes.Count;
                subject.RotateLeft();

                Assert.AreEqual(shapes[currentShape].GetLength(1), subject.Width);
                Assert.AreEqual(shapes[currentShape].GetLength(0), subject.Height);
                CompareBlock(subject, shapes[currentShape], color);
            }

            subject.RotateLeft();
            CompareBlock(subject, shapes[shapes.Count - 1], color);
        }
Exemple #11
0
        public void RotateRightTest()
        {
            Block block = new Block();

            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 4 ] );

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 4 ] );

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 0 ] );

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 0 ] );
        }
Exemple #12
0
        public void RotateLeftTest()
        {
            var block = new Block();

            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 0 ] );
            Assert.AreEqual( null, block.Grid [ 0 ] [ 0 ] );

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 4 ] );
            Assert.AreEqual( null, block.Grid [ 0 ] [ 0 ] );

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 4 ] );
            Assert.AreEqual( null, block.Grid [ 0 ] [ 0 ] );

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 0 ] );
        }
Exemple #13
0
        public void TwoColumnMoveLeftOkTest()
        {
            Field field = new Field( 2, 10 );
            IBlock block = new Block();
            field.SetBlock( block, new Point( 1, 0 ) );
            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            bool moveleft = field.CanMoveLeft();
            Assert.AreEqual( true, moveleft );
        }
Exemple #14
0
        public void SingleColumnNoMovesTest()
        {
            Field field = new Field( 1, 10 );
            IBlock block = new Block();
            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            field.SetBlock( block, new Point( 0, 0 ) );

            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            bool moveleft = field.CanMoveLeft();
            Assert.AreEqual( false, moveleft );
            bool moveright = field.CanMoveRight();
            Assert.AreEqual( false, moveright );
        }
Exemple #15
0
 public void FixSquareBlockTest()
 {
     Field field = new Field( 2, 10 );
     IBlock block = new Block();
     block.Grid [ 0 ] [ 0 ] = Color.Tomato;
     block.Grid [ 0 ] [ 1 ] = Color.Tomato;
     block.Grid [ 1 ] [ 0 ] = Color.Tomato;
     block.Grid [ 1 ] [ 1 ] = Color.Tomato;
     field.SetBlock( block, new Point( 0, 0 ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 0, 9 ) ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 1, 9 ) ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 0, 8 ) ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 1, 8 ) ) );
     field.FixBlock();
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 0, 9 ) ) );
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 1, 9 ) ) );
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 0, 8 ) ) );
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 1, 8 ) ) );
 }
        private void CompareAllShapesRight(Block subject, List<bool[,]> shapes, Color color)
        {
            for (int i = 1; i < shapes.Count; i++)
            {
                subject.RotateRight();

                Assert.AreEqual(shapes[i].GetLength(1), subject.Width);
                Assert.AreEqual(shapes[i].GetLength(0), subject.Height);
                CompareBlock(subject, shapes[i], color);
            }

            subject.RotateRight();
            CompareBlock(subject, shapes[0], color);
        }
Exemple #17
0
 public IBlock MakeBlock(Color color, byte[,] tetrominoGrid)
 {
     var block = new Block();
     block.TetrominoGrid = tetrominoGrid;
     block.color = color;
     block.Position = new Vector2(0,0);
     return block;
 }
Exemple #18
0
 public IBlock MakeBlock()
 {
     Block block = new Block();
     insertStraight( block );
     return block;
 }