INNER CODE UNIT · JavaScript

GameEngine

rohitg00/k8sgames · js/engine/GameEngine.js:138

export class GameEngine {
  constructor(options = {}) {
    this.eventBus = new EventBus();
    this.on = this.eventBus.on.bind(this.eventBus);
    this.off = this.eventBus.off.bind(this.eventBus);
    this.emit = this.eventBus.emit.bind(this.eventBus);
    this.once = this.eventBus.once.bind(this.eventBus);
    this.cluster = new ClusterState(this.eventBus);
    this.simulation = new SimulationTick(this.cluster, this.eventBus);

    this.state = GAME_STATES.INIT;
    this.mode = options.mode || GAME_MODES.SANDBOX;
    this.difficulty = options.difficulty || 'normal';

    this._rafId = null;
    this._lastTimestamp = 0;
    this._accumulator = 0;
    this._fixedTimeStep = 1000 / (options.ticksPerSecond || 20);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…