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.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// 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;
|
||||
Reference in New Issue
Block a user