More cleanup
This commit is contained in:
+18
-31
@@ -1,35 +1,22 @@
|
||||
var Cube = {
|
||||
create: function() {
|
||||
var e = Entity.create();
|
||||
e.add(COMPONENT_TYPE_POSITION);
|
||||
e.position.x = 0;
|
||||
e.position.y = 0;
|
||||
e.position.z = 0;
|
||||
e.add(COMPONENT_TYPE_MESH);
|
||||
e.add(COMPONENT_TYPE_MATERIAL);
|
||||
// e.material.setColor(Color.black());
|
||||
function CubeEntity() {
|
||||
Entity.call(this);
|
||||
this.add(POSITION);
|
||||
this.position.x = 0;
|
||||
this.position.y = 0;
|
||||
this.position.z = 0;
|
||||
this.add(MESH);
|
||||
this.add(MATERIAL);
|
||||
}
|
||||
|
||||
print(Color);
|
||||
print(Color.prototype);
|
||||
Object.assign(CubeEntity.prototype, Entity.prototype);
|
||||
|
||||
return {
|
||||
_e: e,
|
||||
update: Cube.update,
|
||||
dispose: Cube.dispose
|
||||
};
|
||||
},
|
||||
|
||||
update: function() {
|
||||
var speed = 3.0;
|
||||
var dx = inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT);
|
||||
var dz = inputAxis(INPUT_ACTION_UP, INPUT_ACTION_DOWN);
|
||||
this._e.position.x += dx * speed * TIME.delta;
|
||||
this._e.position.z += dz * speed * TIME.delta;
|
||||
},
|
||||
|
||||
dispose: function() {
|
||||
this._e.dispose();
|
||||
}
|
||||
CubeEntity.prototype.update = function() {
|
||||
var speed = 3.0;
|
||||
var dx = inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT);
|
||||
var dz = inputAxis(INPUT_ACTION_UP, INPUT_ACTION_DOWN);
|
||||
this.position.x += dx * speed * TIME.delta;
|
||||
this.position.z += dz * speed * TIME.delta;
|
||||
this.material.setColor(Color.rainbow());
|
||||
};
|
||||
|
||||
Cube;
|
||||
module = CubeEntity;
|
||||
Reference in New Issue
Block a user