zippy-game-engine
Version:
A lightweight game engine for web games
38 lines • 1.15 kB
JavaScript
import { SceneSystem } from "../systems/scene-system.js";
export class GameEngine {
inputSystem;
sceneSystem;
debugMode = true;
constructor(inputSystem, sceneSystem) {
this.inputSystem = inputSystem;
this.sceneSystem = sceneSystem;
}
handleDebugToggle() {
this.debugMode = !this.debugMode;
console.log(`Debug mode: ${this.debugMode ? "ON" : "OFF"}`);
}
frameTick = (context) => {
this.inputSystem.update();
this.sceneSystem.currentScene?.update?.(context);
this.sceneSystem.currentScene?.render?.(context);
};
get availableScenes() {
return this.sceneSystem.availableScenes;
}
get activeScene() {
return this.sceneSystem.activeScene;
}
get input() {
return this.inputSystem;
}
onSceneChange(callback) {
return this.sceneSystem.onSceneChange(callback);
}
transitionToScene(name) {
return this.sceneSystem.transitionToScene(name);
}
registerScene(name, sceneModule) {
this.sceneSystem.registerScene(name, sceneModule);
}
}
//# sourceMappingURL=game-engine.js.map