Example #1
0
        private void checkForCupcakeCollisions()
        {
            foreach (Actor cupcake in cupcakes)
            {
                //if (cupcake.getRectangle().Intersects(leftWheel.getRectangle()) || cupcake.getRectangle().Intersects(rightWheel.getRectangle()))
                //{
                //    cupcakes.Remove(cupcake);
                //    break;
                //}

                if (cupcake.Position.Y < 250.0f)
                {
                    cupcake.Velocity = Vector2.Zero;

                    if (cupcake.Position.X < 250)
                    {
                        cupcake.Position = new Vector2(leftWheel.Position.X - 32, leftWheel.Position.Y + 32);
                        leftWheel.takeCupcake(cupcake);
                    }
                    else
                    {
                        cupcake.Position = new Vector2(rightWheel.Position.X - 32, rightWheel.Position.Y + 32);
                        rightWheel.takeCupcake(cupcake);
                    }
                    cupcakes.Remove(cupcake);
                    break;
                }
            }
        }
Example #2
0
        //CheckForCupcakeCollisions looks at each cupcake in the list of cupcakes and checks for "collisions" with certain locations on the screen.
        private void checkForCupcakeCollisions()
        {
            foreach (Actor cupcake in cupcakes)
            {
                //if (cupcake.getRectangle().Intersects(leftWheel.getRectangle()) || cupcake.getRectangle().Intersects(rightWheel.getRectangle()))
                //{
                //    cupcakes.Remove(cupcake);
                //    break;
                //}
                //If a cupcake moves up to where the trays are located, stop its movement.
                if (cupcake.Position.Y < 250.0f)
                {
                    cupcake.Velocity = Vector2.Zero;

                    //If the cupcake is near the leftwheel and can be added, add to the left wheel.
                    if (cupcake.Position.X < 250)
                    {
                        cupcake.Position = new Vector2(leftWheel.Position.X - 32, leftWheel.Position.Y + 32);
                        leftWheel.takeCupcake(cupcake);
                    }
                    else //If the cupcake is near the rightwheel and can be added, add to the right wheel.
                    {
                        cupcake.Position = new Vector2(rightWheel.Position.X - 32, rightWheel.Position.Y + 32);
                        rightWheel.takeCupcake(cupcake);
                    }
                    cupcakes.Remove(cupcake);
                    break;
                }
            }
        }