Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 1591 bytes modified
parent
d911d08872
commit
9ab9bf503b
|
@ -191,15 +191,13 @@ GameLib.CustomCode.prototype.createGameMesh = function(material, visible) {
|
||||||
* @param type
|
* @param type
|
||||||
* @param mesh
|
* @param mesh
|
||||||
* @param position
|
* @param position
|
||||||
* @param index
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.CustomCode.GameObject = function(
|
GameLib.CustomCode.GameObject = function(
|
||||||
objectType,
|
objectType,
|
||||||
type,
|
type,
|
||||||
mesh,
|
mesh,
|
||||||
position,
|
position
|
||||||
index
|
|
||||||
) {
|
) {
|
||||||
if (GameLib.Utils.UndefinedOrNull(objectType)) {
|
if (GameLib.Utils.UndefinedOrNull(objectType)) {
|
||||||
objectType = GameLib.CustomCode.OBJECT_TYPE_NONE;
|
objectType = GameLib.CustomCode.OBJECT_TYPE_NONE;
|
||||||
|
@ -220,11 +218,6 @@ GameLib.CustomCode.GameObject = function(
|
||||||
position = null;
|
position = null;
|
||||||
}
|
}
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(index)) {
|
|
||||||
index = -1;
|
|
||||||
}
|
|
||||||
this.index = index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -248,8 +241,6 @@ GameLib.CustomCode.GameObject.prototype.dispose = function(removeMesh) {
|
||||||
this.type = -1;
|
this.type = -1;
|
||||||
|
|
||||||
this.position = null;
|
this.position = null;
|
||||||
|
|
||||||
this.index = -1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -400,8 +391,7 @@ GameLib.CustomCode.prototype.createGameObject = function(
|
||||||
objectType,
|
objectType,
|
||||||
type,
|
type,
|
||||||
mesh,
|
mesh,
|
||||||
position,
|
position
|
||||||
array.length
|
|
||||||
)
|
)
|
||||||
gameObject.applyToMesh(true);
|
gameObject.applyToMesh(true);
|
||||||
break;
|
break;
|
||||||
|
@ -410,7 +400,6 @@ GameLib.CustomCode.prototype.createGameObject = function(
|
||||||
type,
|
type,
|
||||||
mesh,
|
mesh,
|
||||||
position,
|
position,
|
||||||
array.length,
|
|
||||||
orientation
|
orientation
|
||||||
)
|
)
|
||||||
gameObject.applyToMesh(true);
|
gameObject.applyToMesh(true);
|
||||||
|
@ -518,18 +507,17 @@ GameLib.CustomCode.prototype.createFood = function(delta) {
|
||||||
* @param type
|
* @param type
|
||||||
* @param mesh
|
* @param mesh
|
||||||
* @param position
|
* @param position
|
||||||
* @param index
|
|
||||||
* @param orientation
|
* @param orientation
|
||||||
* @param flip
|
* @param flip
|
||||||
* @param backupMesh
|
* @param backupMesh
|
||||||
* @param isTail
|
* @param isTail
|
||||||
|
* @property animation
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.CustomCode.SnakeBody = function(
|
GameLib.CustomCode.SnakeBody = function(
|
||||||
type,
|
type,
|
||||||
mesh,
|
mesh,
|
||||||
position,
|
position,
|
||||||
index,
|
|
||||||
orientation,
|
orientation,
|
||||||
flip,
|
flip,
|
||||||
backupMesh,
|
backupMesh,
|
||||||
|
@ -541,8 +529,7 @@ GameLib.CustomCode.SnakeBody = function(
|
||||||
GameLib.Object.OBJECT_TYPE_SNAKE_BODY,
|
GameLib.Object.OBJECT_TYPE_SNAKE_BODY,
|
||||||
type,
|
type,
|
||||||
mesh,
|
mesh,
|
||||||
position,
|
position
|
||||||
index
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(orientation)) {
|
if (GameLib.Utils.UndefinedOrNull(orientation)) {
|
||||||
|
@ -566,6 +553,10 @@ GameLib.CustomCode.SnakeBody = function(
|
||||||
this.isTail = isTail;
|
this.isTail = isTail;
|
||||||
|
|
||||||
this.applyToMesh();
|
this.applyToMesh();
|
||||||
|
|
||||||
|
var animation = GameLib.EntityManager.Instance.findComponentById('8kb7utb2fn');
|
||||||
|
|
||||||
|
animation.meshes.push(this.mesh);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.CustomCode.SnakeBody.prototype = Object.create(GameLib.CustomCode.GameObject.prototype);
|
GameLib.CustomCode.SnakeBody.prototype = Object.create(GameLib.CustomCode.GameObject.prototype);
|
||||||
|
@ -934,25 +925,19 @@ GameLib.Event.Subscribe(
|
||||||
*/
|
*/
|
||||||
this.snake.map(
|
this.snake.map(
|
||||||
function(body) {
|
function(body) {
|
||||||
body.mesh.geometry = null;
|
body.dispose();
|
||||||
body.mesh.materials = null;
|
|
||||||
body.mesh.remove();
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
this.food.map(
|
this.food.map(
|
||||||
function(food) {
|
function(food) {
|
||||||
food.mesh.geometry = null;
|
food.dispose();
|
||||||
food.mesh.materials = null;
|
|
||||||
food.mesh.remove();
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
this.powerups.map(
|
this.powerups.map(
|
||||||
function(powerup) {
|
function(powerup) {
|
||||||
powerup.mesh.geometry = null;
|
powerup.dispose();
|
||||||
powerup.mesh.materials = null;
|
|
||||||
powerup.mesh.remove();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -962,55 +947,23 @@ GameLib.Event.Subscribe(
|
||||||
|
|
||||||
this.snake = [
|
this.snake = [
|
||||||
new GameLib.CustomCode.SnakeBody(
|
new GameLib.CustomCode.SnakeBody(
|
||||||
this.createGameMesh(this.materialBreadHead),
|
GameLib.CustomCode.BODY_TYPE_BREAD_HEAD,
|
||||||
{
|
{
|
||||||
x : 4,
|
x : 4,
|
||||||
y : 4
|
y : 4
|
||||||
},
|
},
|
||||||
0
|
GameLib.CustomCode.ORIENTATION_UP
|
||||||
),
|
),
|
||||||
new GameLib.CustomCode.SnakeBody(
|
new GameLib.CustomCode.SnakeBody(
|
||||||
this.createGameMesh(this.materialBreadPatty),
|
GameLib.CustomCode.BODY_TYPE_BREAD_TAIL,
|
||||||
{
|
{
|
||||||
x : 4,
|
x : 4,
|
||||||
y : 3
|
y : 3
|
||||||
},
|
},
|
||||||
0
|
GameLib.CustomCode.ORIENTATION_UP
|
||||||
),
|
|
||||||
new GameLib.CustomCode.SnakeBody(
|
|
||||||
this.createGameMesh(this.materialBreadPatty),
|
|
||||||
{
|
|
||||||
x : 4,
|
|
||||||
y : 2
|
|
||||||
},
|
|
||||||
0
|
|
||||||
),
|
|
||||||
new GameLib.CustomCode.SnakeBody(
|
|
||||||
this.createGameMesh(this.materialBreadTail),
|
|
||||||
{
|
|
||||||
x : 4,
|
|
||||||
y : 1
|
|
||||||
},
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
true
|
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
this.snake[0].mesh.updateInstance('position');
|
|
||||||
this.snake[1].mesh.updateInstance('position');
|
|
||||||
this.snake[2].mesh.updateInstance('position');
|
|
||||||
this.snake[3].mesh.updateInstance('position');
|
|
||||||
|
|
||||||
this.animation.meshes.push(this.snake[0].mesh);
|
|
||||||
this.animation.meshes.push(this.snake[1].mesh);
|
|
||||||
this.animation.meshes.push(this.snake[2].mesh);
|
|
||||||
this.animation.meshes.push(this.snake[3].mesh);
|
|
||||||
|
|
||||||
//this.snake[2].mesh.instance.add(this.snake[3].mesh.instance);
|
|
||||||
//this.animationRotation.meshes.push(this.snake[3].mesh);
|
|
||||||
|
|
||||||
this.initializeGrid();
|
this.initializeGrid();
|
||||||
//this.visualizeGrid();
|
//this.visualizeGrid();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue