25 lines
733 B
JavaScript
25 lines
733 B
JavaScript
var OverworldEntity = include('entities/OverworldEntity.js');
|
|
|
|
function CubeEntity() {
|
|
OverworldEntity.call(this);
|
|
|
|
this.add(RENDERABLE);
|
|
|
|
this.cubeMesh = Mesh.createCube();
|
|
this.renderable.mesh = this.cubeMesh;
|
|
}
|
|
|
|
CubeEntity.prototype = Object.create(OverworldEntity.prototype);
|
|
CubeEntity.prototype.constructor = CubeEntity;
|
|
|
|
CubeEntity.prototype.update = function() {
|
|
OverworldEntity.prototype.update.call(this);
|
|
var speed = 5.0;
|
|
var move = Input.axis2D(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT, INPUT_ACTION_UP, INPUT_ACTION_DOWN);
|
|
this.position.position.x += move.x * speed * TIME.delta;
|
|
this.position.position.z += move.y * speed * TIME.delta;
|
|
this.renderable.color = Color.rainbow();
|
|
};
|
|
|
|
module = CubeEntity;
|