AddObject() публичный Метод

public AddObject ( AcademyPopcorn.GameObject obj ) : void
obj AcademyPopcorn.GameObject
Результат void
Пример #1
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);
            }

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

            //engine.AddObject(ball);
            //ex 6
            MeteoriteBall mball = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            engine.AddObject(mball);
            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock leftWall = new IndestructibleBlock(new MatrixCoords(row, 0));
                engine.AddObject(leftWall);
                IndestructibleBlock rigthWall = new IndestructibleBlock(new MatrixCoords(row, WorldCols-1));
                engine.AddObject(rigthWall);
            }
            //ex 5
            //TrailObject lifeObj = new TrailObject(new MatrixCoords(4, 10), new char[,] { { '#' } }, 8);
            //engine.AddObject(lifeObj);
        }
        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 = 1;
            int endCol = WorldCols - 1;
            int endRow = 10;

            //generate level
            for (int i = startCol; i < endCol; i++)
            {
                for (int j = startRow; j < endRow; j++)
                {
                    Block currBlock = BlockFactory.GetBlock(generator.Next(1, 10), new MatrixCoords(j, i));

                    engine.AddObject(currBlock);
                }
            }

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

            Ball megaBall = new UnstoppableBall(new MatrixCoords(WorldRows - 1, WorldCols/2 +1), new MatrixCoords(-1, 1));

            engine.AddObject(megaBall);

            //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;
            int endRow = WorldRows - 15;

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

            //AddTrailObjects(engine); /* Task 5 */

            /*** BLOCKS ***/
            AddWalls(engine); /* Task 1 */
            //AddUnpassableBlocks(engine, startCol, endCol, startRow); /* Task 9 */
            //AddExplodingBlocks(engine, startCol, endCol, startRow); /* Task 10 */
            //AddGiftBlocks(engine, startCol, endCol, startRow); /* Task 12 */
            AddRandomBlocks(engine, startCol, endCol, startRow, endRow);

            /*** BALLS ***/
            //AddMeteoriteBall(engine); /* Task 6 and 7 */
            AddUnstoppableBall(engine); /* Task 9 */
            //engine.AddObject(new Ball(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1)));

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

            for (int i = startCol; i < endCol; i++)
            {

                if (rnd.Next(startCol, WorldCols*2)> endCol)
                {
                    Block currBlock = new Block(new MatrixCoords(startRow, i));
                    engine.AddObject(currBlock);
                }
                else if (rnd.Next(startCol, WorldCols * 3) > endCol)
                {
                    ExplodingBlock boomBlock = new ExplodingBlock(new MatrixCoords(startRow, i));

                    engine.AddObject(boomBlock);
                }
                else if (rnd.Next(startCol, WorldCols * 4) > endCol)
                {
                    GiftBlock giftBlock = new GiftBlock(new MatrixCoords(startRow, i));

                    engine.AddObject(giftBlock);
                }
                else
                {
                    UnpassableBlock unpBlock = new UnpassableBlock(new MatrixCoords(startRow, i));
                    engine.AddObject(unpBlock);
                }

            }

            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);
            Racket newtheRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength + 1);
            engine.AddObject(newtheRacket);
            // Add side wallsя
            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 roof = new IndestructibleBlock(new MatrixCoords(0, col));
                engine.AddObject(roof);
            }
        }
Пример #6
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;
            for (int col = 0; col <WorldCols; col++)
            {
                IndestructibleBlock wallLeftBlock = new IndestructibleBlock(new MatrixCoords(0,col));
                engine.AddObject(wallLeftBlock);
            }
            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));
                if (i == 7) //the seventh block is the first block, being hit by the ball
                {
                    currBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                }
                else if (i == endCol-3) //you'll have to wait a little bit to see hit that block with the gift
                {
                    currBlock = new GiftBlock(new MatrixCoords(startRow, i));
                }
                engine.AddObject(currBlock);

            }
            //Add side walls
            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock wallLeftBlock = new IndestructibleBlock(new MatrixCoords(row, 0));
                engine.AddObject(wallLeftBlock);
                IndestructibleBlock wallRightBlock = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));
                engine.AddObject(wallRightBlock);
            }
            //trail object
            char[,] signOfTrail={{'*'}};
            TrailObject trail=new TrailObject(new MatrixCoords(13,13),signOfTrail,10);
            engine.AddObject(trail);

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

            engine.AddObject(secondBall);
            //engine.AddObject(theBall);

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

            engine.AddObject(theRacket);

               // adding an unpassable block and an unstoppable ball
            for (int i = 10; i < WorldRows; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(i, 8)));
            }

            engine.AddObject(new UnstoppableBall(new MatrixCoords(WorldRows - 1, WorldCols / 2 + 1), new MatrixCoords(-1, 1)));
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
        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);
            }

            // Task 1
            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);
            }

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

            engine.AddObject(theRacket);

            // Task 5, 6, 7
            MeteoriteBall meteor = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));

            engine.AddObject(meteor);

            // Task 8, 9
            UnstoppableBall unstoppable = new UnstoppableBall(new MatrixCoords(4, 4), new MatrixCoords(1, 1));

            engine.AddObject(unstoppable);
            UnpassableBlock unpassable = new UnpassableBlock(new MatrixCoords(9, 9));

            engine.AddObject(unpassable);
            // Task 10
            ExplodingBlock explodeBlock = new ExplodingBlock(new MatrixCoords(8, 8));

            engine.AddObject(explodeBlock);

            // Task 11, 12
            GiftBlock gift = new GiftBlock(new MatrixCoords(10, 10));

            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);
            }

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

                engine.AddObject(currBlock);
            }

            for (int i = startCol + 12; i < endCol - 7; i += 3)
            {
                ExplodingBlock currBlock = new ExplodingBlock(new MatrixCoords(startRow + 3, i));

                engine.AddObject(currBlock);
            }

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

                engine.AddObject(currBlock);
            }

            UnstopableBall theBall = new UnstopableBall(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);

            //Task 1
            for (int i = 0; i < WorldRows; i++)
            {
                IndestructibleBlock indBlock = new IndestructibleBlock(new MatrixCoords(i, WorldCols - 1));
                engine.AddObject(indBlock);

                indBlock = new IndestructibleBlock(new MatrixCoords(i, 0));
                engine.AddObject(indBlock);
            }

            for (int i = 1; i < WorldCols - 1; i++)
            {
                IndestructibleBlock indBlock = new IndestructibleBlock(new MatrixCoords(0, i));
                engine.AddObject(indBlock);
            }
        }
Пример #11
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), new [,] {{'#'}});

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

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

                engine.AddObject(currBlock);
            }

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

            for (int row = 3; row < WorldRows; row++)
            {
                UnpassableBlock leftWall = new UnpassableBlock(new MatrixCoords(row, 1));
                engine.AddObject(leftWall);
                UnpassableBlock rightWall = new UnpassableBlock(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);
            }

            //MeteoriteBall meteoriteBall = new MeteoriteBall(new MatrixCoords(7, 7), new MatrixCoords(1, 1));
            //engine.AddObject(meteoriteBall);

            UnstoppableBall unstoppableBall = new UnstoppableBall(new MatrixCoords(7, 7), new MatrixCoords(1, 1));
            engine.AddObject(unstoppableBall);

            ExplodingBlock explodingBlock = new ExplodingBlock(new MatrixCoords(startRow + 3, 15));
            engine.AddObject(explodingBlock);

            GiftBlock giftBlock = new GiftBlock(new MatrixCoords(startRow + 3, endCol - 1));
            engine.AddObject(giftBlock);
        }
Пример #12
0
        /// <summary>
        /// Task 1
        /// </summary>
        static void AddWalls(Engine engine)
        {
            for (int row = 1; row < WorldRows - 1; row++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(row, 0)));
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1)));
            }

            for (int col = 1; col < WorldCols - 1; col++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(1, col)));
            }
        }
        /// <summary>
        /// Task 1
        /// </summary>
        static void AddWalls(Engine engine)
        {
            for (int row = 1; row < WorldRows - 1; row++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(row, 0)));
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1)));
            }

            for (int col = 1; col < WorldCols - 1; col++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(1, col)));
            }
        }
Пример #14
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int endRow = WorldRows;
            int startCol = 2;
            int endCol = WorldCols - 2;


            //Task 1: Implementing Game field with adding a "for cycle" for rows
            //Task 10: Using UnpassableBlock 
            for (int row = startRow; row < endRow; row++)
            {
                for (int col = startCol; col < endCol; col++)
                {
                    if (row == startRow)
                    {
                        UnpassableBlock unpassable = new UnpassableBlock(new MatrixCoords(row, col));
                        engine.AddObject(unpassable);
                    }
                    if (row != startRow && (col == startCol || col == endCol - 1))
                    {
                        UnpassableBlock unpassable = new UnpassableBlock(new MatrixCoords(row, col));
                        engine.AddObject(unpassable);
                    }
                    else if (row <= startRow + 5 && row != startRow)
                    {
                        //Task12: Implementing GiftBlock.cs 
                        GiftBlock currBlock = new GiftBlock(new MatrixCoords(row, col));
                        engine.AddObject(currBlock);
                    }
                }

            }

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

            //Task7: Implementing Meteorit Ball 
            //MeteoritBall meteoritBall = new MeteoritBall(new MatrixCoords(WorldRows / 2, 10), new MatrixCoords(-1, 1));

            //Task9: Implement Unstoppable ball
            UnstoppableBall ultimateBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 10), new MatrixCoords(-1, 1));

            engine.AddObject(ultimateBall);

            //TODO - Task 13: Implementing Shooting Ability
            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++)
            {
                if (i == 3)
                {
                    ExplodingBlock expBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                    engine.AddObject(expBlock);
                    continue;
                }
                if (i == 2)
                {
                    GiftBlock giftblock = new GiftBlock(new MatrixCoords(startRow, i));
                    engine.AddObject(giftblock);
                    continue;
                }
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }

               // 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));
            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);

            for (int i = startRow; i < Console.BufferHeight; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(i, startCol - 1)));
            }
            for (int i = startRow; i < Console.BufferHeight; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(i, WorldCols - 2)));
            }
            for (int i = startCol-1; i < WorldCols-1; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(startRow - 1, i)));
            }
            Random rnd = new Random();
            for (int i = 0; i < 5; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords((rnd.Next(0, WorldCols)), (rnd.Next(0, WorldRows)))));
            }
        }
Пример #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;
                if (i == 7)
                {
                    currBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                }
                else if (i == endCol - 3)
                {
                    currBlock = new GiftBlock(new MatrixCoords(startRow, i));
                }
                else
                {
                    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);
            // Task7: Test MeteoriteBall
            //Ball theMeteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //engine.AddObject(theMeteoriteBall);

            #region
            // 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)));
             * }*/
            #endregion

            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(theRacket);
            //Task3
            Racket newtheRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength + 1);
            engine.AddObject(newtheRacket);
        }
        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);
            }

            // Task 1
            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);
            }

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

            engine.AddObject(theRacket);

            // Task 5, 6, 7
            MeteoriteBall meteor = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            engine.AddObject(meteor);

            // Task 8, 9
            UnstoppableBall unstoppable = new UnstoppableBall(new MatrixCoords(4,4), new MatrixCoords(1, 1));
            engine.AddObject(unstoppable);
            UnpassableBlock unpassable = new UnpassableBlock(new MatrixCoords(9, 9));
            engine.AddObject(unpassable);
            // Task 10
            ExplodingBlock explodeBlock = new ExplodingBlock( new MatrixCoords(8,8));
            engine.AddObject(explodeBlock);

            // Task 11, 12
            GiftBlock gift = new GiftBlock(new MatrixCoords(10, 10));
            engine.AddObject(gift);
        }
        private static void InitializeBlocks(Engine engine, int startRow, int startCol, int endCol)
        {
            for (int row = 0; row < 4; row++)
            {
                for (int i = startCol; i < endCol; i++)
                {
                    engine.AddObject(new Block(new MatrixCoords(startRow + row, i)));
                }
            }

            for (int i = startCol; i < endCol; i += 5)
            {
                engine.AddObject(new ExplodingBlock(new MatrixCoords(startRow + 2, i)));
            }
        }
        private static void InitializeBlocks(Engine engine, int startRow, int startCol, int endCol)
        {
            for (int row = 0; row < 2; row++)
            {
                for (int i = startCol; i < endCol; i++)
                {
                    engine.AddObject(new Block(new MatrixCoords(startRow + row, i)));
                }
            }

            for (int i = startCol; i < endCol; i += 5)
            {
                engine.AddObject(new GiftBlock(new MatrixCoords(startRow + 2, i)));
            }
        }
Пример #20
0
        //static method CreateWalls adds the boundaries of the game, using
        //UnpassableBlock and the variables WorldCol and WorldRow
        //can also work with IndesctructibleBlock

        static void CreateWalls(Engine engine)
        {
            for (int i = 0; i < WorldCols; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(0, i)));
            }
            for (int i = 0; i < WorldRows; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(i, 0)));
                engine.AddObject(new UnpassableBlock(new MatrixCoords(i, WorldCols - 1)));
            }

            char[,] welcomeMessage = { { 'S', 'T', 'A', 'R', 'T' } };
            engine.AddObject(new TrailObject(new MatrixCoords(10, 15), welcomeMessage, 4));
        }
        //static method CreateWalls adds the boundaries of the game, using
        //UnpassableBlock and the variables WorldCol and WorldRow
        //can also work with IndesctructibleBlock
        static void CreateWalls(Engine engine)
        {
            for (int i = 0; i < WorldCols; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(0, i)));
            }
            for (int i = 0; i < WorldRows; i++)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(i, 0)));
                engine.AddObject(new UnpassableBlock(new MatrixCoords(i, WorldCols - 1)));
            }

            char[,] welcomeMessage = { { 'S', 'T', 'A', 'R', 'T' } };
            engine.AddObject(new TrailObject(new MatrixCoords(10, 15), welcomeMessage, 4));
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;

            for (int col = startCol; col < endCol; col++)
            {
                if (col == (WorldCols - 2) / 4 || col == WorldCols / 2 ||
                    col == WorldCols - 10 || col == WorldCols - 5) // Task 12: Testing the classes Gift and GiftBlock
                {
                    engine.AddObject(new GiftBlock(new MatrixCoords(startRow, col)));
                    continue;
                }
                Block currBlock = new Block(new MatrixCoords(startRow, col));
                engine.AddObject(currBlock);
            }

            // Task 1: Creating the side walls
            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock leftSideWallBlock = new IndestructibleBlock(new MatrixCoords(row, 0));
                engine.AddObject(leftSideWallBlock);
                IndestructibleBlock rightSideWallBlock = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));
                engine.AddObject(rightSideWallBlock);
            }

            // Task 1: Creating the ceiling wall
            for (int col = 1; col < WorldCols - 1; col++)
            {
                IndestructibleBlock ceilingWallBlock = new IndestructibleBlock(new MatrixCoords(0, col));
                engine.AddObject(ceilingWallBlock);
            }

            // Task 10: Testing the ExplodingBlock class
            //engine.AddObject(new ExplodingBlock(new MatrixCoords(startRow + 3, startCol + 4)));
            //engine.AddObject(new ExplodingBlock(new MatrixCoords(startRow + 3, startCol + 3)));
            //engine.AddObject(new ExplodingBlock(new MatrixCoords(startRow + 3, startCol + 5)));
            //engine.AddObject(new ExplodingBlock(new MatrixCoords(startRow + 3, startCol + 7)));

            // Task 7: Replacing the normal ball with meteorite ball
            MeteoriteBall metoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            engine.AddObject(metoriteBall);

            //// Task 9: Testing the UnstoppableBall class
            //UnstoppableBall unstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            //engine.AddObject(unstoppableBall);

            // Task 9: Testing the UnpassableBlock class
            for (int col = 5; col < WorldCols; col += 15)
            {
                engine.AddObject(new UnpassableBlock(new MatrixCoords(5, col)));
            }

            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);
        }
Пример #24
0
 private static void InitializeWalls(Engine engine)
 {
     for (int row = 0; row < WorldRows; row++)
     {
         IndestructibleBlock wall = new IndestructibleBlock(new MatrixCoords(row, 0));
         engine.AddObject(wall);
         wall = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));
         engine.AddObject(wall);
     }
     //ceiling
     for (int col = 1; col < WorldCols-1; col++)
     {
         IndestructibleBlock wall = new IndestructibleBlock(new MatrixCoords(0, col));
         engine.AddObject(wall);
     }
 }
 /// <summary>
 /// Task 9
 /// </summary>
 static void AddUnpassableBlocks(Engine engine, int startCol, int endCol, int startRow)
 {
     for (int i = startCol + 5; i < endCol; i += 2)
     {
         engine.AddObject(new UnpassableBlock(new MatrixCoords(startRow + 4, i)));
     }
 }
Пример #26
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));
                ExplodingBlock expBlock = new ExplodingBlock(new MatrixCoords(startRow + 2,i));
                Block someMoreBlock = new Block(new MatrixCoords(startRow + 1, i));
                engine.AddObject(currBlock);
                engine.AddObject(expBlock);
                engine.AddObject(someMoreBlock);
            }

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

            engine.AddObject(theBall);

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

            engine.AddObject(theRacket);

            //add sides
            for (int row = 0; row < WorldRows; row++)
            {
                IndestructibleBlock leftIndestructibleBlock = new IndestructibleBlock(new MatrixCoords(row,0));
                engine.AddObject(leftIndestructibleBlock);
                IndestructibleBlock rightIndestructibleBlock = new IndestructibleBlock(new MatrixCoords(row, WorldCols-1));
                engine.AddObject(rightIndestructibleBlock);
            }
            //add roof
            for (int col = 0; col < WorldCols; col++)
            {
                IndestructibleBlock topIndestructibleBlock = new IndestructibleBlock(new MatrixCoords(0,col));
                engine.AddObject(topIndestructibleBlock);
            }

            Gift gift = new Gift(new MatrixCoords(0,10));
            engine.AddObject(gift);

            GiftBlock giftBlock = new GiftBlock(new MatrixCoords(7,33));
            engine.AddObject(giftBlock);
        }
Пример #27
0
        private static void CreateFieldBorders(Engine engine, int startRow, int startCol, int endCol)
        {
            for (int i = startRow; i < WorldRows; i++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(i, startCol)));
            }

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

            for (int i = startCol; i <= endCol; i++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(startRow - 1, i)));
            }
        }
        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 10
                if (i == 7)
                {
                    currBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                }

                //task 12
                else if (i == endCol - 3)
                {
                    currBlock = new GiftBlock(new MatrixCoords(startRow, i));
                }

                engine.AddObject(currBlock);
            }

            /* 07. Test the MeteoriteBall by replacing the normal ball in the AcademyPopcornMain.cs file.*/
            /* Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
                new MatrixCoords(-1, 1));
            */
            Ball theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2 + 1, 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
           /* Ball theUnstopableBall = new UnstopableBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1));
            engine.AddObject(theUnstopableBall);

            for (int i = 2; i < WorldCols / 2; i += 4)
            {
                engine.AddObject(new UnpassableBlocks(new MatrixCoords(4, i)));
            }
            */
            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);

        }
        private static void CreateFieldBorders(Engine engine, int startRow, int startCol, int endCol)
        {
            for (int i = startRow; i < WorldRows; i++)
            {
                engine.AddObject(new IndestructibleBlock(new MatrixCoords(i, startCol)));
            }

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

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

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

                engine.AddObject(indBlock);
            }

            for (int i = 1; i < WorldRows; i++)
            {
                IndestructibleBlock indBlock = new IndestructibleBlock(new MatrixCoords(i, 0));

                engine.AddObject(indBlock);
            }

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

                engine.AddObject(indBlock);
            }

            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);

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

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

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

            engine.AddObject(theUnsBall);

            UnpassableBlock theUnpasBlock = new UnpassableBlock(new MatrixCoords(WorldRows - 19, WorldCols - 21));

            engine.AddObject(theUnpasBlock);

            GiftBlock theGiftBlock = new GiftBlock(new MatrixCoords(5, 7));

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

            InitializeBlocks(engine, startRow, startCol, endCol);
            CreateFieldBorders(engine, startRow, startCol, endCol);

            Ball theBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 2),
                                               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;

            InitializeBlocks(engine, startRow, startCol, endCol);
            CreateFieldBorders(engine, startRow, startCol, endCol);

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

            engine.AddObject(theBall);

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

            engine.AddObject(theRacket);
        }
Пример #33
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);
            }

            // 01. Adding the ceiling
            // Adding the top wall
            startCol -= 2;
            startRow -= 2;
            for (int i = startCol; i < WorldCols; i++)
            {
                IndestructibleBlock topWall = new IndestructibleBlock(new MatrixCoords(startRow, i));
                engine.AddObject(topWall);
            }

            // Adding the left wall
            startRow = 2;
            startCol = 0;
            for (int i = startRow; i < WorldRows; i++)
            {
                IndestructibleBlock currWall = new IndestructibleBlock(new MatrixCoords(i, startCol));
                engine.AddObject(currWall);
            }

            // Adding the right wall
            startRow = 2;
            startCol = WorldCols - 1;
            for (int i = startRow; i < WorldRows; i++)
            {
                IndestructibleBlock currWall = new IndestructibleBlock(new MatrixCoords(i, startCol));
                engine.AddObject(currWall);
            }

            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);

            // 05. Initialize Trailing object
            // !!! The Object disapears instantly - Must find why!!!
            TrailObject simpleTrailObject = new TrailObject(new MatrixCoords(10, 10), new char[, ] {
                { '$' }
            }, 500);

            engine.AddObject(simpleTrailObject);
        }
 /// <summary>
 /// Adding random blocks
 /// </summary>
 static void AddRandomBlocks(Engine engine, int startCol, int endCol, int startRow, int endRow)
 {
     for (int j = startRow + 1; j < endRow; j++)
     {
         for (int i = startCol; i < endCol; i++)
         {
             engine.AddObject(RandomBlock.GenerateRandomBlock(new MatrixCoords(j, i)));
         }
     }
 }
        private static void AddGameFieldWalls(Engine engine)
        {
            // add left and right wolls
            for (int row = 2; row < WorldRows; row++)
            {
                var leftWoll  = new IndestructibleBlock(new MatrixCoords(row, 0));
                var rightWoll = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));

                engine.AddObject(leftWoll);
                engine.AddObject(rightWoll);
            }

            // add roof
            for (int col = 0; col < WorldCols; col++)
            {
                var roof = new IndestructibleBlock(new MatrixCoords(1, col));

                engine.AddObject(roof);
            }
        }
        private static void AddGameFieldWalls(Engine engine)
        {
            // add left and right wolls
            for (int row = 2; row < WorldRows; row++)
            {
                var leftWoll = new IndestructibleBlock(new MatrixCoords(row, 0));
                var rightWoll = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));

                engine.AddObject(leftWoll);
                engine.AddObject(rightWoll);
            }

            // add roof
            for (int col = 0; col < WorldCols; col++)
            {
                var roof = new IndestructibleBlock(new MatrixCoords(1, col));

                engine.AddObject(roof);
            }
        }
        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 SetBorders(Engine engine)
 {
     //left border
     for (int row = 0; row < WorldRows; row++)
     {
         IndestructibleBlock borderLeft = new IndestructibleBlock(new MatrixCoords(row, 0));
         engine.AddObject(borderLeft);
     }
     //right border
     for (int row = 0; row < WorldRows; row++)
     {
         IndestructibleBlock borderRight = new IndestructibleBlock(new MatrixCoords(row, WorldCols - 1));
         engine.AddObject(borderRight);
     }
     //top
     for (int col = 0; col < WorldCols; col++)
     {
         IndestructibleBlock borderTop = new IndestructibleBlock(new MatrixCoords(0, col));
         engine.AddObject(borderTop);
     }
 }
        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 meteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 2), new MatrixCoords(-1, 1));

            engine.AddObject(meteoriteBall);

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

            engine.AddObject(theRacket);
        }
Пример #40
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol   = WorldCols - 2;

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

                engine.AddObject(currBlock);
            }

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

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

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

            engine.AddObject(theBall);

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

            engine.AddObject(theRacket);
        }
Пример #41
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);
                
                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);
        }
Пример #42
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol   = WorldCols - 2;

            // 1. adding ceiling and left/right walls
            for (int i = startRow - 1; i < WorldRows; i++)
            {
                UnpassableBlock newIndBlockLeft  = new UnpassableBlock(new MatrixCoords(i, startCol - 1));
                UnpassableBlock newIndBlockRight = new UnpassableBlock(new MatrixCoords(i, endCol));
                engine.AddObject(newIndBlockRight);
                engine.AddObject(newIndBlockLeft);
            }
            for (int i = startCol - 1; i <= endCol; i++)
            {
                UnpassableBlock newTopBlock = new UnpassableBlock(new MatrixCoords(startRow - 2, i));
                engine.AddObject(newTopBlock);
            }


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

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

                engine.AddObject(currBlock);
            }

            TrailObject trailer = new TrailObject(new MatrixCoords(WorldRows / 2, WorldCols / 2), new char[, ] {
                { 'H', 'E', 'L', 'L', 'O' }
            }, 5);

            engine.AddObject(trailer);

            // the ball is here
            Ball theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 3), new MatrixCoords(-1, 1));

            engine.AddObject(theBall);

            // the racket - moves with A/D and space shoots
            Racket theRacket = new ShootingRacket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);

            engine.AddObject(theRacket);
        }
        private static void AddExplodingBlocks(Engine engine)
        {
            int startRow = 4;
            int startCol = 8;
            int endCol = 19;

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

                engine.AddObject(currBlock);
            }
        }
        private static void AddGiftBlocks(Engine engine)
        {
            int startRow = 6;
            int startCol = 10;
            int endCol = 19;

            for (int col = startCol; col < endCol; col++)
            {
                var currBlock = new GiftBlock(new MatrixCoords(startRow, col), new FireGift());

                engine.AddObject(currBlock);
            }
        }
Пример #45
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);
            }

            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);
        }
        private static void AddUnpassableBlocks(Engine engine)
        {
            int startRow = 13;
            int startCol = 2;
            int endCol   = 19;

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

                engine.AddObject(currBlock);
            }
        }
        private static void AddExplodingBlocks(Engine engine)
        {
            int startRow = 4;
            int startCol = 8;
            int endCol   = 19;

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

                engine.AddObject(currBlock);
            }
        }
        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);
        }
        private static void AddGiftBlocks(Engine engine)
        {
            int startRow = 6;
            int startCol = 10;
            int endCol   = 19;

            for (int col = startCol; col < endCol; col++)
            {
                var currBlock = new GiftBlock(new MatrixCoords(startRow, col), new FireGift());

                engine.AddObject(currBlock);
            }
        }
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol = WorldCols - 2;
            for (int i = startCol; i < endCol/2; i++)
            {
                Block currBlock = new Block(new MatrixCoords(startRow, i));

                engine.AddObject(currBlock);
            }
            for (int i = (endCol/2); i < endCol; i++) // making unpassable blocks
            {
                UnpassableBlock unpBlock = new UnpassableBlock(new MatrixCoords(startRow, i));
                engine.AddObject(unpBlock);
            }
            Ball theBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2 + 1 , 0), new MatrixCoords(-1, 1));
            Ball unstBall = new UnstoppableBall(new MatrixCoords(10, WorldCols - 1), new MatrixCoords(-1, -1)); //creating unstoppable ball
            engine.AddObject(unstBall);
            engine.AddObject(theBall);
            Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength);
            engine.AddObject(theRacket);
        }
Пример #51
0
        static void Main(string[] args)
        {
            IRenderer renderer = new ConsoleRenderer(WorldRows, WorldCols);
            IUserInterface keyboard = new KeyboardInterface();

            Engine gameEngine = new Engine(renderer, keyboard, 200);
            //indestructable blocks
            for (int i = 1; i < WorldRows; i++)
            {
                //gameEngine.AddObject(new IndestructibleBlock(new MatrixCoords(i, 0)));
                //gameEngine.AddObject(new IndestructibleBlock(new MatrixCoords(i, WorldCols - 1)));
                gameEngine.AddObject(new UnpassableBlock(new MatrixCoords(i, 0)));
                gameEngine.AddObject(new UnpassableBlock(new MatrixCoords(i, WorldCols - 1)));
            }
            for (int i = 0; i < WorldCols; i++)
            {
                //gameEngine.AddObject(new IndestructibleBlock(new MatrixCoords(1, i)));
                gameEngine.AddObject(new UnpassableBlock(new MatrixCoords(1, i)));
            }
            //end

            keyboard.OnLeftPressed += (sender, eventInfo) =>
            {
                gameEngine.MovePlayerRacketLeft();
            };

            keyboard.OnRightPressed += (sender, eventInfo) =>
            {
                gameEngine.MovePlayerRacketRight();
            };

            Initialize(gameEngine);

            //

            gameEngine.Run();
        }
Пример #52
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);
        }
        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++)
            {
                //ExplodingBlock currBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
                GiftBlock giftBlock = new GiftBlock(new MatrixCoords(startRow + 1, i));
                // engine.AddObject(currBlock);
                engine.AddObject(giftBlock);
            }
            // upper wall
            for (int col = 0; col < WorldCols; col++)
            {
                UnpassableBlocks block = new UnpassableBlocks(new MatrixCoords(0, col));
                engine.AddObject(block);
            }

            // left and right wall
            for (int row = 1; row < WorldRows; row++)
            {
                UnpassableBlocks leftblock  = new UnpassableBlocks(new MatrixCoords(row, 0));
                UnpassableBlocks rIghtblock = new UnpassableBlocks(new MatrixCoords(row, WorldCols - 1));
                engine.AddObject(leftblock);
                engine.AddObject(rIghtblock);
            }

            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);
            Racket theRacket1 = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2), RacketLength + 3);

            engine.AddObject(theRacket);
            engine.AddObject(theRacket1);
            //    Gift gift = new Gift(new MatrixCoords(0, 5));
            //    engine.AddObject(gift);
        }
 /// <summary>
 /// Task 6 and 7
 /// </summary>
 /// <param name="engine"></param>
 static void AddMeteoriteBall(Engine engine)
 {
     engine.AddObject(new MeteoriteBall(new MatrixCoords(WorldRows / 2, 0), new MatrixCoords(-1, 1)));
 }
 /// <summary>
 /// Task 5
 /// </summary>
 static void AddTrailObjects(Engine engine)
 {
     engine.AddObject(new TrailObject(new MatrixCoords(5, 5), 20));
     engine.AddObject(new TrailObject(new MatrixCoords(5, 10), 30));
     engine.AddObject(new TrailObject(new MatrixCoords(5, 15), 40));
 }
Пример #57
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol   = WorldCols - 2;

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

                engine.AddObject(indestructibleBlockLeft);
                engine.AddObject(indestructibleBlockRight);
            }

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

                engine.AddObject(indestructibleBlockTop);
            }

            Random random = new Random();

            for (int row = 0; row < 3; ++row)
            {
                for (int i = startCol; i < endCol; i++)
                {
                    int   rand = random.Next(4);
                    Block currBlock;
                    if (rand == 0)
                    {
                        currBlock = new ExplodingBlock(new MatrixCoords(startRow + row, i));
                    }
                    else if (rand == 1)
                    {
                        currBlock = new GiftBlock(new MatrixCoords(startRow + row, i));
                    }
                    else if (rand == 2)
                    {
                        currBlock = new UnpassableBlock(new MatrixCoords(startRow + row, i));
                    }
                    else
                    {
                        currBlock = new Block(new MatrixCoords(startRow + row, i));
                    }
                    engine.AddObject(currBlock);
                }
            }

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

            engine.AddObject(theBall);

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

            engine.AddObject(theRacket);

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

            // standart blocks

            #region Standart Blocks

            for (int row = 2; row < 5; row++)
            {
                for (int col = startCol; col < endCol; col++)
                {
                    Block standartBlock = new Block(new MatrixCoords(row, col));
                    engine.AddObject(standartBlock);
                }
            }

            #endregion

            #region GameField Walls

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

            for (int col = 0; col < WorldCols; col++)
            {
                IndestructibleBlock topWallBlock = new IndestructibleBlock(new MatrixCoords(startRow - 2, col));
                engine.AddObject(topWallBlock);
            }

            #endregion

            #region Impassable Blocks

            for (int col = 1; col < WorldCols - 1; col++)
            {
                //if (col == 1 || col == 2) continue;
                ImpassableBlock imBlock = new ImpassableBlock(new MatrixCoords(11, col));
                engine.AddObject(imBlock);
            }

            #endregion

            #region Explosion Blocks

            for (int col = 2; col < WorldCols - 1; col += 1)
            {
                ExplodingBlock expBlock = new ExplodingBlock(new MatrixCoords(5, col));
                engine.AddObject(expBlock);
            }

            #endregion

            #region Gift Blocks

            for (int col = 1; col < WorldCols - 1; col += 5)
            {
                GiftBlock giftBlocks = new GiftBlock(new MatrixCoords(6, col));
                engine.AddObject(giftBlocks);
            }

            #endregion

            Ball 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);
        }
Пример #59
0
        static void Initialize(Engine engine)
        {
            int startRow = 3;
            int startCol = 2;
            int endCol   = WorldCols - 2;

            #region Add some layers of ordinary blocks and a layer of exploding block in the middle

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock1 = new Block(new MatrixCoords(startRow, i));
                Block currBlock2 = new Block(new MatrixCoords(startRow + 1, i));
                Block currBlock3 = new Block(new MatrixCoords(startRow + 2, i));

                engine.AddObject(currBlock1);
                engine.AddObject(currBlock2);
                engine.AddObject(currBlock3);
            }

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

                engine.AddObject(currBlock);
            }

            for (int i = startCol; i < endCol; i++)
            {
                Block currBlock1 = new Block(new MatrixCoords(startRow + 4, i));
                Block currBlock2 = new Block(new MatrixCoords(startRow + 5, i));
                Block currBlock3 = new Block(new MatrixCoords(startRow + 6, i));

                engine.AddObject(currBlock1);
                engine.AddObject(currBlock2);
                engine.AddObject(currBlock3);
            }

            #endregion

            #region Add a layer of gift objects

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

            //    engine.AddObject(currBlock);
            //}

            #endregion

            #region Create side walls and a ceiling

            // create side walls
            for (int i = 0; i < WorldRows; i++)
            {
                // create a block for the left wall
                IndestructibleBlock leftWallBlock = new IndestructibleBlock(new MatrixCoords(i, 0));
                // create a block for the right wall
                IndestructibleBlock rightWallBlock = new IndestructibleBlock(new MatrixCoords(i, WorldCols - 1));

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

            for (int i = 0; i < WorldCols; i++)
            {
                // create a block for the ceiling
                IndestructibleBlock ceilingBlock = new IndestructibleBlock(new MatrixCoords(0, i));

                engine.AddObject(ceilingBlock);
            }

            #endregion

            #region Add an impassable wall

            //for (int i = startRow + 1; i < WorldRows; i++)
            //{
            //    // create an impassable block
            //    ImpassableBlock impassableBlock = new ImpassableBlock(new MatrixCoords(i, 2 * WorldCols / 3 + 2));

            //    engine.AddObject(impassableBlock);
            //}

            #endregion

            #region Create an ordinary ball

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

            #endregion

            #region Replace the ordinary ball with a MeteoriteBall object

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

            #endregion

            #region Replace the ordinary ball with an UnstoppableBall object

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

            #endregion

            engine.AddObject(theBall);

            #region Add the racket

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

            engine.AddObject(theRacket);

            #endregion

            #region Add an instance of the TrailObject class

            //TrailObject ephemera = new TrailObject(
            //    new MatrixCoords(WorldRows / 3, WorldCols / 3), new char[,] { { '@' } }, 10);

            //engine.AddObject(ephemera);

            #endregion

            #region Add a single gift

            Gift gift = new Gift(new MatrixCoords(WorldRows / 3, WorldCols / 3), new char[, ] {
                { '@' }
            });

            engine.AddObject(gift);

            #endregion
        }
 /// <summary>
 /// Task 9
 /// </summary>
 static void AddUnstoppableBall(Engine engine)
 {
     engine.AddObject(new UnstoppableBall(new MatrixCoords(WorldRows / 2 + 5, 0), new MatrixCoords(-1, 1)));
 }