24 lines
618 B
JavaScript
24 lines
618 B
JavaScript
function CubeEntity() {
|
|
Entity.call(this);
|
|
|
|
this.add(POSITION);
|
|
this.add(MESH);
|
|
this.add(MATERIAL);
|
|
|
|
this.position.x = 0;
|
|
this.position.y = 0;
|
|
this.position.z = 0;
|
|
}
|
|
|
|
CubeEntity.prototype = Object.create(Entity.prototype);
|
|
CubeEntity.prototype.constructor = CubeEntity;
|
|
|
|
CubeEntity.prototype.update = function() {
|
|
var speed = 3.0;
|
|
var move = Input.axis2D(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT, INPUT_ACTION_UP, INPUT_ACTION_DOWN);
|
|
this.position.x += move.x * speed * TIME.delta;
|
|
this.position.z += move.y * speed * TIME.delta;
|
|
this.material.setColor(Color.rainbow());
|
|
};
|
|
|
|
module = CubeEntity; |