From 6d64edc8fabb169fe77e61414595f7426f3769bb Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sun, 18 Feb 2018 21:35:46 +0100 Subject: [PATCH] Initial Commit: CC - Bacon - Before Render (r8wkd1wwip.js) --- r8wkd1wwip.js | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 r8wkd1wwip.js diff --git a/r8wkd1wwip.js b/r8wkd1wwip.js new file mode 100644 index 0000000..dc4be2c --- /dev/null +++ b/r8wkd1wwip.js @@ -0,0 +1,89 @@ +if (!this.entityLoaded) { + return; +} + +if (this.entityLoaded.gameOver) { + return; +} + +if (!this.initialized) { + + this.totalTime = 0; + + /** + * Waiting means - this block is on top of some blocks which are busy disappearing + * - so wait for the fall to complete + */ + this.waiting = false; + + this.animation = this.entityLoaded.animation; + + this.translationSpeed = this.animation.translationSpeed; + + this.drop = false; + + this.moveQueue = []; + + this.initialized = true; +} + +var moved = true; +var fall = false; + +if (this.waiting) { + fall = true; +} else { + this.totalTime += data.delta; +} + +if (this.drop) { + + this.animation.translationSpeed = 70; + + fall = true; + + if (this.moveQueue && this.moveQueue.length > 0) { + + var tryMove = function () { + if (this.moveQueue.length > 0) { + + var move = this.moveQueue[0]; + + if (this.moveBlock(null, move, 1, true)) { + this.moveQueue.splice(0, 1); + tryMove(); + } + } + }.bind(this); + + tryMove(); + } +} + +if (this.totalTime > this.entityLoaded.speed) { + this.totalTime = 0; + fall = true; +} + +if (fall) { + moved = this.moveBlock(null, {down: true}, 1, true); +} + +if (moved === null) { + this.waiting = true; +} else { + this.waiting = false; +} + +if (moved === false) { + + this.drop = false; + + this.moveQueue = []; + + this.stopBlock(); + + this.animation.translationSpeed = this.translationSpeed; +} + +//@ sourceURL=beforeRender.js \ No newline at end of file