示例#1
0
 public void Pressed(Point p, BubbleContainer bc)
 {
     pressed = true;
     lastposition = p;
     currentBubble = bc.catchBubble(p);
     if (currentBubble != null) currentBubble.setDragged(true);
 }
示例#2
0
 public void Released()
 {
     pressed = false;
     if (currentBubble != null)
     {
         currentBubble.setDragged(false);
     }
     currentBubble = null;
 }
示例#3
0
        public void collide(Bubble other)
        {
            Point otherpos = other.getPosition();
            double otherrad = other.getRadius();
            double distancesquared = (otherpos.x - position.x) * (otherpos.x - position.x)
                                    + (otherpos.y - position.y) * (otherpos.y - position.y);
            double radiussquared = (otherrad + radius) * (otherrad + radius);
            if (distancesquared < radiussquared)
            {
                double magnitude = (1 - (distancesquared * distancesquared) / (radiussquared * radiussquared)) * pushStrength;
                double pushangle = Math.Atan((otherpos.y - position.y) / (otherpos.x - position.x)) + Math.PI;
                if (otherpos.x < position.x) pushangle += Math.PI;

                velocity.x += magnitude * Math.Cos(pushangle);
                velocity.y += magnitude * Math.Sin(pushangle);
            }
        }
示例#4
0
 public static bool containsPoint(Bubble bubble, Point point)
 {
     Bubble.Point bubblepos = bubble.getPosition();
     return (bubblepos.x - point.X) * (bubblepos.x - point.X) + (bubblepos.y - point.Y) * (bubblepos.y - point.Y)
         < bubble.getRadius() * bubble.getRadius();
 }