UNPKG

itay-game-loop

Version:

A game loop written in typescript.

64 lines (63 loc) 2.01 kB
(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class TimingController { constructor() { this._minMillisecondsPerTick = 0; this._maxMillisecondsPerTick = Number.MAX_VALUE; } get minMillisecondsPerTick() { return this._minMillisecondsPerTick; } set minMillisecondsPerTick(value) { if (value < 0) { this._minMillisecondsPerTick = 0; } else { this._minMillisecondsPerTick = value; } } get maxMillisecondsPerTick() { return this._maxMillisecondsPerTick; } set maxMillisecondsPerTick(value) { if (value <= 0) { this._maxMillisecondsPerTick = Number.MAX_VALUE; } else { this._maxMillisecondsPerTick = value; } } get minTicksPerSecond() { return 1000 / this._maxMillisecondsPerTick; } set minTicksPerSecond(value) { if (value <= 0) { this.maxMillisecondsPerTick = 0; } else { this.maxMillisecondsPerTick = 1000 / value; } } get maxTicksPerSecond() { return 1000 / this._minMillisecondsPerTick; } set maxTicksPerSecond(value) { if (value <= 0) { this.minMillisecondsPerTick = 0; } else { this.minMillisecondsPerTick = 1000 / value; } } } exports.TimingController = TimingController; });