Files
dusk/assets/scenes/cube.js
T
2026-05-19 23:13:41 -05:00

34 lines
790 B
JavaScript

var CubeEntity = include('entities/CubeEntity.js');
function CubeScene() {
Map.load('test');
this.cam = new Entity();
this.cam.add(POSITION);
this.cam.add(CAMERA);
this.player = new CubeEntity();
this.player.position.position = new Vec3(0, 0, 0);
}
CubeScene.prototype = Object.create(Scene.prototype);
CubeScene.prototype.constructor = CubeScene;
CubeScene.prototype.update = function() {
this.player.update();
var pos = this.player.position.position;
this.cam.position.position = new Vec3(pos.x, pos.y + 8, pos.z + 8);
this.cam.position.lookAt(pos);
Map.setPosition(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z));
};
CubeScene.prototype.dispose = function() {
this.cam.dispose();
this.player.dispose();
Map.dispose();
};
module = CubeScene;