aboutsummaryrefslogtreecommitdiff
path: root/Cat.js
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2011-08-04 09:16:49 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2011-08-04 09:16:49 +0300
commit58e5e72564bce298fcdc73728b91d981feda9451 (patch)
treefa4507907c3dec171f2a9cdc81a11fad40992a3e /Cat.js
parenta30babdeca01469d4cbd4ce12176d0ccb161f16e (diff)
downloadcatgag-58e5e72564bce298fcdc73728b91d981feda9451.tar.gz
catgag-58e5e72564bce298fcdc73728b91d981feda9451.zip
Almost converted from Jaws -> EaselJS
Diffstat (limited to 'Cat.js')
-rw-r--r--Cat.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/Cat.js b/Cat.js
new file mode 100644
index 0000000..fc382f9
--- /dev/null
+++ b/Cat.js
@@ -0,0 +1,68 @@
+(function(window) {
+
+function Cat() {
+ this.initialize();
+}
+var p = Cat.prototype = new Container();
+
+ p._barrelRolling = false;
+ p._rollState = 0;
+ p._maxRollState = 0;
+ p._gagging = false;
+ p._gags = [];
+
+ p.base_initialize = p.initialize;
+ p.initialize = function() {
+ p.base_initialize();
+
+ var _this = this;
+
+ this.img = new Image();
+ this.img.onload = function() { _this.setup(); };
+ this.img.src = "cat.jpg";
+ };
+
+ p.setup = function() {
+ this.gfx = new Bitmap(this.img);
+ this.addChild(this.gfx);
+
+ this.regX = this.img.width / 2;
+ this.regY = this.img.height / 2;
+ }
+
+ p.tick = function() {
+ if (this._barrelRolling) {
+ this.rotation += 360.0 / this._maxRollState;
+ this._rollState++;
+
+ if (this._rollState >= this._maxRollState) {
+ this._rollState = 0;
+ this._barrelRolling = false;
+ }
+ }
+
+ for (i = 0; this._gags[i]; i++) {
+ //if (this._gags[i].escaped &&
+ }
+ }
+
+ // Starts the barrelroll if the cat's not currently rolling about
+ p.barrelRoll = function() {
+ if (!this._barrelRolling) {
+ this._rollState = 0;
+ this._barrelRolling = true;
+ this._maxRollState = Ticker.getFPS() * 1.5;
+ }
+ }
+
+ // Makes the cat gag
+ p.gag = function() {
+ if (!this._gagging) {
+ this._gagging = true;
+ // @todo create/shoot the gag
+ window.setTimeout(function(cat) { cat._gagging = false; }, 250, this);
+ }
+ }
+
+window.Cat = Cat;
+}(window));