Example #1
0
        /// <summary>
        /// Move slider left on keyboard left. Also handles explicit collision detection because of a bug with slider moving
        /// </summary>
        /// <param name="x">The value by which slider will move left in a single frame</param>
        /// <param name="ball">To detect collision with ball</param>
        /// <param name="brickManager">To detect collision with brick</param>
        /// <param name="gameFrame">Detect collision with screen edges</param>
        /// <param name="lifelost">Boolean variable to store if ball went below slider and a life was lost</param>
        /// <param name="hit">Sound when collision occurs</param>
        public void MoveLeft(int x, ref Ball ball, ref BricksManager brickManager, ref Rectangle gameFrame, ref bool lifelost, SoundEffectInstance hit)
        {
            //for every unit movement of the slider to the left
            for (int i = 0; i < x; i++)
            {
                boundingBox.X--;
                ball.UpdatePosition(brickManager, gameFrame, this, ref lifelost, hit, x); //note slow down factor, since UpdatePosition is called 'x' times

                //this was an explicit bug fix. Slider used to cross over the ball
                if (checkCollision(ball.getBoundingBox()))
                {
                    boundingBox.X+=3;

                }
            }
        }