feat: Implement basic horror world with standard materials, ambient lighting, pillars, and a target object, alongside general code cleanup and logging improvements.
This commit is contained in:
50
src/Game.js
50
src/Game.js
@@ -1,19 +1,12 @@
|
||||
import { Graphics } from './Graphics.js';
|
||||
import { World } from './World.js';
|
||||
import { Player } from './Player.js';
|
||||
import * as THREE from 'three';
|
||||
|
||||
export class Game {
|
||||
constructor() {
|
||||
window.log('Game constructor start');
|
||||
try {
|
||||
this.graphics = new Graphics();
|
||||
this.world = new World(this.graphics.scene);
|
||||
this.player = new Player(this.graphics.camera, this.world.colliders);
|
||||
window.log('All components created successfully');
|
||||
} catch (e) {
|
||||
window.log('CRITICAL ERROR during setup: ' + e.message);
|
||||
}
|
||||
this.graphics = new Graphics();
|
||||
this.world = new World(this.graphics.scene);
|
||||
this.player = new Player(this.graphics.camera, this.world.colliders);
|
||||
|
||||
this.isRunning = false;
|
||||
this.lastTime = 0;
|
||||
@@ -23,38 +16,21 @@ export class Game {
|
||||
setupUI() {
|
||||
const startScreen = document.getElementById('start-screen');
|
||||
const hud = document.getElementById('hud');
|
||||
if (!startScreen) {
|
||||
window.log('ERROR: start-screen not found');
|
||||
return;
|
||||
}
|
||||
|
||||
startScreen.addEventListener('click', () => {
|
||||
window.log('Start screen clicked');
|
||||
if (this.player) {
|
||||
this.player.lockControls();
|
||||
}
|
||||
startScreen.style.display = 'none';
|
||||
if (hud) hud.style.display = 'block';
|
||||
this.isRunning = true;
|
||||
window.log('Game isRunning = true');
|
||||
});
|
||||
if (startScreen) {
|
||||
startScreen.addEventListener('click', () => {
|
||||
if (this.player) this.player.lockControls();
|
||||
startScreen.style.display = 'none';
|
||||
if (hud) hud.style.display = 'block';
|
||||
this.isRunning = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
start() {
|
||||
window.log('Game.start() begin');
|
||||
try {
|
||||
if (this.world) this.world.load();
|
||||
if (this.player) {
|
||||
const playerObj = this.player.getObject();
|
||||
this.graphics.scene.add(playerObj);
|
||||
}
|
||||
window.log('World/Player loading complete');
|
||||
} catch (e) {
|
||||
window.log('ERROR in Game.start(): ' + e.message);
|
||||
}
|
||||
|
||||
this.world.load();
|
||||
this.graphics.scene.add(this.player.getObject());
|
||||
requestAnimationFrame(this.loop.bind(this));
|
||||
window.log('Animation loop requested');
|
||||
}
|
||||
|
||||
loop(time) {
|
||||
|
||||
Reference in New Issue
Block a user