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 mesh
|
||||
* @param position
|
||||
* @param index
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.CustomCode.GameObject = function(
|
||||
objectType,
|
||||
type,
|
||||
mesh,
|
||||
position,
|
||||
index
|
||||
position
|
||||
) {
|
||||
if (GameLib.Utils.UndefinedOrNull(objectType)) {
|
||||
objectType = GameLib.CustomCode.OBJECT_TYPE_NONE;
|
||||
|
@ -220,11 +218,6 @@ GameLib.CustomCode.GameObject = function(
|
|||
position = null;
|
||||
}
|
||||
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.position = null;
|
||||
|
||||
this.index = -1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -400,8 +391,7 @@ GameLib.CustomCode.prototype.createGameObject = function(
|
|||
objectType,
|
||||
type,
|
||||
mesh,
|
||||
position,
|
||||
array.length
|
||||
position
|
||||
)
|
||||
gameObject.applyToMesh(true);
|
||||
break;
|
||||
|
@ -410,7 +400,6 @@ GameLib.CustomCode.prototype.createGameObject = function(
|
|||
type,
|
||||
mesh,
|
||||
position,
|
||||
array.length,
|
||||
orientation
|
||||
)
|
||||
gameObject.applyToMesh(true);
|
||||
|
@ -518,18 +507,17 @@ GameLib.CustomCode.prototype.createFood = function(delta) {
|
|||
* @param type
|
||||
* @param mesh
|
||||
* @param position
|
||||
* @param index
|
||||
* @param orientation
|
||||
* @param flip
|
||||
* @param backupMesh
|
||||
* @param isTail
|
||||
* @property animation
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.CustomCode.SnakeBody = function(
|
||||
type,
|
||||
mesh,
|
||||
position,
|
||||
index,
|
||||
orientation,
|
||||
flip,
|
||||
backupMesh,
|
||||
|
@ -541,8 +529,7 @@ GameLib.CustomCode.SnakeBody = function(
|
|||
GameLib.Object.OBJECT_TYPE_SNAKE_BODY,
|
||||
type,
|
||||
mesh,
|
||||
position,
|
||||
index
|
||||
position
|
||||
);
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(orientation)) {
|
||||
|
@ -566,6 +553,10 @@ GameLib.CustomCode.SnakeBody = function(
|
|||
this.isTail = isTail;
|
||||
|
||||
this.applyToMesh();
|
||||
|
||||
var animation = GameLib.EntityManager.Instance.findComponentById('8kb7utb2fn');
|
||||
|
||||
animation.meshes.push(this.mesh);
|
||||
};
|
||||
|
||||
GameLib.CustomCode.SnakeBody.prototype = Object.create(GameLib.CustomCode.GameObject.prototype);
|
||||
|
@ -934,25 +925,19 @@ GameLib.Event.Subscribe(
|
|||
*/
|
||||
this.snake.map(
|
||||
function(body) {
|
||||
body.mesh.geometry = null;
|
||||
body.mesh.materials = null;
|
||||
body.mesh.remove();
|
||||
body.dispose();
|
||||
}
|
||||
)
|
||||
|
||||
this.food.map(
|
||||
function(food) {
|
||||
food.mesh.geometry = null;
|
||||
food.mesh.materials = null;
|
||||
food.mesh.remove();
|
||||
food.dispose();
|
||||
}
|
||||
)
|
||||
|
||||
this.powerups.map(
|
||||
function(powerup) {
|
||||
powerup.mesh.geometry = null;
|
||||
powerup.mesh.materials = null;
|
||||
powerup.mesh.remove();
|
||||
powerup.dispose();
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -962,55 +947,23 @@ GameLib.Event.Subscribe(
|
|||
|
||||
this.snake = [
|
||||
new GameLib.CustomCode.SnakeBody(
|
||||
this.createGameMesh(this.materialBreadHead),
|
||||
GameLib.CustomCode.BODY_TYPE_BREAD_HEAD,
|
||||
{
|
||||
x : 4,
|
||||
y : 4
|
||||
},
|
||||
0
|
||||
GameLib.CustomCode.ORIENTATION_UP
|
||||
),
|
||||
new GameLib.CustomCode.SnakeBody(
|
||||
this.createGameMesh(this.materialBreadPatty),
|
||||
GameLib.CustomCode.BODY_TYPE_BREAD_TAIL,
|
||||
{
|
||||
x : 4,
|
||||
y : 3
|
||||
},
|
||||
0
|
||||
),
|
||||
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
|
||||
GameLib.CustomCode.ORIENTATION_UP
|
||||
)
|
||||
];
|
||||
|
||||
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.visualizeGrid();
|
||||
|
||||
|
|
Loading…
Reference in New Issue