Esempio n. 1
0
        // Checks if this Ball collided with another.
        public bool CollidedWith(Ball otherBall)
        {
            float collisionDist = this.size + otherBall.size;
            float dist = Vector3.Distance(this.pos, otherBall.pos);

            if (dist > collisionDist)
            {
                return false;
            }
            return true;
        }
Esempio n. 2
0
 public override void Collide(Ball otherBall)
 {
     if (this.size < otherBall.size)
     {
         // move somewhere else
         this.pos = game.landscape.getStartPoint();
         // reduce size and decrease score
         Grow(-otherBall.size);
         game.score -= (int)(otherBall.size * game.scoreMultiplier);
     }
     else if (this.size >= otherBall.size)
     {
         // move other ball somewhere else
         otherBall.pos = game.landscape.getStartPoint();
         // grow and increase score
         Grow(otherBall.size);
         game.score += (int)(otherBall.size * game.scoreMultiplier);
     }
 }
Esempio n. 3
0
 public override void Collide(Ball otherBall)
 {
     if (this.size == otherBall.size)
     {
         return;
     }
     if (this.size < otherBall.size)
     {
         // move somewhere else
         this.pos = game.landscape.getStartPoint();
     }
     if (this.size > otherBall.size)
     {
         return;
     }
 }
Esempio n. 4
0
 public abstract void Collide(Ball otherBall);