Files
dusk/assets/scripts/Player.js
T
YourWishes 42cb84b610 Extract player entity setup into a Player class
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.
2026-08-02 21:06:31 -05:00

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;