Update: CC - Bacon - Entity Loaded (2xswm1bwq8.js) 194 bytes modified
parent
e49a84b478
commit
3bce4a9146
|
@ -1436,41 +1436,49 @@ GameLib.CustomCode.prototype.stopBlock = function() {
|
|||
/**
|
||||
* 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);
|
||||
var block = this.grid[position.y][position.x];
|
||||
|
||||
if (block.mesh) {
|
||||
this.scene.removeObject(block.mesh);
|
||||
}
|
||||
|
||||
this.grid[position.y][position.x] = {
|
||||
value: GameLib.CustomCode.TETRIS_GRID_TAKEN,
|
||||
mesh: position.mesh
|
||||
};
|
||||
if (block.baconDisappearing) {
|
||||
this.scene.removeObject(block.baconDisappearing);
|
||||
}
|
||||
|
||||
block = {
|
||||
value : GameLib.CustomCode.TETRIS_GRID_TAKEN,
|
||||
mesh : position.mesh,
|
||||
baconDisappearing : null
|
||||
}
|
||||
|
||||
this.grid[position.y][position.x] = block;
|
||||
|
||||
}.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();
|
||||
/**
|
||||
* We apply our current rotation and position to the instance
|
||||
*/
|
||||
this.block.center.updateInstance('position');
|
||||
this.block.center.updateInstance('rotation');
|
||||
|
||||
/**
|
||||
* Now we unlink the meshes from the controlling center block
|
||||
*/
|
||||
this.block.meshes.map(
|
||||
function (mesh) {
|
||||
|
||||
mesh.setParentMesh(null);
|
||||
mesh.position.z = 2.5;
|
||||
mesh.updateInstancePosition();
|
||||
mesh.updateInstance('position');
|
||||
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.animation.removeMesh(this.block.center);
|
||||
|
||||
/**
|
||||
* We remove the controlling block
|
||||
*/
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.REMOVE_COMPONENT,
|
||||
{
|
||||
|
@ -1478,10 +1486,16 @@ GameLib.CustomCode.prototype.stopBlock = function() {
|
|||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* We remove any lines
|
||||
*/
|
||||
this.removeLines();
|
||||
|
||||
this.visualizeGrid(0xff0000);
|
||||
|
||||
/**
|
||||
* Check if the game is over
|
||||
*/
|
||||
for (var x = 0; x < GameLib.CustomCode.TETRIS_GRID_WIDTH; x++) {
|
||||
if (
|
||||
this.grid[19][x].value === GameLib.CustomCode.TETRIS_GRID_TAKEN ||
|
||||
|
@ -1495,27 +1509,29 @@ GameLib.CustomCode.prototype.stopBlock = function() {
|
|||
}
|
||||
|
||||
if (this.gameOver) {
|
||||
this.endGame();
|
||||
|
||||
/**
|
||||
* End the game if game over
|
||||
*/
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_OVER,
|
||||
{
|
||||
score: this.score,
|
||||
level: this.level,
|
||||
rows: this.rows
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Otherwise continue
|
||||
*/
|
||||
this.getNextBlock();
|
||||
}
|
||||
|
||||
}.bind(this);
|
||||
|
||||
GameLib.CustomCode.prototype.endGame = function() {
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_OVER,
|
||||
{
|
||||
score: this.score,
|
||||
level: this.level,
|
||||
rows: this.rows
|
||||
}
|
||||
);
|
||||
|
||||
}.bind(this)
|
||||
|
||||
|
||||
/**
|
||||
* Clears the grid
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue