public void stickTo(SimpleGameObject target)
 {
     // adjust the coordinates based on direction to stick to an object
     if (direction == MOVE_UP)
     {
         top = target.bottom + 1;
     }
     else if (direction == MOVE_DOWN)
     {
         top = target.top - height - 1;
     }
     else if (direction == MOVE_LEFT)
     {
         left = target.right + 1;
     }
     else if (direction == MOVE_RIGHT)
     {
         left = target.left - width - 1;
     }
     base.recalaculate();
 }
 public bool isColliding(SimpleGameObject target)
 {
     // collision detection code to see if the 2 rectangles overlap
     if (((left >= target.left && left <= target.right) ||
          (right >= target.left && right <= target.right)) &&
         ((top >= target.top && top <= target.bottom) ||
          (bottom >= target.top && bottom <= target.bottom)))
     {
         return(true);
     }
     else if (((target.left >= left && target.left <= right) ||
               (target.right >= left && target.right <= right)) &&
              ((target.top >= top && target.top <= bottom) ||
               (target.bottom >= top && target.bottom <= bottom)))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public void bounceOff(SimpleGameObject target)
 {
     // adjust the coordinates to stick and then randomly bounce off an object
     stickTo(target);
     direction = randomDirection();
 }