From 925e2c397f4be7ae9413b6e9e262b1bc47d5ce8c Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Thu, 4 Aug 2011 22:08:09 +0300 Subject: Make gagging work --- Cat.js | 12 ++++++++++-- index.html | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Cat.js b/Cat.js index fc382f9..02f2e96 100644 --- a/Cat.js +++ b/Cat.js @@ -42,7 +42,11 @@ var p = Cat.prototype = new Container(); } for (i = 0; this._gags[i]; i++) { - //if (this._gags[i].escaped && + if (this._gags[i].escaped && this.rect().collidesWith(this._gags[i].rect())) { + window.Log("CATCHED"); + this.getStage().removeChild(this._gags[i]); + this._gags.splice(i, 1); + } } } @@ -59,10 +63,14 @@ var p = Cat.prototype = new Container(); p.gag = function() { if (!this._gagging) { this._gagging = true; - // @todo create/shoot the gag + this._gags.push(new Gag(this, this.x, this.y, this.rotation)); window.setTimeout(function(cat) { cat._gagging = false; }, 250, this); } } + + p.rect = function() { + return new Rectangle(this.x-this.regX, this.y-this.regY, this.img.width, this.img.height); + } window.Cat = Cat; }(window)); diff --git a/index.html b/index.html index aff76af..713f358 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,7 @@ + @@ -22,12 +23,26 @@ + + + +
- + + +

-- cgit v1.2.3