Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Drawing;
  5. namespace AnimatedBalls
  6. {
  7.     /// <summary>
  8.     /// Enumerated values for the direction of the ball
  9.     /// </summary>
  10.     public enum Direction
  11.     {
  12.         LEFT, RIGHT, UP, DOWN, UP_LEFT, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT
  13.     }
  14.  
  15.     /// <summary>
  16.     /// The ball class
  17.     /// </summary>
  18.     public class Ball
  19.     {
  20.         #region Private Variables
  21.         private Color _ballColor;
  22.         private int _x;
  23.         private int _y;
  24.         private int _height;
  25.         private int _width;
  26.         private Direction _xDirection;
  27.         private Direction _yDirection;
  28.         private Direction _ballDirection;
  29.         private int _speed;
  30.         #endregion
  31.  
  32.         #region Properties
  33.         public Color BallColor
  34.         {
  35.             set
  36.             {
  37.                 _ballColor = value;
  38.             }
  39.             get
  40.             {
  41.                 return _ballColor;
  42.             }
  43.         }
  44.  
  45.         public int X
  46.         {
  47.             set
  48.             {
  49.                 _x = value;
  50.             }
  51.             get
  52.             {
  53.                 return _x;
  54.             }
  55.         }
  56.  
  57.         public int Y
  58.         {
  59.             set
  60.             {
  61.                 _y = value;
  62.             }
  63.             get
  64.             {
  65.                 return _y;
  66.             }
  67.         }
  68.  
  69.         public int Height
  70.         {
  71.             set
  72.             {
  73.                 _height = value;
  74.             }
  75.             get
  76.             {
  77.                 return _height;
  78.             }
  79.         }
  80.  
  81.         public int Width
  82.         {
  83.             set
  84.             {
  85.                 _width = value;
  86.             }
  87.             get
  88.             {
  89.                 return _width;
  90.             }
  91.         }
  92.  
  93.         public Direction XDirection
  94.         {
  95.             set
  96.             {
  97.                 _xDirection = value;
  98.             }
  99.             get
  100.             {
  101.                 return _xDirection;
  102.             }
  103.         }
  104.  
  105.         public Direction YDirection
  106.         {
  107.             set
  108.             {
  109.                 _yDirection = value;
  110.             }
  111.             get
  112.             {
  113.                 return _yDirection;
  114.             }
  115.         }
  116.  
  117.         public Direction BallDirection
  118.         {
  119.             set
  120.             {
  121.                 _ballDirection = value;
  122.             }
  123.             get
  124.             {
  125.                 return _ballDirection;
  126.             }
  127.         }
  128.  
  129.         public int Speed
  130.         {
  131.             set
  132.             {
  133.                 _speed = value;
  134.             }
  135.             get
  136.             {
  137.                 return _speed;
  138.             }
  139.         }
  140.         #endregion
  141.  
  142.         public Ball()
  143.         {
  144.             //
  145.             // Constructor
  146.             //
  147.         }
  148.  
  149.         public void DrawBall(Graphics g)
  150.         {
  151.             g.DrawEllipse(new Pen(_ballColor), _x, _y, _width, _height);
  152.             // Create solid brush.
  153.             SolidBrush redBrush = new SolidBrush(_ballColor);
  154.             // Fill ellipse on screen.
  155.             g.FillEllipse(redBrush, _x, _y, _width, _height);
  156. //            for (int conta = 0; conta < 600000; conta++)
  157. //                for (int conta1 = 0; conta1 < 500; conta1++) ;
  158.         }
  159.  
  160.         public void DrawBall(Graphics g, int move_x, int move_y)
  161.         {
  162.             _x = move_x;
  163.             _y = move_y;
  164.             DrawBall(g);
  165.         }
  166.  
  167.         public void MoveBall(Ball ball, int screenHeight, int screenWidth)
  168.         {
  169.  
  170.             // Check Boundary
  171.             // Check Direction
  172.             // if ball hits boundary
  173.             // check direction
  174.  
  175.             switch (ball._ballDirection)
  176.             {
  177.                 case Direction.UP:
  178.                     ball._y = ball._y - ball._speed;
  179.                     break;
  180.  
  181.                 case Direction.DOWN:
  182.                     ball._y = ball._y + ball._speed;
  183.                     break;
  184.  
  185.                 case Direction.LEFT:
  186.                     ball._x = ball._x - ball._speed;
  187.                     break;
  188.  
  189.                 case Direction.RIGHT:
  190.                     ball._x = ball._x + ball._speed;
  191.                     break;
  192.  
  193.                 case Direction.DOWN_RIGHT:
  194.                     ball._x = ball._x + ball._speed;
  195.                     ball._y = ball._y + ball._speed;
  196.                     break;
  197.  
  198.                 case Direction.UP_LEFT:
  199.                     ball._x = ball._x - ball._speed;
  200.                     ball._y = ball._y - ball._speed;
  201.                     break;
  202.  
  203.                 case Direction.UP_RIGHT:
  204.                     ball._x = ball._x + ball._speed;
  205.                     ball._y = ball._y - ball._speed;
  206.                     break;
  207.  
  208.                 case Direction.DOWN_LEFT:
  209.                     ball._x = ball._x - ball._speed;
  210.                     ball._y = ball._y + ball._speed;
  211.                     break;
  212.  
  213.             }
  214.  
  215.             // if ball hits any border then change direction
  216.  
  217.             // Ball touches TOP
  218.             if (ball._y <= 0)
  219.             {
  220.                 //ball._speed++;
  221.                 //ball._speed--;
  222.                 switch (ball._ballDirection)
  223.                 {
  224.                     case Direction.UP:
  225.                         ball._ballDirection = Direction.DOWN;
  226.                         break;
  227.                     case Direction.UP_RIGHT:
  228.                         ball._ballDirection = Direction.DOWN_RIGHT;
  229.                         break;
  230.                     case Direction.UP_LEFT:
  231.                         ball._ballDirection = Direction.DOWN_LEFT;
  232.                         break;
  233.  
  234.                 }
  235.             }
  236.  
  237.             // Ball Touches Bottom
  238.             if (ball._y >= screenHeight - ball._height)
  239.             {
  240.                 switch (ball._ballDirection)
  241.                 {
  242.                     case Direction.DOWN:
  243.                         ball._ballDirection = Direction.UP;
  244.                         break;
  245.  
  246.                     case Direction.DOWN_RIGHT:
  247.                         ball._ballDirection = Direction.UP_RIGHT;
  248.                         break;
  249.                     case Direction.DOWN_LEFT:
  250.                         ball._ballDirection = Direction.UP_LEFT;
  251.                         break;
  252.                 }
  253.             }
  254.  
  255.             // Ball Touches Right
  256.             if (ball._x >= screenWidth - ball._width)
  257.             {
  258.                 switch (ball._ballDirection)
  259.                 {
  260.                     case Direction.RIGHT:
  261.                         ball._ballDirection = Direction.LEFT;
  262.                         break;
  263.  
  264.                     case Direction.UP_RIGHT:
  265.                         ball._ballDirection = Direction.UP_LEFT;
  266.                         break;
  267.  
  268.                     case Direction.DOWN_RIGHT:
  269.                         ball._ballDirection = Direction.DOWN_LEFT;
  270.                         break;
  271.                 }
  272.             }
  273.  
  274.             // Ball Touches left
  275.             if (ball._x <= 0)
  276.             {
  277.                 switch (ball._ballDirection)
  278.                 {
  279.                     case Direction.LEFT:
  280.                         ball._ballDirection = Direction.RIGHT;
  281.                         break;
  282.                     case Direction.DOWN_LEFT:
  283.                         ball._ballDirection = Direction.DOWN_RIGHT;
  284.                         break;
  285.  
  286.                     case Direction.UP_LEFT:
  287.                         ball._ballDirection = Direction.UP_RIGHT;
  288.                         break;
  289.                     case Direction .DOWN_RIGHT :
  290.                         ball.BallDirection = Direction.DOWN_LEFT;
  291.                         break;
  292.                     case Direction .UP_RIGHT :
  293.                         ball.BallDirection = Direction.UP_LEFT;
  294.                         break;
  295.  
  296.                 }
  297.             }
  298.         } // end MOVEBALL
  299.  
  300.         //
  301.         //*****************************************************************************************
  302.         //*****************************************************************************************
  303.         //********************************** C  O  M  P  A  R  A   ********************************
  304.         //*****************************************************************************************
  305.         //*****************************************************************************************
  306.         public void Compara(Ball bola1, Ball bola2)
  307.         {
  308.             int xDiff = bola1._x - bola2._x;
  309.             int yDiff = bola1._y - bola2._y;
  310.             double distancia = Math.Sqrt(xDiff * xDiff + yDiff * yDiff);
  311.  
  312.             if(distancia <= 50)
  313.             switch (bola1._ballDirection)
  314.             {
  315.                 case Direction.UP:
  316.                     switch (bola2._ballDirection)
  317.                     {
  318.                         case Direction.UP_LEFT:
  319.                             {
  320.                                
  321.                                 bola1._ballDirection = Direction.DOWN;
  322.                                 bola2._ballDirection = Direction.UP;
  323.                             }
  324.                             break;
  325.                         case Direction.UP:
  326.                             if ((bola1._y < bola2._y) && (bola1._speed < bola2._speed))
  327.                                 bola1._speed += bola2._speed;
  328.                             break;
  329.                         case Direction.DOWN:
  330.                             if (bola1._y > bola2._y)
  331.                             {
  332.                                 bola1._ballDirection = Direction.DOWN;
  333.                                 bola2._ballDirection = Direction.UP;
  334.                             }
  335.                             break;
  336.                         case Direction.UP_RIGHT:
  337.                             {
  338.                                 bola1._ballDirection = Direction.DOWN;
  339.                                 bola2._ballDirection = Direction.UP;
  340.                             }
  341.                             break;
  342.                         case Direction.RIGHT:
  343.                             if (bola1._x > bola2._x)
  344.                                 if (bola1._y == bola2._y)
  345.                                 {
  346.                                     bola1._ballDirection = Direction.RIGHT;
  347.                                     bola2._ballDirection = Direction.LEFT;
  348.                                 }
  349.                                 else if (bola1._y < bola2._y)
  350.                                 {
  351.                                     bola1._ballDirection = Direction.UP_RIGHT;
  352.                                     bola2._ballDirection = Direction.DOWN_RIGHT;
  353.                                 }
  354.                                 else if (bola1._y > bola2._y)
  355.                                 {
  356.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  357.                                     bola2._ballDirection = Direction.UP_RIGHT;
  358.                                 }
  359.                             else
  360.                                     if (bola1._y == bola2._y)
  361.                                     {
  362.                                         bola1._ballDirection = Direction.DOWN_RIGHT;
  363.                                         bola2._ballDirection = Direction.UP_LEFT;
  364.                                     }
  365.                                     else if (bola1._y < bola2._y)
  366.                                     {
  367.                                         bola1._ballDirection = Direction.UP_RIGHT;
  368.                                         bola2._ballDirection = Direction.DOWN_RIGHT;
  369.                                     }
  370.                                     else if (bola1._y > bola2._y)
  371.                                     {
  372.                                         bola1._ballDirection = Direction.DOWN_RIGHT;
  373.                                         bola2._ballDirection = Direction.UP_RIGHT;
  374.                                     }
  375.                             break;
  376.                         case Direction.LEFT:
  377.                             if (bola1._x < bola2._x)
  378.                                 if (bola1._y == bola2._y)
  379.                                 {
  380.                                     bola1._ballDirection = Direction.UP_LEFT;
  381.                                     bola2._ballDirection = Direction.UP_RIGHT;
  382.                                 }
  383.                                 else if (bola1._y < bola2._y)
  384.                                 {
  385.                                     bola1._ballDirection = Direction.UP_LEFT;
  386.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  387.                                 }
  388.                                 else if (bola1._y > bola2._y)
  389.                                 {
  390.                                     bola1._ballDirection = Direction.LEFT;
  391.                                     bola2._ballDirection = Direction.UP_LEFT;
  392.                                 }
  393.                             else
  394.                                     if (bola1._y == bola2._y)
  395.                                     {
  396.                                         bola1._ballDirection = Direction.UP_LEFT;
  397.                                         bola2._ballDirection = Direction.DOWN_RIGHT;
  398.                                     }
  399.                                     else if (bola1._y < bola2._y)
  400.                                     {
  401.                                         bola1._ballDirection = Direction.UP_LEFT;
  402.                                         bola2._ballDirection = Direction.DOWN_LEFT;
  403.                                     }
  404.                                     else if (bola1._y > bola2._y)
  405.                                     {
  406.                                         bola1._ballDirection = Direction.LEFT;
  407.                                         bola2._ballDirection = Direction.UP_LEFT;
  408.                                     }
  409.                             break;
  410.                         case Direction.DOWN_RIGHT:
  411.                             if (bola1._y >= bola2._y)
  412.                                 if (bola1._x > bola2._x)
  413.                                 {
  414.                                     bola1._ballDirection = Direction.RIGHT;
  415.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  416.                                 }
  417.                                 else if (bola1._x == bola2._x)
  418.                                 {
  419.                                     bola1._ballDirection = Direction.DOWN;
  420.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  421.                                 }
  422.                                 else if (bola1._x < bola2._x)
  423.                                 {
  424.                                     bola1._ballDirection = Direction.UP_LEFT;
  425.                                     bola2._ballDirection = Direction.RIGHT;
  426.                                 }
  427.                             break;
  428.                         case Direction.DOWN_LEFT:
  429.                             if (bola1._y > bola2._y)
  430.                             {
  431.                                 if (bola1._x == bola2._x)
  432.                                 {
  433.                                     bola1._ballDirection = Direction.DOWN;
  434.                                     bola2._ballDirection = Direction.LEFT;
  435.                                 }
  436.                                 else if (bola1._x < bola2._x)
  437.                                 {
  438.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  439.                                     bola2._ballDirection = Direction.RIGHT;
  440.                                 }
  441.                                 else if (bola1._x > bola2._x)
  442.                                 {
  443.                                     bola1._ballDirection = Direction.RIGHT;
  444.                                     bola2._ballDirection = Direction.LEFT;
  445.                                 }
  446.                             }
  447.                             else if (bola1._y == bola2._y)
  448.                                 if (bola1._x < bola2._x)
  449.                                 {
  450.                                     bola1._ballDirection = Direction.LEFT;
  451.                                     bola2._ballDirection = Direction.DOWN;
  452.                                 }
  453.                             break;
  454.                     } //fin Switch(bola2)
  455.  
  456.                     break;  // de case UP  ********************************************************
  457.                 //
  458.                 //*********************************************************************************
  459.                 //************************   CASE D O W N   ***************************************
  460.                 //*********************************************************************************
  461.                 case Direction.UP_RIGHT :
  462.                     switch (bola2._ballDirection)
  463.                     {
  464.                         case Direction.UP_LEFT:
  465.                             {
  466.                                 bola1._ballDirection = Direction.DOWN_LEFT;
  467.                                 bola2._ballDirection = Direction.UP_RIGHT;
  468.                             }
  469.                             break;
  470.                         case Direction.UP:
  471.                             if ((bola1._y < bola2._y) && (bola1._speed < bola2._speed))
  472.                             {
  473.                                 bola1._speed += bola2._speed;
  474.                                 bola1._ballDirection = Direction.UP_LEFT ;
  475.                                 bola2._ballDirection = Direction.DOWN ;
  476.                             }
  477.                             break;
  478.                         case Direction.DOWN:
  479.                             if (bola1._y > bola2._y)
  480.                             {
  481.                                 bola1._ballDirection = Direction.UP;
  482.                                 bola2._ballDirection = Direction.DOWN_RIGHT ;
  483.                             }
  484.                             break;
  485.                         case Direction.UP_RIGHT:
  486.                             {
  487.                                 bola1._ballDirection = Direction.LEFT;
  488.                                 bola2._ballDirection = Direction.DOWN_LEFT ;
  489.                             }
  490.                             break;
  491.                         case Direction.RIGHT:
  492.                             if (bola1._x > bola2._x)
  493.                                 if (bola1._y == bola2._y)
  494.                                 {
  495.                                     bola1._ballDirection = Direction.RIGHT;
  496.                                     bola2._ballDirection = Direction.UP_LEFT;
  497.                                 }
  498.                                 else if (bola1._y < bola2._y)
  499.                                 {
  500.                                     bola1._ballDirection = Direction.RIGHT ;
  501.                                     bola2._ballDirection = Direction.DOWN;
  502.                                 }
  503.                                 else if (bola1._y > bola2._y)
  504.                                 {
  505.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  506.                                     bola2._ballDirection = Direction.UP_RIGHT;
  507.                                 }
  508.                             break;
  509.                         case Direction.LEFT:
  510.                             if (bola1._x < bola2._x)
  511.                                 if (bola1._y == bola2._y)
  512.                                 {
  513.                                     bola1._ballDirection = Direction.RIGHT;
  514.                                     bola2._ballDirection = Direction.UP_LEFT ;
  515.                                 }
  516.                                 else if (bola1._y < bola2._y)
  517.                                 {
  518.                                     bola1._ballDirection = Direction.UP_LEFT;
  519.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  520.                                 }
  521.                                 else if (bola1._y > bola2._y)
  522.                                 {
  523.                                     bola1._ballDirection = Direction.LEFT;
  524.                                     bola2._ballDirection = Direction.UP_LEFT;
  525.                                 }
  526.                             break;
  527.                         case Direction.DOWN_RIGHT:
  528.                             if (bola1._y >= bola2._y)
  529.                                 if (bola1._x > bola2._x)
  530.                                 {
  531.                                     bola1._ballDirection = Direction.UP_LEFT;
  532.                                     bola2._ballDirection = Direction.DOWN_LEFT ;
  533.                                 }
  534.                                 else if (bola1._x == bola2._x)
  535.                                 {
  536.                                     bola1._ballDirection = Direction.DOWN;
  537.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  538.                                 }
  539.                                 else if (bola1._x < bola2._x)
  540.                                 {
  541.                                     bola1._ballDirection = Direction.UP_LEFT;
  542.                                     bola2._ballDirection = Direction.RIGHT;
  543.                                 }
  544.                             break;
  545.                         case Direction.DOWN_LEFT:
  546.                             if (bola1._y > bola2._y)
  547.                             {
  548.                                 if (bola1._x == bola2._x)
  549.                                 {
  550.                                     bola1._ballDirection = Direction.DOWN;
  551.                                     bola2._ballDirection = Direction.LEFT;
  552.                                 }
  553.                                 else if (bola1._x < bola2._x)
  554.                                 {
  555.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  556.                                     bola2._ballDirection = Direction.RIGHT;
  557.                                 }
  558.                                 else if (bola1._x > bola2._x)
  559.                                 {
  560.                                     bola1._ballDirection = Direction.RIGHT;
  561.                                     bola2._ballDirection = Direction.LEFT;
  562.                                 }
  563.                             }
  564.                             else if (bola1._y == bola2._y)
  565.                                 if (bola1._x < bola2._x)
  566.                                 {
  567.                                     bola1._ballDirection = Direction.LEFT;
  568.                                     bola2._ballDirection = Direction.DOWN;
  569.                                 }
  570.                             break;
  571.                     } //fin Switch(bola2)
  572.  
  573.                     break;
  574.                
  575.                 case Direction.UP_LEFT :
  576.                     switch (bola2._ballDirection)
  577.                     {
  578.                         case Direction.UP_LEFT:
  579.                             {
  580.                                 bola1._ballDirection = Direction.DOWN_LEFT;
  581.                                 bola2._ballDirection = Direction.UP_RIGHT;
  582.                             }
  583.                             break;
  584.                         case Direction.UP:
  585.                             if ((bola1._y < bola2._y) && (bola1._speed < bola2._speed))
  586.                             {
  587.                                 bola1._speed += bola2._speed;
  588.                                 bola1._ballDirection = Direction.DOWN;
  589.                                 bola2._ballDirection = Direction.UP_RIGHT ;
  590.                             }
  591.                             break;
  592.                         case Direction.DOWN:
  593.                             if (bola1._y > bola2._y)
  594.                             {
  595.                                 bola1._ballDirection = Direction.UP;
  596.                                 bola2._ballDirection = Direction.DOWN;
  597.                             }
  598.                             break;
  599.                         case Direction.UP_RIGHT:
  600.                             {
  601.                                 bola1._ballDirection = Direction.LEFT;
  602.                                 bola2._ballDirection = Direction.UP_LEFT;
  603.                             }
  604.                             break;
  605.                         case Direction.RIGHT:
  606.                             if (bola1._x > bola2._x)
  607.                                 if (bola1._y == bola2._y)
  608.                                 {
  609.                                     bola1._ballDirection = Direction.RIGHT;
  610.                                     bola2._ballDirection = Direction.UP_LEFT;
  611.                                 }
  612.                                 else if (bola1._y < bola2._y)
  613.                                 {
  614.                                     bola1._ballDirection = Direction.UP_RIGHT;
  615.                                     bola2._ballDirection = Direction.DOWN_RIGHT;
  616.                                 }
  617.                                 else if (bola1._y > bola2._y)
  618.                                 {
  619.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  620.                                     bola2._ballDirection = Direction.UP_RIGHT;
  621.                                 }
  622.                             break;
  623.                         case Direction.LEFT:
  624.                             if (bola1._x >= bola2._x)
  625.                                 if (bola1._y == bola2._y)
  626.                                 {
  627.                                     bola1._ballDirection = Direction.RIGHT;
  628.                                     bola2._ballDirection = Direction.LEFT;
  629.                                 }
  630.                                 else if (bola1._y < bola2._y)
  631.                                 {
  632.                                     bola1._ballDirection = Direction.UP_RIGHT ;
  633.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  634.                                 }
  635.                                 else if (bola1._y > bola2._y)
  636.                                 {
  637.                                     bola1._ballDirection = Direction.LEFT;
  638.                                     bola2._ballDirection = Direction.UP_LEFT;
  639.                                 }
  640.                             break;
  641.                         case Direction.DOWN_RIGHT:
  642.                             if (bola1._y >= bola2._y)
  643.                                 if (bola1._x > bola2._x)
  644.                                 {
  645.                                     bola1._ballDirection = Direction.DOWN_RIGHT ;
  646.                                     bola2._ballDirection = Direction.UP_LEFT ;
  647.                                 }
  648.                                 else if (bola1._x == bola2._x)
  649.                                 {
  650.                                     bola1._ballDirection = Direction.DOWN;
  651.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  652.                                 }
  653.                                 else if (bola1._x < bola2._x)
  654.                                 {
  655.                                     bola1._ballDirection = Direction.DOWN ;
  656.                                     bola2._ballDirection = Direction.RIGHT;
  657.                                 }
  658.                             break;
  659.                         case Direction.DOWN_LEFT:
  660.                             if (bola1._y > bola2._y)
  661.                             {
  662.                                 if (bola1._x == bola2._x)
  663.                                 {
  664.                                     bola1._ballDirection = Direction.DOWN;
  665.                                     bola2._ballDirection = Direction.LEFT;
  666.                                 }
  667.                                 else if (bola1._x < bola2._x)
  668.                                 {
  669.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  670.                                     bola2._ballDirection = Direction.RIGHT;
  671.                                 }
  672.                                 else if (bola1._x > bola2._x)
  673.                                 {
  674.                                     bola1._ballDirection = Direction.RIGHT;
  675.                                     bola2._ballDirection = Direction.LEFT;
  676.                                 }
  677.                             }
  678.                             else if (bola1._y == bola2._y)
  679.                                 if (bola1._x < bola2._x)
  680.                                 {
  681.                                     bola1._ballDirection = Direction.LEFT;
  682.                                     bola2._ballDirection = Direction.DOWN;
  683.                                 }
  684.                             break;
  685.                     } //fin Switch(bola2)
  686.  
  687.                     break;
  688.                
  689.                 case Direction.RIGHT :
  690.                     switch (bola2._ballDirection)
  691.                     {
  692.                         case Direction.UP_LEFT:
  693.                             {
  694.                                 bola1._ballDirection = Direction.DOWN_LEFT;
  695.                                 bola2._ballDirection = Direction.UP_RIGHT;
  696.                             }
  697.                             break;
  698.                         case Direction.UP:
  699.                             if ((bola1._y < bola2._y) && (bola1._speed < bola2._speed))
  700.                             {
  701.                                 bola1._speed += bola2._speed;
  702.                                 bola1._ballDirection = Direction.DOWN;
  703.                                 bola2._ballDirection = Direction.UP_LEFT;
  704.                             }
  705.                             break;
  706.                         case Direction.DOWN:
  707.                             if (bola1._y > bola2._y)
  708.                             {
  709.                                 bola1._ballDirection = Direction.UP;
  710.                                 bola2._ballDirection = Direction.DOWN_RIGHT;
  711.                             }
  712.                             break;
  713.                         case Direction.UP_RIGHT:
  714.                             {
  715.                                 bola1._ballDirection = Direction.LEFT;
  716.                                 bola2._ballDirection = Direction.UP;
  717.                             }
  718.                             break;
  719.                         case Direction.RIGHT:
  720.                             if (bola1._x > bola2._x)
  721.                                 if (bola1._y == bola2._y)
  722.                                 {
  723.                                     bola1._ballDirection = Direction.DOWN;
  724.                                     bola2._ballDirection = Direction.UP_LEFT;
  725.                                 }
  726.                                 else if (bola1._y < bola2._y)
  727.                                 {
  728.                                     bola1._ballDirection = Direction.UP_RIGHT;
  729.                                     bola2._ballDirection = Direction.DOWN_RIGHT;
  730.                                 }
  731.                                 else if (bola1._y > bola2._y)
  732.                                 {
  733.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  734.                                     bola2._ballDirection = Direction.UP_RIGHT;
  735.                                 }
  736.                             break;
  737.                         case Direction.LEFT:
  738.                             if (bola1._x >= bola2._x)
  739.                                 if (bola1._y == bola2._y)
  740.                                 {
  741.                                     bola1._ballDirection = Direction.LEFT;
  742.                                     bola2._ballDirection = Direction.RIGHT;
  743.                                 }
  744.                                 else if (bola1._y < bola2._y)
  745.                                 {
  746.                                     bola1._ballDirection = Direction.UP_LEFT;
  747.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  748.                                 }
  749.                                 else if (bola1._y > bola2._y)
  750.                                 {
  751.                                     bola1._ballDirection = Direction.LEFT;
  752.                                     bola2._ballDirection = Direction.UP_LEFT;
  753.                                 }
  754.                             break;
  755.                         case Direction.DOWN_RIGHT:
  756.                             if (bola1._y >= bola2._y)
  757.                                 if (bola1._x > bola2._x)
  758.                                 {
  759.                                     bola1._ballDirection = Direction.UP_LEFT;
  760.                                     bola2._ballDirection = Direction.DOWN;
  761.                                 }
  762.                                 else if (bola1._x == bola2._x)
  763.                                 {
  764.                                     bola1._ballDirection = Direction.DOWN;
  765.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  766.                                 }
  767.                                 else if (bola1._x < bola2._x)
  768.                                 {
  769.                                     bola1._ballDirection = Direction.UP_LEFT;
  770.                                     bola2._ballDirection = Direction.RIGHT;
  771.                                 }
  772.                             break;
  773.                         case Direction.DOWN_LEFT:
  774.                             if (bola1._y > bola2._y)
  775.                             {
  776.                                 if (bola1._x == bola2._x)
  777.                                 {
  778.                                     bola1._ballDirection = Direction.DOWN;
  779.                                     bola2._ballDirection = Direction.LEFT;
  780.                                 }
  781.                                 else if (bola1._x < bola2._x)
  782.                                 {
  783.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  784.                                     bola2._ballDirection = Direction.RIGHT;
  785.                                 }
  786.                                 else if (bola1._x > bola2._x)
  787.                                 {
  788.                                     bola1._ballDirection = Direction.UP_RIGHT ;
  789.                                     bola2._ballDirection = Direction.LEFT;
  790.                                 }
  791.                             }
  792.                             else if (bola1._y == bola2._y)
  793.                                 if (bola1._x < bola2._x)
  794.                                 {
  795.                                     bola1._ballDirection = Direction.LEFT;
  796.                                     bola2._ballDirection = Direction.DOWN;
  797.                                 }
  798.                             break;
  799.                     } //fin Switch(bola2)
  800.  
  801.                     break;
  802.                
  803.                 case Direction.LEFT :
  804.                     switch (bola2._ballDirection)
  805.                     {
  806.                         case Direction.UP_LEFT:
  807.                             {
  808.                                 bola1._ballDirection = Direction.DOWN_LEFT;
  809.                                 bola2._ballDirection = Direction.UP_RIGHT;
  810.                             }
  811.                             break;
  812.                         case Direction.UP:
  813.                             if ((bola1._y < bola2._y) && (bola1._speed < bola2._speed))
  814.                             {
  815.                                 bola1._speed += bola2._speed;
  816.                                 bola1._ballDirection = Direction.DOWN;
  817.                                 bola2._ballDirection = Direction.DOWN_LEFT ;
  818.                             }
  819.                             break;
  820.                         case Direction.DOWN:
  821.                             if (bola1._y > bola2._y)
  822.                             {
  823.                                 bola1._ballDirection = Direction.UP;
  824.                                 bola2._ballDirection = Direction.RIGHT ;
  825.                             }
  826.                             break;
  827.                         case Direction.UP_RIGHT:
  828.                             {
  829.                                 bola1._ballDirection = Direction.UP_RIGHT ;
  830.                                 bola2._ballDirection = Direction.LEFT ;
  831.                             }
  832.                             break;
  833.                         case Direction.RIGHT:
  834.                             if (bola1._x > bola2._x)
  835.                                 if (bola1._y == bola2._y)
  836.                                 {
  837.                                     bola1._ballDirection = Direction.RIGHT;
  838.                                     bola2._ballDirection = Direction.UP_LEFT;
  839.                                 }
  840.                                 else if (bola1._y < bola2._y)
  841.                                 {
  842.                                     bola1._ballDirection = Direction.UP_RIGHT;
  843.                                     bola2._ballDirection = Direction.DOWN_RIGHT;
  844.                                 }
  845.                                 else if (bola1._y > bola2._y)
  846.                                 {
  847.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  848.                                     bola2._ballDirection = Direction.UP_RIGHT;
  849.                                 }
  850.                             break;
  851.                         case Direction.LEFT:
  852.                             if (bola1._x >= bola2._x)
  853.                                 if (bola1._y == bola2._y)
  854.                                 {
  855.                                     bola1._ballDirection = Direction.RIGHT;
  856.                                     bola2._ballDirection = Direction.DOWN_LEFT ;
  857.                                 }
  858.                                 else if (bola1._y < bola2._y)
  859.                                 {
  860.                                     bola1._ballDirection = Direction.UP_LEFT;
  861.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  862.                                 }
  863.                                 else if (bola1._y > bola2._y)
  864.                                 {
  865.                                     bola1._ballDirection = Direction.UP_RIGHT ;
  866.                                     bola2._ballDirection = Direction.UP_LEFT;
  867.                                 }
  868.                             break;
  869.                         case Direction.DOWN_RIGHT:
  870.                             if (bola1._y >= bola2._y)
  871.                                 if (bola1._x > bola2._x)
  872.                                 {
  873.                                     bola1._ballDirection = Direction.DOWN_LEFT ;
  874.                                     bola2._ballDirection = Direction.UP_LEFT ;
  875.                                 }
  876.                                 else if (bola1._x == bola2._x)
  877.                                 {
  878.                                     bola1._ballDirection = Direction.DOWN;
  879.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  880.                                 }
  881.                                 else if (bola1._x < bola2._x)
  882.                                 {
  883.                                     bola1._ballDirection = Direction.UP_LEFT;
  884.                                     bola2._ballDirection = Direction.RIGHT;
  885.                                 }
  886.                             break;
  887.                         case Direction.DOWN_LEFT:
  888.                             if (bola1._y > bola2._y)
  889.                             {
  890.                                 if (bola1._x == bola2._x)
  891.                                 {
  892.                                     bola1._ballDirection = Direction.DOWN;
  893.                                     bola2._ballDirection = Direction.LEFT;
  894.                                 }
  895.                                 else if (bola1._x < bola2._x)
  896.                                 {
  897.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  898.                                     bola2._ballDirection = Direction.RIGHT;
  899.                                 }
  900.                                 else if (bola1._x > bola2._x)
  901.                                 {
  902.                                     bola1._ballDirection = Direction.RIGHT;
  903.                                     bola2._ballDirection = Direction.LEFT;
  904.                                 }
  905.                             }
  906.                             else if (bola1._y == bola2._y)
  907.                                 if (bola1._x < bola2._x)
  908.                                 {
  909.                                     bola1._ballDirection = Direction.LEFT;
  910.                                     bola2._ballDirection = Direction.DOWN;
  911.                                 }
  912.                             break;
  913.                     } //fin Switch(bola2)
  914.  
  915.                     break;
  916.                
  917.                 case Direction.DOWN_RIGHT :
  918.                     switch (bola2._ballDirection)
  919.                     {
  920.                         case Direction.UP_LEFT:
  921.                             {
  922.                                 bola1._ballDirection = Direction.DOWN_LEFT;
  923.                                 bola2._ballDirection = Direction.UP_RIGHT;
  924.                             }
  925.                             break;
  926.                         case Direction.UP:
  927.                             if ((bola1._y < bola2._y) && (bola1._speed < bola2._speed))
  928.                             {
  929.                                 bola1._speed += bola2._speed;
  930.                                 bola1._ballDirection = Direction.DOWN;
  931.                                 bola2._ballDirection = Direction.LEFT ;
  932.                             }
  933.                             break;
  934.                         case Direction.DOWN:
  935.                             if (bola1._y > bola2._y)
  936.                             {
  937.                                 bola1._ballDirection = Direction.UP;
  938.                                 bola2._ballDirection = Direction.UP_LEFT ;
  939.                             }
  940.                             break;
  941.                         case Direction.UP_RIGHT:
  942.                             {
  943.                                 bola1._ballDirection = Direction.LEFT;
  944.                                 bola2._ballDirection = Direction.DOWN ;
  945.                             }
  946.                             break;
  947.                         case Direction.RIGHT:
  948.                             if (bola1._x > bola2._x)
  949.                                 if (bola1._y == bola2._y)
  950.                                 {
  951.                                     bola1._ballDirection = Direction.RIGHT;
  952.                                     bola2._ballDirection = Direction.UP_LEFT;
  953.                                 }
  954.                                 else if (bola1._y < bola2._y)
  955.                                 {
  956.                                     bola1._ballDirection = Direction.UP_RIGHT;
  957.                                     bola2._ballDirection = Direction.UP ;
  958.                                 }
  959.                                 else if (bola1._y > bola2._y)
  960.                                 {
  961.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  962.                                     bola2._ballDirection = Direction.UP_RIGHT;
  963.                                 }
  964.                             break;
  965.                         case Direction.LEFT:
  966.                             if (bola1._x >= bola2._x)
  967.                                 if (bola1._y == bola2._y)
  968.                                 {
  969.                                     bola1._ballDirection = Direction.DOWN_LEFT ;
  970.                                     bola2._ballDirection = Direction.DOWN_RIGHT ;
  971.                                 }
  972.                                 else if (bola1._y < bola2._y)
  973.                                 {
  974.                                     bola1._ballDirection = Direction.UP_LEFT;
  975.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  976.                                 }
  977.                                 else if (bola1._y > bola2._y)
  978.                                 {
  979.                                     bola1._ballDirection = Direction.LEFT;
  980.                                     bola2._ballDirection = Direction.UP_LEFT;
  981.                                 }
  982.                             break;
  983.                         case Direction.DOWN_RIGHT:
  984.                             if (bola1._y >= bola2._y)
  985.                                 if (bola1._x > bola2._x)
  986.                                 {
  987.                                     bola1._ballDirection = Direction.UP_LEFT;
  988.                                     bola2._ballDirection = Direction.UP ;
  989.                                 }
  990.                                 else if (bola1._x == bola2._x)
  991.                                 {
  992.                                     bola1._ballDirection = Direction.DOWN;
  993.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  994.                                 }
  995.                                 else if (bola1._x < bola2._x)
  996.                                 {
  997.                                     bola1._ballDirection = Direction.UP_LEFT;
  998.                                     bola2._ballDirection = Direction.RIGHT;
  999.                                 }
  1000.                             break;
  1001.                         case Direction.DOWN_LEFT:
  1002.                             if (bola1._y > bola2._y)
  1003.                             {
  1004.                                 if (bola1._x == bola2._x)
  1005.                                 {
  1006.                                     bola1._ballDirection = Direction.DOWN;
  1007.                                     bola2._ballDirection = Direction.LEFT;
  1008.                                 }
  1009.                                 else if (bola1._x < bola2._x)
  1010.                                 {
  1011.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1012.                                     bola2._ballDirection = Direction.RIGHT;
  1013.                                 }
  1014.                                 else if (bola1._x > bola2._x)
  1015.                                 {
  1016.                                     bola1._ballDirection = Direction.RIGHT;
  1017.                                     bola2._ballDirection = Direction.LEFT;
  1018.                                 }
  1019.                             }
  1020.                             else if (bola1._y == bola2._y)
  1021.                                 if (bola1._x < bola2._x)
  1022.                                 {
  1023.                                     bola1._ballDirection = Direction.LEFT;
  1024.                                     bola2._ballDirection = Direction.DOWN;
  1025.                                 }
  1026.                             break;
  1027.                     } //fin Switch(bola2)
  1028.  
  1029.                     break;
  1030.                
  1031.                 case Direction.DOWN_LEFT :
  1032.                     switch (bola2._ballDirection)
  1033.                     {
  1034.                         case Direction.UP_LEFT:
  1035.                             {
  1036.                                 bola1._ballDirection = Direction.UP ;
  1037.                                 bola2._ballDirection = Direction.UP_RIGHT;
  1038.                             }
  1039.                             break;
  1040.                         case Direction.UP:
  1041.                             if ((bola1._y < bola2._y) && (bola1._speed < bola2._speed))
  1042.                             {
  1043.                                 bola1._speed += bola2._speed;
  1044.                                 bola1._ballDirection = Direction.DOWN;
  1045.                                 bola2._ballDirection = Direction.DOWN_LEFT ;
  1046.                             }
  1047.                             break;
  1048.                         case Direction.DOWN:
  1049.                             if (bola1._y > bola2._y)
  1050.                             {
  1051.                                 bola1._ballDirection = Direction.UP;
  1052.                                 bola2._ballDirection = Direction.DOWN_RIGHT;
  1053.                             }
  1054.                             break;
  1055.                         case Direction.UP_RIGHT:
  1056.                             {
  1057.                                 bola1._ballDirection = Direction.LEFT;
  1058.                                 bola2._ballDirection = Direction.UP;
  1059.                             }
  1060.                             break;
  1061.                         case Direction.RIGHT:
  1062.                             if (bola1._x > bola2._x)
  1063.                                 if (bola1._y == bola2._y)
  1064.                                 {
  1065.                                     bola1._ballDirection = Direction.RIGHT;
  1066.                                     bola2._ballDirection = Direction.UP_LEFT;
  1067.                                 }
  1068.                                 else if (bola1._y < bola2._y)
  1069.                                 {
  1070.                                     bola1._ballDirection = Direction.UP_RIGHT;
  1071.                                     bola2._ballDirection = Direction.DOWN_RIGHT;
  1072.                                 }
  1073.                                 else if (bola1._y > bola2._y)
  1074.                                 {
  1075.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  1076.                                     bola2._ballDirection = Direction.UP_RIGHT;
  1077.                                 }
  1078.                             break;
  1079.                         case Direction.LEFT:
  1080.                             if (bola1._x >= bola2._x)
  1081.                                 if (bola1._y == bola2._y)
  1082.                                 {
  1083.                                     bola1._ballDirection = Direction.RIGHT;
  1084.                                     bola2._ballDirection = Direction.UP_RIGHT ;
  1085.                                 }
  1086.                                 else if (bola1._y < bola2._y)
  1087.                                 {
  1088.                                     bola1._ballDirection = Direction.UP_LEFT;
  1089.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  1090.                                 }
  1091.                                 else if (bola1._y > bola2._y)
  1092.                                 {
  1093.                                     bola1._ballDirection = Direction.LEFT;
  1094.                                     bola2._ballDirection = Direction.UP_LEFT;
  1095.                                 }
  1096.                             break;
  1097.                         case Direction.DOWN_RIGHT:
  1098.                             if (bola1._y >= bola2._y)
  1099.                                 if (bola1._x > bola2._x)
  1100.                                 {
  1101.                                     bola1._ballDirection = Direction.UP_LEFT;
  1102.                                     bola2._ballDirection = Direction.DOWN;
  1103.                                 }
  1104.                                 else if (bola1._x == bola2._x)
  1105.                                 {
  1106.                                     bola1._ballDirection = Direction.DOWN;
  1107.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  1108.                                 }
  1109.                                 else if (bola1._x < bola2._x)
  1110.                                 {
  1111.                                     bola1._ballDirection = Direction.UP_LEFT;
  1112.                                     bola2._ballDirection = Direction.RIGHT;
  1113.                                 }
  1114.                             break;
  1115.                         case Direction.DOWN_LEFT:
  1116.                             if (bola1._y > bola2._y)
  1117.                             {
  1118.                                 if (bola1._x == bola2._x)
  1119.                                 {
  1120.                                     bola1._ballDirection = Direction.DOWN;
  1121.                                     bola2._ballDirection = Direction.LEFT;
  1122.                                 }
  1123.                                 else if (bola1._x < bola2._x)
  1124.                                 {
  1125.                                     bola1._ballDirection = Direction.UP ;
  1126.                                     bola2._ballDirection = Direction.RIGHT;
  1127.                                 }
  1128.                                 else if (bola1._x > bola2._x)
  1129.                                 {
  1130.                                     bola1._ballDirection = Direction.RIGHT;
  1131.                                     bola2._ballDirection = Direction.LEFT;
  1132.                                 }
  1133.                             }
  1134.                             else if (bola1._y == bola2._y)
  1135.                                 if (bola1._x < bola2._x)
  1136.                                 {
  1137.                                     bola1._ballDirection = Direction.LEFT;
  1138.                                     bola2._ballDirection = Direction.DOWN;
  1139.                                 }
  1140.                             break;
  1141.                     } //fin Switch(bola2)
  1142.  
  1143.                     break;
  1144.  
  1145.                 case Direction.DOWN:
  1146.                     switch (bola2._ballDirection)
  1147.                     {
  1148.                         case Direction.UP_LEFT :
  1149.                             if (bola1._y < bola2._y)
  1150.                             {
  1151.                                 if (bola1._x < bola2._x)
  1152.                                 {
  1153.                                     bola1._ballDirection = Direction.UP_LEFT;
  1154.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  1155.                                 }
  1156.                                 else if (bola1._x == bola2._x)
  1157.                                 {
  1158.                                     bola1._ballDirection = Direction.UP;
  1159.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  1160.                                 }
  1161.                                 else if (bola1._x > bola2._x)
  1162.                                 {
  1163.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  1164.                                     bola2._ballDirection = Direction.LEFT;
  1165.                                 }
  1166.                             }
  1167.                             else if(bola1._y == bola2._y)
  1168.                                 if (bola1._x < bola2._x)
  1169.                                 {
  1170.                                     bola1._ballDirection = Direction.LEFT;
  1171.                                     bola2._ballDirection = Direction.UP_RIGHT;
  1172.                                 }
  1173.                             break;
  1174.  
  1175.                         case Direction.UP_RIGHT:
  1176.                             if (bola1._y < bola2._y)
  1177.                             {
  1178.                                 if (bola1._x < bola2._x)
  1179.                                 {
  1180.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1181.                                     bola2._ballDirection = Direction.RIGHT;
  1182.                                 }
  1183.                                 else if (bola1._x == bola2._x)
  1184.                                 {
  1185.                                     bola1._ballDirection = Direction.UP;
  1186.                                     bola2._ballDirection = Direction.DOWN;
  1187.                                 }
  1188.                                 else if (bola1._x > bola2._x)
  1189.                                 {
  1190.                                     bola1._ballDirection = Direction.UP_RIGHT;
  1191.                                     bola2._ballDirection = Direction.DOWN_RIGHT;
  1192.                                 }
  1193.                             }
  1194.                             else if (bola1._y == bola2._y)
  1195.                                 if (bola1._x > bola2._x)
  1196.                                 {
  1197.                                     bola1._ballDirection = Direction.RIGHT;
  1198.                                     bola2._ballDirection = Direction.UP;
  1199.                                 }
  1200.                             break;
  1201.  
  1202.                         case Direction.UP:
  1203.  
  1204.                             if (bola1._y < bola2._y)
  1205.                             {
  1206.                                 if (bola1._x == bola2._x)
  1207.                                 {
  1208.                                     bola1._ballDirection = Direction.UP;
  1209.                                     bola2._ballDirection = Direction.DOWN;
  1210.                                 }
  1211.                                 else if (bola1._x < bola2._x)
  1212.                                 {
  1213.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1214.                                     bola2._ballDirection = Direction.UP_RIGHT;
  1215.                                 }
  1216.                                 else if (bola1._x > bola2._x)
  1217.                                 {
  1218.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  1219.                                     bola2._ballDirection = Direction.UP_LEFT;
  1220.                                 }
  1221.                             }
  1222.                             break;
  1223.  
  1224.                         case Direction.DOWN:
  1225.                             if ((bola1._y > bola2._y) && (bola1._speed < bola2._speed))
  1226.                             {
  1227.                                 bola1._speed += bola2._speed;
  1228.                                 if (bola1._x > bola2._x)
  1229.                                 {
  1230.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  1231.                                 }
  1232.                                 else if (bola1._x < bola2._x)
  1233.                                 {
  1234.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1235.                                 }
  1236.                             }
  1237.                             break;
  1238.  
  1239.                         case Direction.RIGHT:
  1240.                             if (bola1._x > bola2._x)
  1241.                                 if (bola1._y == bola2._y)
  1242.                                 {
  1243.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  1244.                                     bola2._ballDirection = Direction.UP_LEFT;
  1245.                                 }
  1246.                                 else if (bola1._y < bola2._y)
  1247.                                 {
  1248.                                     bola1._ballDirection = Direction.RIGHT;
  1249.                                     bola2._ballDirection = Direction.DOWN_RIGHT;
  1250.                                 }
  1251.                                 else if (bola1._y > bola2._y)
  1252.                                 {
  1253.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  1254.                                     bola2._ballDirection = Direction.UP_RIGHT;
  1255.                                 }
  1256.                             break;
  1257.  
  1258.                         case Direction.LEFT:
  1259.                             if (bola1._x < bola2._x)
  1260.                                 if (bola1._y == bola2._y)
  1261.                                 {
  1262.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1263.                                     bola2._ballDirection = Direction.RIGHT;
  1264.                                 }
  1265.                                 else if (bola1._y < bola2._y)
  1266.                                 {
  1267.                                     bola1._ballDirection = Direction.LEFT;
  1268.                                     bola2._ballDirection = Direction.DOWN_LEFT;
  1269.                                 }
  1270.                                 else if (bola1._y > bola2._y)
  1271.                                 {
  1272.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1273.                                     bola2._ballDirection = Direction.UP_LEFT;
  1274.                                 }
  1275.                             break;
  1276.  
  1277.                         case Direction.DOWN_RIGHT:
  1278.                             if (bola1._y >= bola2._y)
  1279.                                 if (bola1._x > bola2._x)
  1280.                                 {
  1281.                                     bola1._ballDirection = Direction.DOWN_RIGHT;
  1282.                                     bola2._ballDirection = Direction.RIGHT;
  1283.                                 }
  1284.                                 else if (bola1._x == bola2._x)
  1285.                                 {
  1286.                                     bola1._ballDirection = Direction.RIGHT;
  1287.                                     bola2._ballDirection = Direction.DOWN;
  1288.                                 }
  1289.                                 else if (bola1._x < bola2._x)
  1290.                                 {
  1291.                                     bola1._ballDirection = Direction.UP_RIGHT;
  1292.                                     bola2._ballDirection = Direction.DOWN;
  1293.                                 }
  1294.                             break;
  1295.  
  1296.                         case Direction.DOWN_LEFT:
  1297.                             if (bola1._y > bola2._y)
  1298.                             {
  1299.                                 if (bola1._x <= bola2._x)
  1300.                                 {
  1301.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1302.                                     bola2._ballDirection = Direction.LEFT;
  1303.                                 }
  1304.                             }
  1305.                             else if (bola1._y == bola2._y)
  1306.                                 if (bola1._x < bola2._x)
  1307.                                 {
  1308.                                     bola1._ballDirection = Direction.DOWN_LEFT;
  1309.                                     bola2._ballDirection = Direction.DOWN;
  1310.                                 }
  1311.                             break;
  1312.                     } //fin Switch(bola2)
  1313.  
  1314.                     break;  // de case DOWN  ********************************************************
  1315.  
  1316.             } //fin Switch(bola1)
  1317.  
  1318.         } // end Compara
  1319.     }
  1320. }