Update: CC - Bacon - Before Render (o4c478xpx3.js) 4306 bytes modified
parent
0fbe2463b5
commit
a8ab040488
165
o4c478xpx3.js
165
o4c478xpx3.js
|
@ -3,78 +3,12 @@ if (!this.entityLoaded) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.initialized) {
|
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.totalTime = 0;
|
||||||
this.waiting = false;
|
this.waiting = false;
|
||||||
this.gameOver = false;
|
this.gameOver = false;
|
||||||
this.moveQueue = [];
|
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;
|
this.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,101 +63,12 @@ if (moved === null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moved === false) {
|
if (moved === false) {
|
||||||
|
|
||||||
/**
|
|
||||||
* We reached the bottom -
|
|
||||||
*/
|
|
||||||
this.drop = false;
|
this.drop = false;
|
||||||
|
|
||||||
this.moveQueue = [];
|
this.moveQueue = [];
|
||||||
|
|
||||||
var gridPositions = this.getBlockGridPositions(this.block);
|
this.bottomReached();
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@ sourceURL=beforeRender.js
|
//@ sourceURL=beforeRender.js
|
Loading…
Reference in New Issue