Exemple #1
0
 public Point(MatrixCoordinates topLeft, int lifeTime)
     : base(topLeft, new char[, ] {
     { '1' }
 })
 {
     this.LifeTime = lifeTime;
 }
Exemple #2
0
 public StartTitle(MatrixCoordinates topLeft)
     : base(topLeft,
     new char[,] { 
         {'╔','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','╗'},
         {'║', 'P','r','e','s','s',' ','E','n','t','e','r',' ','t','o',' ','s','t','a','r','t',' ','g','a','m','e','║'},
     {'╚','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','═','╝'},})
 {
 }
Exemple #3
0
 public Alien(MatrixCoordinates topLeft)
     : base(topLeft, 
     new char[,] { 
     { ' ', ' ', '▀', '▄', ' ', ' ', ' ', '▄', '▀', ' ', ' ' },
     {' ', '▄', '█', '▀', '█', '█', '█', '▀', '█', '▄', ' ' },
     {'█', '▀', '█', '▀', '█', '█', '█', '▀', '█', '▀', '█' },
     {'▀', ' ', '▀', '▄', '▄', ' ', '▄', '▄', '▀', ' ', '▀' }})
 {
 }
Exemple #4
0
 public StartTitle(MatrixCoordinates topLeft)
     : base(topLeft,
            new char[, ] {
     { '╔', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '╗' },
     { '║', 'P', 'r', 'e', 's', 's', ' ', 'E', 'n', 't', 'e', 'r', ' ', 't', 'o', ' ', 's', 't', 'a', 'r', 't', ' ', 'g', 'a', 'm', 'e', '║' },
     { '╚', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '═', '╝' },
 })
 {
 }
Exemple #5
0
 public Spaceship(MatrixCoordinates topLeft, int width)
     : base(topLeft, 
     new char[,] { 
     {' ', ' ', '▄', '█', '▄', ' ', ' ' },
     {'█', '█', '█', '█', '█', '█', '█' } })
 {
     this.Width = width;
     this.body = GetRacketBody(this.Width);
 }
 public Alien(MatrixCoordinates topLeft)
     : base(topLeft,
            new char[, ] {
     { ' ', ' ', '▀', '▄', ' ', ' ', ' ', '▄', '▀', ' ', ' ' },
     { ' ', '▄', '█', '▀', '█', '█', '█', '▀', '█', '▄', ' ' },
     { '█', '▀', '█', '▀', '█', '█', '█', '▀', '█', '▀', '█' },
     { '▀', ' ', '▀', '▄', '▄', ' ', '▄', '▄', '▀', ' ', '▀' }
 })
 {
 }
Exemple #7
0
 public Spaceship(MatrixCoordinates topLeft, int width)
     : base(topLeft,
            new char[, ] {
     { ' ', ' ', '▄', '█', '▄', ' ', ' ' },
     { '█', '█', '█', '█', '█', '█', '█' }
 })
 {
     this.Width = width;
     this.body  = GetRacketBody(this.Width);
 }
Exemple #8
0
        public CollisionData(MatrixCoordinates collisionForceDirection, List<string> hitObjectsCollisionGroupStrings)
        {
            this.CollisionForceDirection = collisionForceDirection;

            this.hitObjectsCollisionGroupStrings = new List<string>();

            foreach (var str in hitObjectsCollisionGroupStrings)
            {
                this.hitObjectsCollisionGroupStrings.Add(str);
            }
        }
Exemple #9
0
        protected GameObject(MatrixCoordinates topLeft, char[,] body)
        {
            this.TopLeft = topLeft;

            int imageRows = body.GetLength(0);
            int imageCols = body.GetLength(1);

            this.body = this.CopyBodyMatrix(body);

            this.IsDestroyed = false;
        }
Exemple #10
0
        protected GameObject(MatrixCoordinates topLeft, char[,] body)
        {
            this.TopLeft = topLeft;

            int imageRows = body.GetLength(0);
            int imageCols = body.GetLength(1);

            this.body = this.CopyBodyMatrix(body);

            this.IsDestroyed = false;
        }
Exemple #11
0
        public CollisionData(MatrixCoordinates collisionForceDirection, List <string> hitObjectsCollisionGroupStrings)
        {
            this.CollisionForceDirection = collisionForceDirection;

            this.hitObjectsCollisionGroupStrings = new List <string>();

            foreach (var str in hitObjectsCollisionGroupStrings)
            {
                this.hitObjectsCollisionGroupStrings.Add(str);
            }
        }
Exemple #12
0
        public void EnqueueForRendering(IRenderable obj)
        {
            char[,] objImage = obj.GetImage();

            int imageRows = objImage.GetLength(0);
            int imageCols = objImage.GetLength(1);

            MatrixCoordinates objTopLeft = obj.GetTopLeft();

            int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows);
            int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols);

            for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
                {
                    if (row >= 0 && row < renderContextMatrixRows &&
                        col >= 0 && col < renderContextMatrixCols)
                    {
                        renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
                    }
                }
            }
        }
Exemple #13
0
 public AlienBullet(MatrixCoordinates topLeft)
     : base(topLeft, new char[,] { { '▼' } }, new MatrixCoordinates(1, 0))
 {
 }
Exemple #14
0
 public Wall(MatrixCoordinates upperLeft,char [,] body)
     : base(upperLeft,body)
 {
 }
Exemple #15
0
 public MovingObjects(MatrixCoordinates topLeft, char[,] body, MatrixCoordinates speed)
     : base(topLeft, body)
 {
     this.Speed = speed;
 }
Exemple #16
0
 public Bullet(MatrixCoordinates topLeft, MatrixCoordinates speed)
     : base(topLeft, new char[, ] {
     { '▀' }
 }, speed)
 {
 }
Exemple #17
0
 public MovingObjects(MatrixCoordinates topLeft, char[,] body, MatrixCoordinates speed)
     : base(topLeft, body)
 {
     this.Speed = speed;
 }
Exemple #18
0
 public AlienBullet(MatrixCoordinates topLeft)
     : base(topLeft, new char[, ] {
     { '▼' }
 }, new MatrixCoordinates(1, 0))
 {
 }
Exemple #19
0
 public CollisionData(MatrixCoordinates collisionForceDirection, string objectCollisionGroupString)
 {
     this.CollisionForceDirection         = collisionForceDirection;
     this.hitObjectsCollisionGroupStrings = new List <string>();
     this.hitObjectsCollisionGroupStrings.Add(objectCollisionGroupString);
 }
Exemple #20
0
 public Wall(MatrixCoordinates upperLeft, char [,] body)
     : base(upperLeft, body)
 {
 }
Exemple #21
0
 public Bullet(MatrixCoordinates topLeft, MatrixCoordinates speed)
     : base(topLeft, new char[,] { { '▀' } }, speed)
 {
 }
        private static void HandleMovingWithStaticCollisions(List<MovingObjects> movingObjects, List<GameObject> staticObjects)
        {
            foreach (var movingObject in movingObjects)
            {
                int verticalIndex = VerticalCollisionIndex(movingObject, staticObjects);
                int horizontalIndex = HorizontalCollisionIndex(movingObject, staticObjects);

                MatrixCoordinates movingCollisionForceDirection = new MatrixCoordinates(0, 0);

                if (verticalIndex != -1)
                {
                    movingCollisionForceDirection.Row = -movingObject.Speed.Row;
                    staticObjects[verticalIndex].RespondToCollision(
                        new CollisionData(new MatrixCoordinates(movingObject.Speed.Row, 0),
                            movingObject.GetCollisionGroupString())
                            );
                }

                if (horizontalIndex != -1)
                {
                    movingCollisionForceDirection.Col = -movingObject.Speed.Col;
                    staticObjects[horizontalIndex].RespondToCollision(
                        new CollisionData(new MatrixCoordinates(0, movingObject.Speed.Col),
                            movingObject.GetCollisionGroupString())
                            );
                }

                int diagonalIndex = -1;
                if (horizontalIndex == -1 && verticalIndex == -1)
                {
                    diagonalIndex = DiagonalCollisionIndex(movingObject, staticObjects);
                    if (diagonalIndex != -1)
                    {
                        movingCollisionForceDirection.Row = -movingObject.Speed.Row;
                        movingCollisionForceDirection.Col = -movingObject.Speed.Col;

                        staticObjects[diagonalIndex].RespondToCollision(
                        new CollisionData(new MatrixCoordinates(movingObject.Speed.Row, 0),
                            movingObject.GetCollisionGroupString())
                            );
                    }
                }

                List<string> hitByMovingCollisionGroups = new List<string>();

                if (verticalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[verticalIndex].GetCollisionGroupString());
                }

                if (horizontalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[horizontalIndex].GetCollisionGroupString());
                }

                if (diagonalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[diagonalIndex].GetCollisionGroupString());
                }

                if (verticalIndex != -1 || horizontalIndex != -1 || diagonalIndex != -1)
                {
                    movingObject.RespondToCollision(
                        new CollisionData(movingCollisionForceDirection,
                            hitByMovingCollisionGroups)
                            );
                }
            }
        }
Exemple #23
0
 public CollisionData(MatrixCoordinates collisionForceDirection, string objectCollisionGroupString)
 {
     this.CollisionForceDirection = collisionForceDirection;
     this.hitObjectsCollisionGroupStrings = new List<string>();
     this.hitObjectsCollisionGroupStrings.Add(objectCollisionGroupString);
 }
Exemple #24
0
        public override bool Equals(object obj)
        {
            MatrixCoordinates objAsMatrixCoordinates = obj as MatrixCoordinates;

            return(objAsMatrixCoordinates.Row == this.Row && objAsMatrixCoordinates.Col == this.Col);
        }
        private static void HandleMovingWithStaticCollisions(List <MovingObjects> movingObjects, List <GameObject> staticObjects)
        {
            foreach (var movingObject in movingObjects)
            {
                int verticalIndex   = VerticalCollisionIndex(movingObject, staticObjects);
                int horizontalIndex = HorizontalCollisionIndex(movingObject, staticObjects);

                MatrixCoordinates movingCollisionForceDirection = new MatrixCoordinates(0, 0);

                if (verticalIndex != -1)
                {
                    movingCollisionForceDirection.Row = -movingObject.Speed.Row;
                    staticObjects[verticalIndex].RespondToCollision(
                        new CollisionData(new MatrixCoordinates(movingObject.Speed.Row, 0),
                                          movingObject.GetCollisionGroupString())
                        );
                }

                if (horizontalIndex != -1)
                {
                    movingCollisionForceDirection.Col = -movingObject.Speed.Col;
                    staticObjects[horizontalIndex].RespondToCollision(
                        new CollisionData(new MatrixCoordinates(0, movingObject.Speed.Col),
                                          movingObject.GetCollisionGroupString())
                        );
                }

                int diagonalIndex = -1;
                if (horizontalIndex == -1 && verticalIndex == -1)
                {
                    diagonalIndex = DiagonalCollisionIndex(movingObject, staticObjects);
                    if (diagonalIndex != -1)
                    {
                        movingCollisionForceDirection.Row = -movingObject.Speed.Row;
                        movingCollisionForceDirection.Col = -movingObject.Speed.Col;

                        staticObjects[diagonalIndex].RespondToCollision(
                            new CollisionData(new MatrixCoordinates(movingObject.Speed.Row, 0),
                                              movingObject.GetCollisionGroupString())
                            );
                    }
                }

                List <string> hitByMovingCollisionGroups = new List <string>();

                if (verticalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[verticalIndex].GetCollisionGroupString());
                }

                if (horizontalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[horizontalIndex].GetCollisionGroupString());
                }

                if (diagonalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[diagonalIndex].GetCollisionGroupString());
                }

                if (verticalIndex != -1 || horizontalIndex != -1 || diagonalIndex != -1)
                {
                    movingObject.RespondToCollision(
                        new CollisionData(movingCollisionForceDirection,
                                          hitByMovingCollisionGroups)
                        );
                }
            }
        }
Exemple #26
0
 public Point(MatrixCoordinates topLeft, int lifeTime)
     : base(topLeft, new char[,]{{'1'}})
 {
     this.LifeTime = lifeTime;
 }