Gating network behind compile flag
This commit is contained in:
@@ -19,6 +19,10 @@ class Player extends Entity {
|
||||
|
||||
this.add(PLAYER);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Player;
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
var CAMERA_OFFSET_ANGLE = 0.0;
|
||||
var CAMERA_OFFSET_RADIUS = 18.0;
|
||||
var CAMERA_OFFSET_HEIGHT = 10.0;
|
||||
|
||||
class PlayerCamera {
|
||||
class PlayerCamera extends Entity {
|
||||
constructor(target) {
|
||||
super();
|
||||
this.target = target;
|
||||
|
||||
this.entity = new Entity();
|
||||
this.position = this.entity.add(POSITION);
|
||||
this.entity.add(CAMERA);
|
||||
this.position = this.add(POSITION);
|
||||
this.add(CAMERA);
|
||||
|
||||
this.update();
|
||||
}
|
||||
@@ -21,11 +16,15 @@ class PlayerCamera {
|
||||
update() {
|
||||
var targetPosition = this.target.position.getLocalPosition();
|
||||
|
||||
var eyeX = targetPosition.x + Math.cos(CAMERA_OFFSET_ANGLE) *
|
||||
CAMERA_OFFSET_RADIUS;
|
||||
var eyeY = targetPosition.y + CAMERA_OFFSET_HEIGHT;
|
||||
var eyeZ = targetPosition.z + Math.sin(CAMERA_OFFSET_ANGLE) *
|
||||
CAMERA_OFFSET_RADIUS;
|
||||
var eyeX = (
|
||||
targetPosition.x + Math.cos(CAMERA_OFFSET_ANGLE) * CAMERA_OFFSET_RADIUS
|
||||
);
|
||||
var eyeY = (
|
||||
targetPosition.y + CAMERA_OFFSET_HEIGHT
|
||||
);
|
||||
var eyeZ = (
|
||||
targetPosition.z + Math.sin(CAMERA_OFFSET_ANGLE) * CAMERA_OFFSET_RADIUS
|
||||
);
|
||||
|
||||
this.position.lookAt(
|
||||
eyeX, eyeY, eyeZ,
|
||||
@@ -33,6 +32,10 @@ class PlayerCamera {
|
||||
0.0, 1.0, 0.0
|
||||
);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.target = null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PlayerCamera;
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
class TestPlane {
|
||||
class TestPlane extends Entity {
|
||||
constructor() {
|
||||
this.entity = new Entity();
|
||||
super();
|
||||
|
||||
this.position = this.entity.add(POSITION);
|
||||
this.position = this.add(POSITION);
|
||||
this.position.setLocalPosition(-10.0, 0.0, -10.0);
|
||||
this.position.setLocalScale(20.0, 1.0, 20.0);
|
||||
|
||||
this.physics = this.entity.add(PHYSICS);
|
||||
this.physics = this.add(PHYSICS);
|
||||
this.physics.setBodyType(PHYSICS_BODY_STATIC);
|
||||
this.physics.setShape(PHYSICS_SHAPE_PLANE, 0.0, 1.0, 0.0, 0.0);
|
||||
|
||||
this.renderable = this.entity.add(RENDERABLE);
|
||||
this.renderable = this.add(RENDERABLE);
|
||||
this.renderable.setMesh(0, MESH_PLANE);
|
||||
this.renderable.setColor(128, 128, 128, 255);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TestPlane;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
var OverworldScene = require('./overworldscene.js');
|
||||
|
||||
// Entry point run once at startup (see game.c). Swap which scene module
|
||||
// gets passed to Scene.set() here to change what the game boots into.
|
||||
var overworldScene = require('./overworldscene.js');
|
||||
Scene.set(overworldScene);
|
||||
Scene.set(new OverworldScene());
|
||||
@@ -1,26 +1,36 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
var Player = require('./Player.js');
|
||||
var PlayerCamera = require('./PlayerCamera.js');
|
||||
var TestPlane = require('./TestPlane.js');
|
||||
|
||||
var camera = null;
|
||||
|
||||
module.exports = {
|
||||
init: function() {
|
||||
var player = new Player();
|
||||
new TestPlane();
|
||||
camera = new PlayerCamera(player);
|
||||
},
|
||||
|
||||
update: function() {
|
||||
if(camera) camera.update();
|
||||
},
|
||||
|
||||
dispose: function() {
|
||||
camera = null;
|
||||
class OverworldScene {
|
||||
constructor() {
|
||||
this.time = 0;
|
||||
}
|
||||
};
|
||||
|
||||
init() {
|
||||
this.player = new Player();
|
||||
this.plane = new TestPlane();
|
||||
this.camera = new PlayerCamera(this.player);
|
||||
}
|
||||
|
||||
update() {
|
||||
this.camera.update();
|
||||
|
||||
this.time += Time.delta;
|
||||
if(this.time > 3.0) {
|
||||
Scene.set(new OverworldScene());
|
||||
}
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.camera.dispose();
|
||||
this.player.dispose();
|
||||
this.plane.dispose();
|
||||
|
||||
this.camera = null;
|
||||
this.player = null;
|
||||
this.plane = null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OverworldScene;
|
||||
Reference in New Issue
Block a user