42cb84b610
Moves the capsule/physics/renderable/PLAYER setup out of overworldscene.js's inline init() into assets/scripts/Player.js so the scene module just instantiates it.
27 lines
728 B
JavaScript
27 lines
728 B
JavaScript
// Copyright (c) 2026 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
// Player: dynamic capsule body, moved relative to the camera by PLAYER's
|
|
// own update callback (see entityplayer.c).
|
|
class Player {
|
|
constructor() {
|
|
this.entity = new Entity();
|
|
|
|
this.position = this.entity.add(POSITION);
|
|
this.position.setLocalPosition(0.0, 2.0, 0.0);
|
|
|
|
this.physics = this.entity.add(PHYSICS);
|
|
this.physics.setShape(PHYSICS_SHAPE_CAPSULE, 0.5, 0.5);
|
|
|
|
this.renderable = this.entity.add(RENDERABLE);
|
|
this.renderable.setMesh(0, MESH_CAPSULE);
|
|
this.renderable.setColor(0, 0, 255, 255);
|
|
|
|
this.entity.add(PLAYER);
|
|
}
|
|
}
|
|
|
|
module.exports = Player;
|