From a8ab040488889e88ccfc235ce6c6d7adb8ba5f09 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sun, 18 Feb 2018 12:07:12 +0100 Subject: [PATCH] Update: CC - Bacon - Before Render (o4c478xpx3.js) 4306 bytes modified --- o4c478xpx3.js | 165 ++------------------------------------------------ 1 file changed, 5 insertions(+), 160 deletions(-) diff --git a/o4c478xpx3.js b/o4c478xpx3.js index 03c8b05..930949f 100644 --- a/o4c478xpx3.js +++ b/o4c478xpx3.js @@ -3,78 +3,12 @@ if (!this.entityLoaded) { } if (!this.initialized) { - - this.scene = this.entityLoaded.scene; - this.animation = this.entityLoaded.animation; - this.drawStatus = this.entityLoaded.drawStatus; - this.getNextBlock = this.entityLoaded.getNextBlock; - + this.totalTime = 0; this.waiting = false; this.gameOver = false; this.moveQueue = []; - if (this.grid instanceof Array) { - this.grid.map( - function(y) { - if (this.grid[y] instanceof Array) { - this.grid[y].map( - function(x){ - if (this.grid[y][x].mesh) { - this.scene.removeObject(this.grid[y][x].mesh); - } - if (this.grid[y][x].baconDisappearing) { - this.scene.removeObject(this.grid[y][x].baconDisappearing); - } - }.bind(this) - ) - } - }.bind(this) - ) - } - /** - * Initialize the grid - */ - this.grid = []; - for (var y = 0; y < GameLib.CustomCode.TETRIS_GRID_HEIGHT; y++) { - this.grid[y] = []; - for (var x = 0; x < GameLib.CustomCode.TETRIS_GRID_WIDTH; x++) { - this.grid[y][x] = { - value: GameLib.CustomCode.TETRIS_GRID_NOT_TAKEN, - mesh: null - }; - } - } - - if (this.block && this.block.center) { - - this.animation.removeMesh(this.block.center); - - GameLib.Event.Emit( - GameLib.Event.REMOVE_COMPONENT, - { - component: this.block.center - } - ); - } - - if (this.block && this.block.meshes) { - this.block.meshes.map( - function (mesh) { - GameLib.Event.Emit( - GameLib.Event.REMOVE_COMPONENT, - { - component: mesh - } - ); - }.bind(this) - ); - } - - this.drawStatus(); - - this.getNextBlock(); - this.initialized = true; } @@ -129,101 +63,12 @@ if (moved === null) { } if (moved === false) { - - /** - * We reached the bottom - - */ + this.drop = false; this.moveQueue = []; - - var gridPositions = this.getBlockGridPositions(this.block); - - gridPositions.map( - function (position) { - /** - * If there already is a mesh - remove it - - */ - if (this.grid[position.y][position.x].mesh) { - this.scene.removeObject(this.grid[position.y][position.x].mesh); - } - - this.grid[position.y][position.x] = { - value: GameLib.CustomCode.TETRIS_GRID_TAKEN, - mesh: position.mesh - }; - }.bind(this) - ); - - this.block.center.instance.position.x = this.block.center.position.x; - this.block.center.instance.position.y = this.block.center.position.y; - this.block.center.instance.position.z = this.block.center.position.z; - - this.block.center.instance.rotation.x = this.block.center.rotation.x; - this.block.center.instance.rotation.y = this.block.center.rotation.y; - this.block.center.instance.rotation.z = this.block.center.rotation.z; - - this.block.center.instance.updateMatrixWorld(); - - this.block.meshes.map( - function (mesh) { - - mesh.setParentMesh(null); - //mesh.position.z = 0.1; - mesh.updateInstancePosition(); - - }.bind(this) - ); - - this.animation.removeMesh(this.block.center); - - GameLib.Event.Emit( - GameLib.Event.REMOVE_COMPONENT, - { - component: this.block.center - } - ); - - this.removeLines(); - - //this.visualizeGrid(0xff0000); - - for (var x = 0; x < GameLib.CustomCode.TETRIS_GRID_WIDTH; x++) { - if ( - this.grid[19][x].value === GameLib.CustomCode.TETRIS_GRID_TAKEN || - this.grid[20][x].value === GameLib.CustomCode.TETRIS_GRID_TAKEN || - this.grid[21][x].value === GameLib.CustomCode.TETRIS_GRID_TAKEN || - this.grid[22][x].value === GameLib.CustomCode.TETRIS_GRID_TAKEN || - this.grid[23][x].value === GameLib.CustomCode.TETRIS_GRID_TAKEN - ) { - this.gameOver = true; - } - } - - if (this.gameOver) { - - this.block.meshes.map( - function (mesh) { - this.scene.removeObject(mesh); - }.bind(this) - ); - - delete this.block; - - GameLib.Event.Emit( - GameLib.Event.GAME_OVER, - { - score: this.entityLoaded.score, - level: this.entityLoaded.level, - rows: this.entityLoaded.rows - } - ); - - //this.visualizeGrid(0xff0000); - - } else { - this.getNextBlock(); - } + + this.bottomReached(); } -//@ sourceURL=beforeRender.js +//@ sourceURL=beforeRender.js \ No newline at end of file