1 /** 2 * The hole 3 * @param {Number} x 4 * @param {Number} y 5 * @param {Number}r 6 * @constructor 7 */ 8 function BB_Hole(x, y, r) { 9 this.x = x || 0; 10 this.y = y || 0; 11 this.r = r || 25; 12 this.w = this.r * 2; 13 this.h = this.r * 2; 14 } 15 16 /** 17 * Extends CP_Item 18 */ 19 BB_Hole.prototype = new CP_Item(); 20 21 /** 22 * Checck ball collision 23 * @param {BB_Ball} ball 24 * @returns {Boolean} 25 */ 26 BB_Hole.prototype.check = function(ball) { 27 var vx = this.ox() - ball.ox(), 28 vy = this.oy() - ball.oy(), 29 d = Math.sqrt((vx * vx) + (vy * vy)); 30 return d < this.r; 31 };