Exemplo 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;
        }
Exemplo 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);
     }
 }
Exemplo 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;
     }
 }
Exemplo n.º 4
0
 public abstract void Collide(Ball otherBall);