Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 68 additions and 15 deletions.
  1. +1 −1 site/assets.json
  2. +67 −14 site/game.js
View
2 site/assets.json
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
81 site/game.js
@@ -14,6 +14,7 @@
var handlerLength = this.handlers.length;
for(var i = 0; i < handlerLength; i++) {
var handler = this.handlers[i];
+ if(!handler) continue;
handler.method.call(handler.context || this.defaultContext, data, source);
}
},
@@ -445,6 +446,21 @@
effect.off('Finished', this.onEffectFinished, this);
this.effects = _(this.effects).without(effect);
},
+ queueEffects: function(effects, cb) {
+ var current = 0;
+ var self = this;
+ var nextEffect = function() {
+ if(current >= effects.length) {
+ cb();
+ return;
+ };
+ var effect = effects[current];
+ effect.once("Finished", nextEffect);
+ self.addEffect(effect);
+ current++;
+ };
+ nextEffect();
+ },
onEffectFinished: function(data, sender) {
this.removeEffect(sender);
},
@@ -500,7 +516,7 @@
this.physical = true;
this.direction = 1;
this.horizontalMotion = Math.random() * 2.5 + 2.5;
- this.id = 'fluff-' + Math.random() * 100000;
+ this.id = 'fluff-' + Math.floor(Math.random() * 100000);
this.generateNewBounds();
this.currentStrategy = this.driftStrategy;
this.expireTime = 0;
@@ -727,16 +743,20 @@
},
onRemovedFromScene: function() {
this.scene.off('TotalFluffChanged', this.onTotalFluffChanged, this);
+ this.scene.withEntity("plughole", _.bind(this.unhookPlugholeEvents, this));
},
onTotalFluffChanged: function(fluffCount) {
this.currentFluff = fluffCount;
this.resize();
},
hookPlugholeEvents: function(plughole) {
- var self = this;
- plughole.on('Moved', function() {
- self.updatePosition();
- });
+ plughole.on('Moved', this.onPlugholeMoved, this);
+ },
+ unhookPlugholeEvents: function(plughole) {
+ plughole.off('Moved', this.onPlugholeMoved, this);
+ },
+ onPlugholeMoved: function() {
+ this.updatePosition();
},
resize: function() {
var newWidth = this.calculateDesiredWidth();
@@ -864,6 +884,7 @@
document.addEventListener('touchstart', _.bind(this.onTouchStart, this), true);
document.addEventListener('touchmove', _.bind(this.onTouchMove, this), true);
document.addEventListener('touchend', _.bind(this.onTouchEnd, this), true);
+ this.enabled = true;
};
Input.prototype = {
@@ -896,10 +917,14 @@
e.preventDefault();
},
actionOn: function(x, y) {
+ if(!this.enabled) return;
this.scene.withEntity("plughole", function(entity) {
entity.moveTo(x, y);
});
},
+ disable: function() {
+ this.enabled = false;
+ },
pageToCanvas: function(x, y) {
var offset = this.wrappedElement.offset();
return {
@@ -961,20 +986,49 @@
this.height = plughole.height * percentage;
}, this));
}
+ },
+ disable: function() {
+ var effect = new FadeOutEffect(this, 60);
+ effect.on('Finished', this.removeSelfFromScene, this);
+ this.addEffect(effect);
+ },
+ removeSelfFromScene: function() {
+ this.scene.remove(this);
}
}
_.extend(CollectedFluff.prototype, Quad.prototype);
-
-
var ClosingStory = function() {
Eventable.call(this);
this.id = "closingstory";
};
ClosingStory.prototype = {
onAddedToScene: function() {
- // Make spider really happy
-
+ var self = this;
+ this.scene.withEntity("spider", function(spider) {
+ spider.queueEffects(
+ [new CelebratingSpiderAnimation(spider),
+ new CelebratingSpiderAnimation(spider)
+ ],
+ function() {
+ self.removeSpiderFromScene();
+ });
+ });
+ },
+ removeSpiderFromScene: function() {
+ var self = this;
+ this.scene.withEntity("spider", function(spider) {
+ var effect = new FadeOutEffect(this, 60);
+ effect.on('Finished', function() {
+ self.scene.remove(spider);
+ self.showEndingScene();
+ });
+ spider.addEffect(effect);
+ spider.addEffect(new CelebratingSpiderAnimation(spider));
+ });
+ },
+ this.showEndingScene: function() {
+
}
};
_.extend(ClosingStory.prototype, Eventable.prototype);
@@ -984,9 +1038,8 @@
this.scene = new Scene();
this.renderer = new Renderer('game');
this.input = new Input('game', this.scene);
- this.fluffGoal = 10;
+ this.fluffGoal = 1;
this.createEntities();
- this.hookEntityEvents();
};
Game.prototype = {
@@ -1012,9 +1065,6 @@
this.scene.autoHook(this);
this.startTimers();
},
- hookEntityEvents: function() {
- this.scene.on('TotalFluffChanged', this.onTotalFluffChanged, this);
- },
startTimers: function() {
var self = this;
setInterval(function() {
@@ -1035,6 +1085,9 @@
this.scene.remove(this.fluffgenerator);
this.scene.remove(this.waterfall);
this.floorWater.disable();
+ this.collectedfluff.disable();
+ this.input.disable();
+ this.plughole.moveTo(340);
this.scene.withAllEntitiesOfType(Fluff, function(fluff) {
fluff.disable();
});

No commit comments for this range

Something went wrong with that request. Please try again.