Update: CC - Bacon - Entity Loaded (2xswm1bwq8.js) 46 bytes modified
parent
437fb735a2
commit
539c94e63a
254
2xswm1bwq8.js
254
2xswm1bwq8.js
|
@ -43,7 +43,6 @@ this.scoreTexture = GameLib.EntityManager.Instance.findComponentById('kva68t4dm8
|
||||||
* Animations
|
* Animations
|
||||||
*/
|
*/
|
||||||
this.animation = GameLib.EntityManager.Instance.findComponentById('tnlwgvf12x');
|
this.animation = GameLib.EntityManager.Instance.findComponentById('tnlwgvf12x');
|
||||||
//this.animationSystem = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SYSTEM_ANIMATION)[0];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lights
|
* Lights
|
||||||
|
@ -126,7 +125,7 @@ GameLib.CustomCode.prototype.startAnimation = function (index) {
|
||||||
|
|
||||||
bacon.position.x = x;
|
bacon.position.x = x;
|
||||||
bacon.position.y = index;
|
bacon.position.y = index;
|
||||||
bacon.position.z = 3;
|
bacon.position.z = 2;
|
||||||
bacon.updateInstance('position');
|
bacon.updateInstance('position');
|
||||||
|
|
||||||
this.grid[index][x].baconDisappearing = bacon;
|
this.grid[index][x].baconDisappearing = bacon;
|
||||||
|
@ -1310,8 +1309,6 @@ GameLib.CustomCode.prototype.spawnBigBlock = function () {
|
||||||
|
|
||||||
GameLib.CustomCode.prototype.getNextBlock = function () {
|
GameLib.CustomCode.prototype.getNextBlock = function () {
|
||||||
|
|
||||||
// this.animationSystem.stop();
|
|
||||||
|
|
||||||
this.block = this.spawnBigBlock();
|
this.block = this.spawnBigBlock();
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
|
@ -1321,97 +1318,10 @@ GameLib.CustomCode.prototype.getNextBlock = function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// this.animationSystem.start();
|
|
||||||
|
|
||||||
this.animation.meshes.push(this.block.center);
|
this.animation.meshes.push(this.block.center);
|
||||||
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.subscriptions)) {
|
|
||||||
|
|
||||||
this.subscriptions = [];
|
|
||||||
|
|
||||||
this.subscriptions.push(
|
|
||||||
new GameLib.Event.Subscribe(
|
|
||||||
GameLib.Event.CUSTOM_GAME_START,
|
|
||||||
|
|
||||||
function () {
|
|
||||||
|
|
||||||
this.animationObjects = [];
|
|
||||||
|
|
||||||
this.baconMaterials = [];
|
|
||||||
|
|
||||||
this.score = 0;
|
|
||||||
this.level = 1;
|
|
||||||
this.rows = 0;
|
|
||||||
this.speed = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw our new status
|
|
||||||
*/
|
|
||||||
this.drawStatus();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure the grid is cleared
|
|
||||||
*/
|
|
||||||
this.clearGrid();
|
|
||||||
|
|
||||||
|
|
||||||
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.getNextBlock();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the game parameters
|
|
||||||
*/
|
|
||||||
this.ccBeforeRender.entityLoaded = null;
|
|
||||||
this.ccBeforeRender.initialized = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Link the classes
|
|
||||||
*/
|
|
||||||
this.ccBeforeRender.entityLoaded = this;
|
|
||||||
this.ccKeyDown.entityLoaded = this;
|
|
||||||
this.ccTouchStart.entityLoaded = this;
|
|
||||||
this.ccTouchEnd.entityLoaded = this;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow the game to proceed
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.gameOver = false;
|
|
||||||
|
|
||||||
console.log('game start complete');
|
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This code executes when the 'bottom' has been reached (the block is stopping)
|
* This code executes when the 'bottom' has been reached (the block is stopping)
|
||||||
*/
|
*/
|
||||||
|
@ -1483,7 +1393,7 @@ GameLib.CustomCode.prototype.stopBlock = function() {
|
||||||
*/
|
*/
|
||||||
this.removeLines();
|
this.removeLines();
|
||||||
|
|
||||||
this.visualizeGrid(0xff0000);
|
//this.visualizeGrid(0xff0000);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the game is over
|
* Check if the game is over
|
||||||
|
@ -1566,34 +1476,60 @@ GameLib.CustomCode.prototype.clearGrid = function() {
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
|
|
||||||
GameLib.CustomCode.prototype.createTile = function(tileName, imageName) {
|
GameLib.CustomCode.prototype.createTile = function(tileName, imageName, displace) {
|
||||||
|
|
||||||
var apiMaterial;
|
var apiMaterial;
|
||||||
|
|
||||||
if (imageName) {
|
if (imageName) {
|
||||||
apiMaterial = new GameLib.D3.API.Material.Phong(
|
if (displace) {
|
||||||
null,
|
apiMaterial = new GameLib.D3.API.Material.Phong(
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new GameLib.D3.API.Texture.Image(
|
|
||||||
null,
|
null,
|
||||||
this[imageName]
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
this.textureDisplacement,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new GameLib.D3.API.Texture.Image(
|
||||||
|
null,
|
||||||
|
this[imageName]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
} else {
|
||||||
|
apiMaterial = new GameLib.D3.API.Material.Phong(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new GameLib.D3.API.Texture.Image(
|
||||||
|
null,
|
||||||
|
this[imageName]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
apiMaterial = new GameLib.D3.API.Material.Phong();
|
apiMaterial = new GameLib.D3.API.Material.Phong();
|
||||||
}
|
}
|
||||||
|
@ -1624,6 +1560,82 @@ GameLib.CustomCode.prototype.createTile = function(tileName, imageName) {
|
||||||
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
|
GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.CUSTOM_GAME_START,
|
||||||
|
|
||||||
|
function () {
|
||||||
|
|
||||||
|
this.animationObjects = [];
|
||||||
|
|
||||||
|
this.baconMaterials = [];
|
||||||
|
|
||||||
|
this.score = 0;
|
||||||
|
this.level = 1;
|
||||||
|
this.rows = 0;
|
||||||
|
this.speed = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw our new status
|
||||||
|
*/
|
||||||
|
this.drawStatus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the grid is cleared
|
||||||
|
*/
|
||||||
|
this.clearGrid();
|
||||||
|
|
||||||
|
|
||||||
|
if (this.block && 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.getNextBlock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the game parameters
|
||||||
|
*/
|
||||||
|
this.ccBeforeRender.entityLoaded = null;
|
||||||
|
this.ccBeforeRender.initialized = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link the classes
|
||||||
|
*/
|
||||||
|
this.ccBeforeRender.entityLoaded = this;
|
||||||
|
this.ccKeyDown.entityLoaded = this;
|
||||||
|
this.ccTouchStart.entityLoaded = this;
|
||||||
|
this.ccTouchEnd.entityLoaded = this;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow the game to proceed
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.gameOver = false;
|
||||||
|
|
||||||
|
console.log('game start complete');
|
||||||
|
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.GET_RUNTIME,
|
GameLib.Event.GET_RUNTIME,
|
||||||
{},
|
{},
|
||||||
|
@ -1631,13 +1643,13 @@ GameLib.Event.Emit(
|
||||||
|
|
||||||
this.graphics = runtime.graphics;
|
this.graphics = runtime.graphics;
|
||||||
|
|
||||||
this.createTile('tile_0', 'image_0');
|
this.createTile('tile_0', 'image_0', true);
|
||||||
this.createTile('tile_1', 'image_1');
|
this.createTile('tile_1', 'image_1', true);
|
||||||
this.createTile('tile_2', 'image_2');
|
this.createTile('tile_2', 'image_2', true);
|
||||||
this.createTile('tile_3', 'image_3');
|
this.createTile('tile_3', 'image_3', true);
|
||||||
this.createTile('tile_4', 'image_4');
|
this.createTile('tile_4', 'image_4', true);
|
||||||
this.createTile('tile_5', 'image_5');
|
this.createTile('tile_5', 'image_5', true);
|
||||||
this.createTile('tile_6', 'image_6');
|
this.createTile('tile_6', 'image_6', true);
|
||||||
|
|
||||||
this.createTile('tile_flames_small', 'image_flames_small');
|
this.createTile('tile_flames_small', 'image_flames_small');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue