/* Legend:
            G - gift block
            X - gift (the block that is dropped after G is hit)
            E - the exploding block
            * - TrailObject (used by the meteorite ball or after explosion of ExplodingBlock)
            @ - bullet fired by the racket
            % - ExplosionBlockResult blocks
         */
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            // build ceiling and left wall for the scene
            for (int i = 0; i < endCol; i++)
            {
                Block ceilingBlock = new IndestructibleBlock(new MatrixCoords(0, i));
                Block leftWallBlock = new IndestructibleBlock(new MatrixCoords(i, 0));

                engine.AddObject(ceilingBlock);
                engine.AddObject(leftWallBlock);
            }

            // build right wall for the scene
            for (int i = 0; i < WorldRows; i++)
            {
                Block rightWallBlock = new IndestructibleBlock(new MatrixCoords(i, endCol - 1));
                engine.AddObject(rightWallBlock);
            }

            // meteorite or unstoppable ball test
            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            Racket theRacket = new ShootingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            // test trail object with random MatrixCoords and lifetime = 15 turns
            GameObject trailObj = new TrailObject(new MatrixCoords(WorldRows - 6, WorldCols - 12), 15);
            engine.AddObject(trailObj);

            // add a gift block
            Block giftBlock = new GiftBlock(new MatrixCoords(WorldRows - 11, WorldCols - 20));
            engine.AddObject(giftBlock);

            //add unpassable block with random coords
            Block unpassable = new UnpassableBlock(new MatrixCoords(WorldRows - 15, WorldCols - 10));
            engine.AddObject(unpassable);

            // add exploding block and ordinary blocks around it
            Block explodingBlock = new ExplodingBlock(new MatrixCoords(WorldRows - 12, WorldCols - 35));
            Block leftToExploding = new Block(explodingBlock.TopLeft + new MatrixCoords(0, -1));
            Block rightToExploding = new Block(explodingBlock.TopLeft + new MatrixCoords(0, 1));
            engine.AddObject(explodingBlock);
            engine.AddObject(leftToExploding);
            engine.AddObject(rightToExploding);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
                
                engine.AddObject(new UnpassableBlock(new MatrixCoords(3, i * 4)));
            }
            engine.AddObject(new ExplodingBlock(new MatrixCoords(startRow + 1, 6)));
            engine.AddObject(new GiftBlock(new MatrixCoords(startRow + 1, endCol - 2)));

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //Ball theBall = new MeteoritBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //Ball theBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(theRacket);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                engine.AddObject(new Block(new MatrixCoords(startRow, i)));
            }

            CreateFieldBorders(engine, startRow, startCol, endCol);

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 2),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            TrailObject trailObject = new TrailObject(theBall.TopLeft, 3);

            engine.AddObject(trailObject);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            // Add walls
            for (int i = 0; i < WorldRows; i++)
            {
                IndestructibleBlock currLeftWall = 
                    new IndestructibleBlock(new MatrixCoords(i, 0));

                engine.AddObject(currLeftWall);

                IndestructibleBlock currRightWall =
                    new IndestructibleBlock(new MatrixCoords(i, WorldCols - 1));

                engine.AddObject(currRightWall);
            }
            
            //add roof
            for (int i = 0; i < WorldCols; i++)
            {
                IndestructibleBlock currLeftWall =
                    new IndestructibleBlock(new MatrixCoords(0, i), '-');

                engine.AddObject(currLeftWall);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
            engine.AddObject(theBall);

            //MeteoriteBall theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));

            //Ball theUnstopableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //engine.AddObject(theUnstopableBall);

            
            //engine.AddObject(new UnpassableBlocks(new MatrixCoords(3, 6)));
            

            engine.AddObject(new GiftBlock(new MatrixCoords(4, 6)));

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 2;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow+1, i));

                engine.AddObject(currBlock);
            }
            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow + 2, i));

                engine.AddObject(currBlock);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 35),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            Ball twoBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
               new MatrixCoords(-1, 1));

            engine.AddObject(twoBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 2, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock wallLeft = new IndestructibleBlock(new MatrixCoords(row,0));
                engine.AddObject(wallLeft);
                IndestructibleBlock wallRight = new IndestructibleBlock(new MatrixCoords(row, WorldCols-1));
                engine.AddObject(wallRight);

            }
            for (int col = 0; col < WorldCols; col++)
            {
                IndestructibleBlock wallDown = new IndestructibleBlock(new MatrixCoords(WorldRows - 1, col));
                engine.AddObject(wallDown);
                IndestructibleBlock wallUp = new IndestructibleBlock(new MatrixCoords(startRow-2, col));
                engine.AddObject(wallUp);
            }
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            for (int i = startCol; i < endCol; i++)
            {
                UnpassableBlock currBlock = new UnpassableBlock(new MatrixCoords(startRow - 2, i));

                engine.AddObject(currBlock);
            }

            for (int i = startCol; i < endCol; i+=2)
            {
                ExplodingBlock currBlock = new ExplodingBlock(new MatrixCoords(startRow + 1, i));

                engine.AddObject(currBlock);
            }
            for (int i = startCol; i < endCol; i += 2)
            {
                GiftBlock currBlock = new GiftBlock(new MatrixCoords(startRow + 2, i));

                engine.AddObject(currBlock);
            }
            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
            UnstoppableBall unstoppable = new UnstoppableBall(new MatrixCoords(WorldRows / 2+4, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);
            engine.AddObject(unstoppable);

            ShoothingRacket theRacket = new ShoothingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            //TrailObject test = new TrailObject(3, new MatrixCoords(5, 5), new char[1, 1]{{'H'}});
            //engine.AddObject(test);

            //walls
            InitializeWalls(engine);
        }
Beispiel #7
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));
                // <Task 1>

                IndestructibleBlock ceilingBlock = new IndestructibleBlock(new MatrixCoords(startRow - 1, i));
                IndestructibleBlock leftSideBlock = new IndestructibleBlock(new MatrixCoords(i, startCol - 1));
                IndestructibleBlock rightSideBlock = new IndestructibleBlock(new MatrixCoords(i, endCol));

                engine.AddObject(ceilingBlock);
                engine.AddObject(leftSideBlock);
                engine.AddObject(rightSideBlock);
                engine.AddObject(currBlock);

            }
            //<Task 5>
            TrailObject trailBlock = new TrailObject(new MatrixCoords(WorldRows / 2, WorldCols / 2), new char[,] { { '&' } }, 30);

            engine.AddObject(trailBlock);

            /* <Task 6>
            MeteoriteBall mBall = new MeteoriteBall(new MatrixCoords(10, 10), new MatrixCoords(1, 1), 3);
            engine.AddObject(mBall);

            <Task9> Test UnstoppableBall
            Ball theUnstopableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            engine.AddObject(theUnstopableBall);

            for (int i = 2; i < WorldCols/2; i+=4)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(4, i)));
            }
             */

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            engine.AddObject(new TailObject(new MatrixCoords(10, 5), new char[1,1] {{'%'}}, 5));

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock2 = new Block(new MatrixCoords(startRow + 1, i));
                engine.AddObject(currBlock2);
                ExplodingBlock currBlock3 = new ExplodingBlock(new MatrixCoords(startRow + 2, i));
                engine.AddObject(currBlock3);
                GiftBlock currBlock4 = new GiftBlock(new MatrixCoords(startRow + 3, i));
                engine.AddObject(currBlock4);

            }

            for (int i = startCol - 1; i <= endCol; i++)
            {
                IndestructibleBlock currBlock = new IndestructibleBlock(new MatrixCoords(startRow, i));
                engine.AddObject(currBlock);
            }

            for (int i = startRow; i <= WorldRows; i++)
            {
                IndestructibleBlock currBlock1 = new IndestructibleBlock(new MatrixCoords(i, startCol - 1));
                IndestructibleBlock currBlock2 = new IndestructibleBlock(new MatrixCoords(i, endCol      ));
                engine.AddObject(currBlock1);
                engine.AddObject(currBlock2);
            }

            //MeteoriteBall theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));
            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));


            engine.AddObject(theBall);

            Gift gift = new Gift(new MatrixCoords(8, 20));
            engine.AddObject(gift);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
        private static void AddBall(Engine engine)
        {
            //UnstoppableBall unstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1), 5);

            //engine.AddObject(unstoppableBall);

            //MeteoriteBall theMeteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1), 5);

            //engine.AddObject(theMeteoriteBall);

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            Racket someRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(someRacket);

            //ShootingRacket shootingRacket = new ShootingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            //engine.AddObject(shootingRacket);

            for (int row = 3; row < WorldRows; row++)
            {
                IndestructibleBlock leftWall = new IndestructibleBlock(new MatrixCoords(row, 1));
                engine.AddObject(leftWall);
                IndestructibleBlock rightWall = new IndestructibleBlock(new MatrixCoords(row, endCol));
                engine.AddObject(rightWall);
            }
            for (int col = 1; col <= endCol; col++)
            {
                IndestructibleBlock topWall = new IndestructibleBlock(new MatrixCoords(startRow - 1, col));
                engine.AddObject(topWall);
            }
            //TrailObject trailObject = new TrailObject(new MatrixCoords(7, 7), new[,] { { '*' } }, 15);
            //engine.AddObject(trailObject);
            MeteoriteBall meteoriteBall = new MeteoriteBall(new MatrixCoords(7, 7), new MatrixCoords(1, 1));
            engine.AddObject(meteoriteBall);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
Beispiel #12
0
        public virtual void AddObject(GameObject obj)
        {
            if (obj is MovingObject)
            {
                this.AddMovingObject(obj as MovingObject);

                if (obj is Ball)
                {
                    this.ball = obj as Ball;
                }
            }
            else
            {
                if (obj is Racket)
                {
                    AddRacket(obj);

                }
                else
                {
                    this.AddStaticObject(obj);
                }
            }
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            //01.   The AcademyPopcorn class contains an IndestructibleBlock class.
            //      Use it to create side and ceiling walls to the game. You can
            //      ONLY edit the AcademyPopcornMain.cs file.
            for (int i = 0; i < WorldRows; i++)
            {
                Block LeftBorder = new IndestructibleBlock(new MatrixCoords(i, 0));
                Block RigthBorder = new IndestructibleBlock(new MatrixCoords(i, WorldCols-1));

                engine.AddObject(LeftBorder);
                engine.AddObject(RigthBorder);
            }

            for (int i = 0; i < WorldCols-1; i++)
            {
                Block UpBorder = new IndestructibleBlock(new MatrixCoords(0,i));

                engine.AddObject(UpBorder);
            }

            ////Task 02 - test sleeptime
            //engine.SleepTime = 100;

            ////Task 05 - test the TrailObject by adding an instance of it in the engine through the AcademyPopcornMain.cs file.
            //TrailObject trail = new TrailObject(new MatrixCoords(WorldRows / 2, WorldCols / 2), new char[,] { { '%' } }, 20);
            //engine.AddObject(trail);

            ////07.     Test the MeteoriteBall by replacing the normal ball in the AcademyPopcornMain.cs file.
            //Ball theMeteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //engine.AddObject(theMeteoriteBall);

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            engine.AddObject(theBall);

            ////09.   Test the UnpassableBlock and the UnstoppableBall by adding them to the engine in AcademyPopcornMain.cs file
            //for (int i = 10; i < WorldCols - 10; i++)
            //{
            //    //create an unpassable block
            //    UnpassableBlock unpassableBlock = new UnpassableBlock(new MatrixCoords(10, i));
            //    engine.AddObject(unpassableBlock);
            //}

            //UnstoppableBall ultimateBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 10), new MatrixCoords(-1, 1));
            //engine.AddObject(ultimateBall);

            ////10.   Test ExplodingBlock
            //for (int i = startCol; i < endCol; i++)
            //{
            //    if (i % 2 == 0)
            //    {
            //        ExplodingBlock currBlock = new ExplodingBlock(new MatrixCoords(startRow + 1, i));
            //        engine.AddObject(currBlock);
            //    }
            //    else
            //    {
            //        Block currBlock = new Block(new MatrixCoords(startRow + 1, i));
            //        engine.AddObject(currBlock);
            //    }
            //}

            ////12.   Test the Gift and GiftBlock classes by adding them through the AcademyPopcornMain.cs file.
            //for (int i = startCol + 5; i < endCol - 5; i++)
            //{
            //    GiftBlock currBlock = new GiftBlock(new MatrixCoords(startRow + 10, i));
            //    engine.AddObject(currBlock);
            //}

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(theRacket);

            //TODO - Task 13: Implementing Shooting Ability
            Racket newRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(theRacket);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
            engine.AddObject(theBall);

            //Implement MetheoridBall
            //MeteoriteBall meteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));
            //engine.AddObject(meteoriteBall);

            //Implement UnstopableBall and UnpassableBlocks
            //UnstoppableBall theUnstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));
            //engine.AddObject(theUnstoppableBall);

            for (int i = 0; i < WorldRows; i++)
            {
                UnpassableBlock LeftWall = new UnpassableBlock(new MatrixCoords(i, 0));
                UnpassableBlock RightWall = new UnpassableBlock(new MatrixCoords(i, WorldCols - 1));
                engine.AddObject(LeftWall);
                engine.AddObject(RightWall);
            }
            for (int i = 1; i < WorldCols - 1; i++)
            {
                UnpassableBlock UppertWall = new UnpassableBlock(new MatrixCoords(0, i));
                engine.AddObject(UppertWall);
            }

            //Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            //engine.AddObject(theRacket);

            //Add indistructuble blocks
            for (int i = 1; i < WorldRows; i++)
            {
                IndestructibleBlock LeftWall = new IndestructibleBlock(new MatrixCoords(i, 1));
                IndestructibleBlock RightWall = new IndestructibleBlock(new MatrixCoords(i, WorldCols - 2));
                engine.AddObject(LeftWall);
                engine.AddObject(RightWall);
            }
            for (int i = 2; i < WorldCols - 2; i++)
            {
                IndestructibleBlock UppertWall = new IndestructibleBlock(new MatrixCoords(1, i));
                engine.AddObject(UppertWall);
            }

            //Adding several explosion blocks
            for (int i = 7; i < WorldCols-2; i+=7)
            {
                ExplodingBlock explosion = new ExplodingBlock(new MatrixCoords(3, i));
                engine.AddObject(explosion);
            }

            //Add several gift blocks
            for (int i = 2; i < WorldCols - 2; i += 7)
            {
                GiftBlock giftBlock = new GiftBlock(new MatrixCoords(4, i));
                engine.AddObject(giftBlock);
            }

            //Add shooting rocket
            ShootingRacket shoot = new ShootingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(shoot);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            //1. The AcademyPopcorn class contains an IndestructibleBlock class.
            //Use it to create side and ceiling walls to the game.
            //You can ONLY edit the AcademyPopcornMain.cs file.

            //LeftWall
            for (int i = 0; i < endCol; i++)
            {
                IndestructibleBlock leftWall = new IndestructibleBlock(new MatrixCoords(i, 0));

                engine.AddObject(leftWall);
            }

            //RightWall
            for (int i = 0; i < endCol; i++)
            {
                IndestructibleBlock rightWall = new IndestructibleBlock(new MatrixCoords(i, WorldCols - 1));

                engine.AddObject(rightWall);
            }

            //Ceiling
            for (int i = 1; i < WorldCols - 1; i++)
            {
                IndestructibleBlock rightWall = new IndestructibleBlock(new MatrixCoords(0, i));

                engine.AddObject(rightWall);
            }

            //10. Testing the exploding block.
            for (int i = startCol; i < endCol; i++)
            {
                //if (i == 7)
                //{
                //    ExplodingBlock boomBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                //
                //    engine.AddObject(boomBlock);
                //}
                //else
                //{
                    Block currBlock = new Block(new MatrixCoords(startRow, i));

                    engine.AddObject(currBlock);
                //}
            }

            //12. Testing Gift and GiftBlock
            for (int i = startCol; i < endCol; i++)
            {
                GiftBlock currBlock = new GiftBlock(new MatrixCoords(startRow + 5, i));

                engine.AddObject(currBlock);
            }

            //7. Test the MeteoriteBall by replacing the normal ball in the AcademyPopcornMain.cs file.
            //MeteoriteBall theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));
            //
            //engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            //5. Testing TrailObject
            //TrailObject trail = new TrailObject(new MatrixCoords(10, 10), 5);
            //
            //engine.AddObject(trail);

            //9. Test the UnpassableBlock and the UnstopableBall by adding them to the engine in AcademyPopcornMain.cs file.
            //for (int i = 5; i < 20; i++)
            //{
            //    UnpassableBlock unpassableBlock = new UnpassableBlock(new MatrixCoords(8, i));
            //
            //    engine.AddObject(unpassableBlock);
            //}
            //
            //UnstopableBall theBall = new UnstopableBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));
            //
            //engine.AddObject(theBall);

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);
        }
Beispiel #16
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));
                engine.AddObject(currBlock);
                Block currBlock2 = new Block(new MatrixCoords(startRow + 2, i));
                engine.AddObject(currBlock2);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
              //  engine.AddObject(theBall);
            //7.Test the MeteoriteBall by replacing the normal ball in the AcademyPopcornMain.cs file.

               // MeteoriteBall theMeteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1), 3);
               // engine.AddObject(MatrixCoords);

            //9.Test the UnpassableBlock and the UnstoppableBall by adding them to the engine in AcademyPopcornMain.cs file

            UnstoppableBall unstopBall=new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
            engine.AddObject(unstopBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            //add side walls
            /*1.The AcademyPopcorn class contains an IndestructibleBlock class. Use it to create side and ceiling walls to the game.
             * You can ONLY edit the AcademyPopcornMain.cs file. */

            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock leftWallBlock = new IndestructibleBlock(new MatrixCoords(row, 0));
                engine.AddObject(leftWallBlock);
                IndestructibleBlock rightWallBlock = new IndestructibleBlock(new MatrixCoords(row,WorldCols-1));
                engine.AddObject(rightWallBlock);

            }

            for (int row = 0; row < WorldCols; row++)
            {
                 IndestructibleBlock topper = new IndestructibleBlock(new MatrixCoords(0, row));
                engine.AddObject(topper);
               // IndestructibleBlock bottem = new IndestructibleBlock(new MatrixCoords(WorldRows-2, row));
               // engine.AddObject(bottem);
            }

             for (int i = 1; i < WorldCols; i+=5)
            {
                ExplodingBlock explosion = new ExplodingBlock(new MatrixCoords(3, i));
                engine.AddObject(explosion);
            }

            for (int i = 1; i < WorldCols; i += 5)
            {
                GiftBlock giftBlock = new GiftBlock(new MatrixCoords(4, i));
                engine.AddObject(giftBlock);
            }

            ShootingRacket shoot = new ShootingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(shoot);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            // 05.Trail object
            TrailObject tempObject = new TrailObject(new MatrixCoords(15, 15), new char[,] { { 'o' } }, 3);
            engine.AddObject(tempObject);

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            // 01.Side and ceiling walls
            for (int i = startRow; i < WorldRows+1; i++)
            {
                IndestructibleBlock leftWall = new IndestructibleBlock(new MatrixCoords(i - 1, 0));

                engine.AddObject(leftWall);
            }

            for (int i = startRow; i < WorldRows+1; i++)
            {
                IndestructibleBlock rightWall = new IndestructibleBlock(new MatrixCoords(i - 1, WorldCols - 1));

                engine.AddObject(rightWall);
            }

            for (int i = 0; i <= WorldCols-1; i++)
            {
                IndestructibleBlock ceiling = new IndestructibleBlock(new MatrixCoords(1, i));

                engine.AddObject(ceiling);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            // 07. Test meteroite ball
            //MeteroiteBall theBall = new MeteroiteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));

            // 09. Test UnstoppableBall
            //Ball theUnstopableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 4), new MatrixCoords(0, 3));
            //engine.AddObject(theUnstopableBall);

            //for (int i = 2; i < WorldCols/2; i+=4)
            //{
            //    engine.AddObject(new UnpassableBlock(new MatrixCoords(4, i)));
            //}
            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock;
                if (i == 7)
                {
                    currBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                }
                else
                {
                    currBlock = new Block(new MatrixCoords(startRow, i));
                }

                engine.AddObject(currBlock);
            }


            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
Beispiel #18
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow + 1, i));
                engine.AddObject(currBlock);
            }

            for (int i = startCol; i < endCol; i++)
            {
                if (i % 4 == 0)
                {
                    GiftBlock giftBlock = new GiftBlock(new MatrixCoords(startRow + 2, i));
                    engine.AddObject(giftBlock);
                }
                else
                {
                    Block currBlock = new Block(new MatrixCoords(startRow + 2, i));
                    engine.AddObject(currBlock);
                }
            }

            // [Task 1] Adding left and right wall
            for (int row = startRow - 1; row < WorldRows; row++)
            {
                IndestructibleBlock leftWall = new IndestructibleBlock(new MatrixCoords(row, startCol - 1));
                engine.AddObject(leftWall);

                IndestructibleBlock rightWall = new IndestructibleBlock(new MatrixCoords(row, endCol));
                engine.AddObject(rightWall);
            }

            // [Task 1] Adding ceiling wall
            for (int col = startCol - 1; col < endCol; col++)
            {
                IndestructibleBlock topWall = new IndestructibleBlock(new MatrixCoords(startRow - 1, col));
                engine.AddObject(topWall);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 1),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            //UnstoppableBall unstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 1),
            //    new MatrixCoords(-1, 1));

            //engine.AddObject(unstoppableBall);

            //Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            //engine.AddObject(theRacket);

            ShootingRacket shootingRacket = new ShootingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(shootingRacket);

            //Gift testGift = new Gift(new MatrixCoords(7, 15));
            //engine.AddObject(testGift);

            //Bullet testBullet = new Bullet(new MatrixCoords(20, 15));
            //engine.AddObject(testBullet);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            // add a few gift blocks
            for (int i = startCol; i < endCol; i++)
            {
                GiftBlock currBlock = new GiftBlock(new MatrixCoords(startRow + 1, i));

                engine.AddObject(currBlock);
            }

            Ball ball = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(ball);

            // test the meteorite ball
            //MeteoriteBall theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));

            //engine.AddObject(theBall);

            // test the unstoppable ball
            //UnstoppableBall unstoppable = new UnstoppableBall(new MatrixCoords(5, 5),
            //    new MatrixCoords(1, 1));

            //engine.AddObject(unstoppable);

            //Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            //engine.AddObject(theRacket);

            ShootingRacket shootingRacket = new ShootingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2));
            engine.AddObject(shootingRacket);

            // add left side
            int topMost = 2;
            int leftMost = 1;
            int sideHeight = 20;
            for (int i = topMost; i < sideHeight + topMost; i++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(i, leftMost)));
            }

            // add ceiling
            int ceilingWidth = 39;
            for (int i = leftMost; i < ceilingWidth; i++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(2, i)));
            }

            // add right side
            int rightMost = 38;
            for (int i = topMost; i < sideHeight + topMost; i++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(i, rightMost)));
            }

            // add exploding blocks
            topMost += 3;
            for (int i = topMost; i < sideHeight; i++)
            {
                engine.AddObject(new ExplodingBlock(new MatrixCoords(i, 25)));
            }

            // add gifts
            engine.AddObject(new Gift(new MatrixCoords(5, 5)));
            engine.AddObject(new Gift(new MatrixCoords(6, 9)));
            engine.AddObject(new Gift(new MatrixCoords(5, 14)));
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }
            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow + 1, i));

                engine.AddObject(currBlock);
            }
            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow + 2, i));

                engine.AddObject(currBlock);
            }
            for (int i = startCol; i < endCol / 3; i++)
            {
                UnpassableBlock currBlock = new UnpassableBlock(new MatrixCoords(startRow + 4, i));

                engine.AddObject(currBlock);
            }

            // Exploding blocks. Chain reaction :)
            for (int i = endCol/2; i < endCol; i++)
            {
                ExplodingBlock currBlock = new ExplodingBlock(new MatrixCoords(startRow + 3, i));

                engine.AddObject(currBlock);
            }

            //Gift testGift = new Gift(new MatrixCoords(10, 20));
            //engine.AddObject(testGift);

            GiftBlock giftBlock = new GiftBlock(new MatrixCoords(7, 25));
            engine.AddObject(giftBlock);

            // TASK 1
            startCol = 0;
            endCol = WorldRows - 1;

            for (int i = startRow; i < endCol; i++) // LEFT SIDE
            {
                IndestructibleBlock currBlock = new IndestructibleBlock(new MatrixCoords(i, startCol));

                engine.AddObject(currBlock);
            }

            startCol = WorldCols - 1;

            for (int i = startRow; i < endCol; i++) // RIGHT SIDE
            {
                IndestructibleBlock currBlock = new IndestructibleBlock(new MatrixCoords(i, startCol));

                engine.AddObject(currBlock);
            }

            startRow = 2;
            startCol = 0;
            endCol = WorldCols;

            for (int i = startCol; i < endCol; i++) // CEILING
            {
                IndestructibleBlock currBlock = new IndestructibleBlock(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            // END TASK 1

            // Bellow the three balls are added to the engine
            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            MeteoriteBall theMeteoriteBall = new MeteoriteBall(new MatrixCoords(20, 9),
                new MatrixCoords(-1, 1));

            UnstoppableBall theUnstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 25),
               new MatrixCoords(-1, 1));

            engine.AddObject(theBall);
            engine.AddObject(theMeteoriteBall);
            engine.AddObject(theUnstoppableBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            // Part of TASK 5
            //TrailObject trailObject = new TrailObject(new MatrixCoords(10, 20), 5);

            //engine.AddObject(trailObject);
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i += 3) // row 3 will be full of unpassable blocks
            {
                UnpassableBlock currBlock = new UnpassableBlock(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            startRow = 4;
            for (int i = startCol; i < endCol; i++) // row 4 will be full of blocks
            {
                if (i % 4 != 0)
                {
                    Block currBlock = new Block(new MatrixCoords(startRow, i));
                    engine.AddObject(currBlock);
                }
                else
                {
                    // but we will put  an Exploding Block on each 4-th position
                    ExplodingBlock currBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                    engine.AddObject(currBlock);
                }
            }

            startRow = 6;
            for (int i = startCol; i < endCol; i += 6) // row 6 will have gift blocks on each 6-th position
            {
                GiftBlock currBlock = new GiftBlock(new MatrixCoords(startRow, i));
                engine.AddObject(currBlock);
            }
            // Task 5: test TrailObject
            //TrailObject tr = new TrailObject(new MatrixCoords(WorldRows / 2, WorldCols / 2));
            //engine.AddObject(tr);

            // Task 7: test MeteoriteBall
            // MeteoriteBall theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));
            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
            // Task 9: test Unstoppable Ball and Unpassable Block
            //UnstoppableBall theBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0),
            //    new MatrixCoords(-1, 1));
            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            // adds top row wall (ceiling)
            for (int i = 0; i < WorldCols; i++)
            {
                IndestructibleBlock wallCell = new IndestructibleBlock(new MatrixCoords(0, i));
                engine.AddObject(wallCell);
            }

            // adds left and right walls)
            for (int i = 1; i < WorldRows; i++)
            {
                IndestructibleBlock wallCell = new IndestructibleBlock(new MatrixCoords(i, 0));
                engine.AddObject(wallCell);
                wallCell = new IndestructibleBlock(new MatrixCoords(i, WorldCols-1));
                engine.AddObject(wallCell);
            }
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            #region Add Indestructible Blocks as ball delimeters

            for (int row = 0; row < WorldRows; row++)
            {
                for (int col = 0; col < WorldCols; col++)
                {
                    IndestructibleBlock currBlock = null;
                    if (row == 0)
                    {
                        currBlock = new IndestructibleBlock(new MatrixCoords(row, col));
                        engine.AddObject(currBlock);
                    }
                    else
                    {
                        if (col == 0 || col == WorldCols - 1)
                        {
                            currBlock = new IndestructibleBlock(new MatrixCoords(row, col));
                            engine.AddObject(currBlock);
                        }
                    }

                }
            }
            #endregion

            #region Add TrailObject

            //TrailObject trailObject = new TrailObject(new MatrixCoords(WorldRows, WorldCols),
            //                                          new char[,] { { '°' } }, 5);
            //engine.AddObject(trailObject);

            #endregion

            #region Add Blocks

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));
                Block currBlock2 = new Block(new MatrixCoords(startRow + 1, i));
                engine.AddObject(currBlock);
                engine.AddObject(currBlock2);
            }
            #endregion

            #region Add unpassable Blocks

            //for (int i = startCol; i < endCol; i = i + 4)
            //{
            //    UnpassableBlock unpassableBlock = new UnpassableBlock(new MatrixCoords(startRow + 5, i));

            //    engine.AddObject(unpassableBlock);
            //}
            for (int i = startCol; i < endCol; i = i + 3)
            {
                UnpassableBlock unpassableBlock = new UnpassableBlock(new MatrixCoords(WorldRows - 8, i));

                engine.AddObject(unpassableBlock);
            }
            #endregion

            #region Add exploding Blocks

            for (int i = startCol; i < endCol; i = i + 1)
            {
                ExplodingBlock expoldingBlock = new ExplodingBlock(new MatrixCoords(startRow + 2, i));

                engine.AddObject(expoldingBlock);
            }
            #endregion

            #region Add gift Blocks

            for (int i = startCol; i < endCol; i++)
            {
                GiftBlock giftBlock = new GiftBlock(new MatrixCoords(startRow + 3, i));

                engine.AddObject(giftBlock);
            }
            #endregion

            #region Add Meteorite Ball

            MeteoriteBall meteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            #endregion

            #region Add unstoppableBall Ball

            UnstoppableBall unstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            #endregion

            #region Add Ball

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
            #endregion

            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
        static void Initialize(Engine engine)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            // I've added the following lines to adjust the size of the console so it's not unnecessarily big
            //================================================================================================= Addition>
            Console.WindowHeight = WorldRows + 2;
            Console.WindowWidth = WorldCols + 1;
            Console.BufferHeight = Console.WindowHeight;
            Console.BufferWidth = Console.WindowWidth;
            //================================================================================================= >Addition

            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            //01. The AcademyPopcorn class contains an IndestructibleBlock class. Use it to create side and ceiling walls
            //    to the game. You can ONLY edit the AcademyPopcornMain.cs file.
            //================================================================================================== Task 01>
            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock leftWallBlock = new IndestructibleBlock(new MatrixCoords(row, 0));
                engine.AddObject(leftWallBlock);

                IndestructibleBlock rightWallBlock = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));
                engine.AddObject(rightWallBlock);
            }

            for (int col = 0; col < WorldCols; col++)
            {
                IndestructibleBlock ceilingBlock = new IndestructibleBlock(new MatrixCoords(0, col));
                engine.AddObject(ceilingBlock);
            }
            //================================================================================================== >Task 01

            for (int i = startCol; i < endCol; i++)
            {
                if (i % 3 != 1)
                {
                    Block regularBlock = new Block(new MatrixCoords(startRow, i));
                    engine.AddObject(regularBlock);
                }
                else
                {
                    // Test ExplodingBlock (TASK 10)
                    //========================================================================================= Addition>
                    ExplodingBlock explodingBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                    engine.AddObject(explodingBlock);
                    //========================================================================================= >Addition
                }
            }

            for (int i = startCol + 5; i < endCol - 5; i++)
            {
                if (i % 3 != 1)
                {
                    Block regularBlock = new Block(new MatrixCoords(startRow + 4, i));
                    engine.AddObject(regularBlock);
                }
                else
                {
                    // Test GiftBlock and Gift (TASK 11 & 12)
                    //========================================================================================= Addition>
                    GiftBlock giftBlock = new GiftBlock(new MatrixCoords(startRow + 4, i));
                    engine.AddObject(giftBlock);
                    //========================================================================================= >Addition
                }
            }

            //09. Test the UnpassableBlock and the UnstoppableBall by adding them to the engine in AcademyPopcornMain.cs file
            //================================================================================================== Task 09>
            for (int i = startCol + 10; i < endCol - 10; i++)
            {
                UnpassableBlock unpassableBlock = new UnpassableBlock(new MatrixCoords(startRow + 2, i));
                engine.AddObject(unpassableBlock);
            }
            //================================================================================================== >Task 09

            //07. Test the MeteoriteBall by replacing the normal ball in the AcademyPopcornMain.cs file.
            //================================================================================================== Task 07>
            // You just need to comment the line below \/
            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //MeteoriteBall theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //================================================================================================== Task 09>>
            //UnstoppableBall theBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //========================================================================================= >>Task 09 >Task 07

            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(theRacket);

            // Testing TrailObject
            //=============================================================================================== Testing 05>
            //for (int i = 1; i < 10; i++)
            //{
            //    TrailObject trail = new TrailObject(new MatrixCoords(i * 2, 3 + i * 2), 10);
            //    engine.AddObject(trail);
            //}
            //=============================================================================================== >Testing 05
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                if (i == 7) // first hit is that brick
                {
                    currBlock = new ExplodeBlock(new MatrixCoords(startRow, i));
                }

                if (i == 17)  // adding gift object
                {
                    currBlock = new GiftBlock(new MatrixCoords(startRow, i));
                }

                engine.AddObject(currBlock);
            }

            // Adding Unpassable Blocks
            for (int i = 10; i < 15; i++)
            {
                UnpassableBlock unpassableBlock = new UnpassableBlock(new MatrixCoords(5, i));
                engine.AddObject(unpassableBlock);
            }

            // Adding Unstoppable Ball
            //UnstoppableBall unstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //engine.AddObject(unstoppableBall);

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            engine.AddObject(theBall);

            //MeteoriteBall meteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));

            //engine.AddObject(meteoriteBall);
            //engine.AddObject(meteoriteBall.Tail);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            for (int i = 0; i < WorldRows; i++)
            {
                IndestructibleBlock leftWall = new IndestructibleBlock(new MatrixCoords(i, 0));
                engine.AddObject(leftWall);

                IndestructibleBlock rightWall = new IndestructibleBlock(new MatrixCoords(i, WorldCols - 1));
                engine.AddObject(rightWall);
            }

            for (int i = 0; i < WorldCols; i++)
            {
                IndestructibleBlock ceiling = new IndestructibleBlock(new MatrixCoords(0, i));
                engine.AddObject(ceiling);
            }
        }
Beispiel #25
0
        // Drawing all objects
        static void Initialize(Engine engine)
        {
            // Wall coordinates
            for (int col = 0; col < WorldCols; col += WallGap)
            {
                if (col > WorldCols / 3 && col < 2 * WorldCols / 3) col += WallGap;
                for (int width = col; width < col + WallWidth; width++)
                {
                    for (int row = 0; row <= ((col != 0 && col < WorldCols - WallGap) ? WorldRows - 1 : WorldRows); row++)
                    {
                        if (col != 0 && col < WorldCols - WallGap && row == 2) row = 6;
                        if (col > WallGap && col < WorldCols - WallGap && row == 17) row = 22;
                        IndestructibleBlock Wall = new IndestructibleBlock(new MatrixCoords(row, width));
                        engine.AddObject(Wall);
                    }
                }
            }

            // Ceiling coordinates
            for (int col = 0; col < WorldCols; col++)
            {
                IndestructibleBlock ceiling = new IndestructibleBlock(new MatrixCoords(0, col));
                engine.AddObject(ceiling);
            }

            // Floor coordinates
            for (int col = 0; col < WorldCols - 1; col++)
            {
                if (col == WallGap + WallWidth) col = 3 * WallGap;
                IndestructibleBlock floor = new IndestructibleBlock(new MatrixCoords(WorldRows - 1, col));
                engine.AddObject(floor);
            }

            // Block coordinates
            for (int row = 0; row < BlockLines; row++)
            {
                if (row == 2) row = 3;
                for (int col = WallGap + WallWidth + 1; col < 3 * WallGap - 1; col++)
                {
                    if (row == 4 && (col == 3 * WallGap / 2 || col == 5 * WallGap / 2)) col++;
                    Block currBlock = new Block(new MatrixCoords(StartBlockRow + row, col));
                    engine.AddObject(currBlock);
                }
            }

            for (int col = WallGap + WallWidth + 1; col < 3 * WallGap - 1; col++)
            {
                if (col == WallGap + 7) col = 3 * WallGap - 5;
                Block currBlock2 = new Block(new MatrixCoords(5, col));
                engine.AddObject(currBlock2);
            }

            for (int row = 0; row < WorldRows - 2 * BlockLines + 1; row += 3)
            {
                for (int col = WallWidth + 1; col < WorldCols - WallWidth - 1; col++)
                {
                    if (col == WallGap - 1) col = 3 * WallGap + WallWidth + 1;
                    Block currBlock = new Block(new MatrixCoords(StartBlockRow + row, col));
                    engine.AddObject(currBlock);
                }
            }

            for (int col = WallGap + WallWidth + 5; col < 3 * WallGap - 5; col++)
            {
                UnpassableBlock unpassBlock = new UnpassableBlock(new MatrixCoords(5, col));
                engine.AddObject(unpassBlock);
            }

            ExplodingBlock exploBlock1 = new ExplodingBlock(new MatrixCoords(7, 3 * WallGap / 2));
            engine.AddObject(exploBlock1);
            ExplodingBlock exploBlock2 = new ExplodingBlock(new MatrixCoords(7, 5 * WallGap / 2));
            engine.AddObject(exploBlock2);

            // Ball coordinates
            Ball theBall = new Ball(new MatrixCoords(2 * WorldRows / 3, WorldCols / 2 - 10), new MatrixCoords(-1, 1));
            engine.AddObject(theBall);

            // Meteorite ball coordinates
            MeteoriteBall meteoBall = new MeteoriteBall(new MatrixCoords(WorldRows - 1, 1), new MatrixCoords(-1, 1));
            engine.AddObject(meteoBall);

            MeteoriteBall meteoBall2 = new MeteoriteBall(new MatrixCoords(WorldRows - 1, 3), new MatrixCoords(-1, 1));
            engine.AddObject(meteoBall2);

            MeteoriteBall meteoBall3 = new MeteoriteBall(new MatrixCoords(WorldRows - 1, 7), new MatrixCoords(-1, 1));
            engine.AddObject(meteoBall3);

            // Unstoppable ball coordinates
            UnstoppableBall unstopBall = new UnstoppableBall(new MatrixCoords(WorldRows - 8, WorldCols - WallWidth - 3), new MatrixCoords(-1, -1));
            engine.AddObject(unstopBall);

            // Racket coordinates
            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, (WorldCols - RacketLength) / 2), RacketLength);
            engine.AddObject(theRacket);

            // Gift coordinates
            for (int col = WallGap + 3; col < 3 * WallGap - 1; col++)
            {
                GiftBlock gift = new GiftBlock(new MatrixCoords(1, col));
                engine.AddObject(gift);
            }
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            //ordinary ball
            Ball theBall = new Ball(new MatrixCoords(WorldRows / 3, 0),
                new MatrixCoords(-1, 1));
            //engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2 - 3), RacketLength);

            engine.AddObject(theRacket);

            /*1.The AcademyPopcorn class contains an IndestructibleBlock class. Use it to create side and ceiling walls to the game.
             You can ONLY edit the AcademyPopcornMain.cs file.*/
            for (int row = startRow - 1; row < WorldRows; row++)
            {
                IndestructibleBlock leftWallBlock = new IndestructibleBlock(new MatrixCoords(row, startCol - 1),
                    IndestructibleBlock.SymbolWall);
                engine.AddObject(leftWallBlock);
                IndestructibleBlock rightWallBlock = new IndestructibleBlock(new MatrixCoords(row, endCol),
                    IndestructibleBlock.SymbolWall);
                engine.AddObject(rightWallBlock);
            }
            //create ceiling (using symbolTop = "_")
            for (int col = startCol - 1; col < WorldCols - 1; col++)
            {
                IndestructibleBlock topWallBlock = new IndestructibleBlock(new MatrixCoords(1, col),
                    IndestructibleBlock.SymbolTop);
                engine.AddObject(topWallBlock);
            }

            TrailObject comet = new TrailObject(new MatrixCoords(WorldRows / 2, WorldCols / 4), new char[,] { { '*' } }, 8);
            engine.AddObject(comet);

            //7.Test the MeteoriteBall by replacing the normal ball in the AcademyPopcornMain.cs file.
            MeteoriteBall metBall = new MeteoriteBall(new MatrixCoords(WorldRows / 3, 0),
                new MatrixCoords(-1, 1), 3);
            //engine.AddObject(metBall);

            //9.Test the UnpassableBlock and the UnstoppableBall by adding them to the engine in AcademyPopcornMain.cs file
            UnstoppableBall unstopBall = new UnstoppableBall(new MatrixCoords(WorldRows / 3, 0), new MatrixCoords(-1, 1));
            engine.AddObject(unstopBall);

            for (int i = 3; i < WorldCols - 2; i = i + 2)
            {
                UnpassableBlock unpassableBlock = new UnpassableBlock(new MatrixCoords(4, i), 'U');
                engine.AddObject(unpassableBlock);
            }

            for (int i = 2; i < WorldCols; i = i + 2)
            {
              ExplodingBlock bombBlock = new ExplodingBlock(new MatrixCoords(4, i), 'B');
              engine.AddObject(bombBlock);
            }

            for (int i = 2; i < WorldCols; i = i + 2)
            {
                GiftBlock giftBlock = new GiftBlock(new MatrixCoords(5, i), 'G');
                engine.AddObject(giftBlock);
            }
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

            // Add some exploding blocks
            for (int i = startCol; i < endCol - 1; i++)
            {
                Block currBlock = new ExplodingBlock(new MatrixCoords(startRow + 1, i));

                engine.AddObject(currBlock);
            }

            Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            // Side walls
            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock indestrBlock = new IndestructibleBlock(new MatrixCoords(row, 0));

                engine.AddObject(indestrBlock);

                indestrBlock = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));

                engine.AddObject(indestrBlock);
            }

            // Ceiling
            for (int col = 0; col < WorldCols; col++)
            {
                IndestructibleBlock indestrBlock = new IndestructibleBlock(new MatrixCoords(0, col));

                engine.AddObject(indestrBlock);
            }

            // Some trail object: body - 'T'
            TrailObject trailObj = new TrailObject(20, new MatrixCoords(10, 15), new char[,] { { 'T' } });

            engine.AddObject(trailObj);

            // Some unpassable blocks: body - 'X'
            for (int col = 4; col < WorldCols - 12; col += 3)
            {
                UnpassableBlock unpassBlock = new UnpassableBlock(new MatrixCoords(6, col));

                engine.AddObject(unpassBlock);
            }

            // Unpassable wall and ceiling (we can't edit the other classes so the
            // unstoppable ball will go throw indestructable block but we cant edit it!).
            for (int col = 1; col < WorldCols - 1; col++)
            {
                UnpassableBlock unpassBlock = new UnpassableBlock(new MatrixCoords(1, col));

                engine.AddObject(unpassBlock);
            }

            for (int row = 2; row < WorldRows; row++)
            {
                UnpassableBlock unpassBlock = new UnpassableBlock(new MatrixCoords(row, WorldCols - 2));

                engine.AddObject(unpassBlock);
            }
        }