tetris stuff

beta.r3js.org
-=yb4f310 2017-09-19 21:27:11 +02:00
parent 4d7ac34a8a
commit d90852e413
7 changed files with 67 additions and 22 deletions

View File

@ -84,6 +84,8 @@ GameLib.Event.PARENT_WORLD_CHANGE = 0x42;
GameLib.Event.ANIMATE = 0x43;
GameLib.Event.ANIMATION_COMPILE_SUCCESS = 0x44;
GameLib.Event.ANIMATION_COMPILE_FAILED = 0x45;
GameLib.Event.CUSTOM_CODE_SYSTEM_STARTED = 0x46;
GameLib.Event.GAME_OVER = 0x47;
/**
* Returns string name of event ID
@ -163,6 +165,8 @@ GameLib.Event.GetEventName = function(number) {
case 0x43 : return 'animate';
case 0x44 : return 'animation_compile_success';
case 0x45 : return 'animation_compile_failed';
case 0x46 : return 'custom_code_system_started';
case 0x47 : return 'game_over';
break;
}

View File

@ -291,10 +291,43 @@ GameLib.Component.prototype.clone = function() {
apiObject.id = GameLib.Utils.RandomId();
apiObject.name = apiObject.name + ' Clone (' + apiObject.id + ')';
apiObject.name = apiObject.name + ' (Clone)';
var runtimeObject = null;
try {
runtimeObject = new this.constructor(this.graphics, apiObject);
} catch (e){
console.log(e);
try {
runtimeObject = new this.constructor(this.physics, apiObject);
} catch (e) {
console.log(e);
try {
runtimeObject = new this.constructor(this.coder, apiObject);
} catch (e) {
console.log(e);
console.log('failed to construct a runtime component');
return;
}
}
}
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{
component : runtimeObject
}
);
runtimeObject.parentEntity = null;
// if (this.parentEntity instanceof GameLib.Entity) {
// this.parentEntity.addComponent(runtimeObject);
// }
return runtimeObject;
//TODO - create runtime object - add to parent entity -
//var object = this.constructor.call(this, this.graphics, apiObject);
};
GameLib.Component.prototype.getStorageDependencies = function() {

View File

@ -114,7 +114,9 @@ GameLib.D3.CustomCode.prototype.launchEditor = function(){
value : this.code,
mode : 'javascript',
lineNumbers : true,
scrollbarStyle : 'overlay'
scrollbarStyle : 'overlay',
indentWithTabs: true,
indentUnit : 4
}
);

View File

@ -1171,4 +1171,4 @@ GameLib.D3.Mesh.prototype.computeBoundingBox = function(geometry) {
this.size.x = geometry.boundingBox.getSize().x;
this.size.y = geometry.boundingBox.getSize().y;
this.size.z = geometry.boundingBox.getSize().z;
};
};

View File

@ -146,15 +146,11 @@ GameLib.Matrix4.prototype.updateInstance = function() {
*/
GameLib.Matrix4.prototype.toApiObject = function () {
return this.rows.map(
function(row) {
if (row instanceof GameLib.Vector4) {
return row.toApiObject();
} else {
console.warn('Incompatible conversion to API matrix for vector: ', row);
throw new Error('Incompatible conversion to API matrix for a vector');
}
}
return new GameLib.API.Matrix4(
this.rows[0].toApiObject(),
this.rows[1].toApiObject(),
this.rows[2].toApiObject(),
this.rows[3].toApiObject()
);
};

View File

@ -46,9 +46,9 @@ GameLib.System.Animation.prototype.start = function() {
intermediateAngle : mesh.quaternion.angle,
subscription : null,
inProcess : false,
blocking : animation.blocking,
callbacks : [],
storedValues : []
blocking : animation.blocking//,
// callbacks : [],
// storedValues : []
};
var getIntermediateAngle = function() {
@ -57,9 +57,9 @@ GameLib.System.Animation.prototype.start = function() {
var getTargetAngle = function() {
if (mesh.animationObject.storedValues.length > 0) {
return mesh.animationObject.storedValues[mesh.animationObject.storedValues.length - 1];
}
// if (mesh.animationObject.storedValues.length > 0) {
// return mesh.animationObject.storedValues[mesh.animationObject.storedValues.length - 1];
// }
return mesh.animationObject.targetAngle;
};
@ -175,7 +175,7 @@ GameLib.System.Animation.prototype.start = function() {
// callback();
// }
mesh.animationObject.storedValues = [];
// mesh.animationObject.storedValues = [];
}
};
@ -201,8 +201,10 @@ GameLib.System.Animation.prototype.start = function() {
console.log('another animation is already in process');
GameLib.Utils.PushUnique(mesh.animationObject.storedValues, value);
// setTargetAngle(value);
// GameLib.Utils.PushUnique(mesh.animationObject.storedValues, value);
//
// mesh.animationObject.callbacks.push(
// function(__value) {
// return function(){

View File

@ -41,6 +41,14 @@ GameLib.System.CustomCode.prototype.start = function() {
}.bind(this));
GameLib.Event.Emit(
GameLib.Event.CUSTOM_CODE_SYSTEM_STARTED,
{
system : this,
components : this.customCodeComponents
}
)
};
/**