Exemple #1
0
        public GameDoc()
        {
            boja.Add(5, "MediumPurple");
            boja.Add(4, "MidnightBlue");
            boja.Add(3, "LimeGreen");
            boja.Add(2, "Gold");
            boja.Add(1, "Firebrick");
            Point ballCenter = new Point(400, 500);

            Ball = new Ball(ballCenter, Color.Black);
            Point FloorPoint = new Point(400, 520);

            FBlock = new FloorBlock(FloorPoint, Color.Black);
            Blocks = new List <Block>();
            Score  = 0;
        }
Exemple #2
0
        public void IsColiding(FloorBlock block)
        {
            bool collisionX = Center.X + RADIUS >= block.Corner.X && block.Corner.X + block.Width >= Center.X - RADIUS;
            bool collisionY = Center.Y + RADIUS >= block.Corner.Y && block.Corner.Y + 20 >= Center.Y - RADIUS;

            if (collisionX && collisionY)
            {
                double otsecka = -velocityX * 50;
                if ((Center.X <= block.Corner.X + block.Width * 0.25) && (Center.X >= block.Corner.X))
                {
                    //  if (Center.X - otsecka < block.Corner.X + block.Width * 0.25)
                    //  {
                    velocityX = velocityX * -1;
                    velocityY = -velocityY;
                    //  }

                    /* else
                     * {
                     *   velocityY = -velocityY;
                     * }*/
                }
                else if ((Center.X <= block.Corner.X + block.Width) && (Center.X >= block.Corner.X + block.Width * 0.75))
                {
                    //  if (Center.X - otsecka > block.Corner.X + block.Width)
                    // {
                    velocityX = velocityX * -1;
                    velocityY = -velocityY;

                    /*  }
                     * else
                     * {
                     *    velocityY = -velocityY;
                     * }
                     */
                }
                else
                {
                    velocityY = -velocityY;
                }
            }
        }