/
memoryspeak
/
UlamCodeWeb
Обзор
Документация
Войти
/
memoryspeak
/
UlamCodeWeb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
js/Loop.js
25 строк
568 B
memoryspeak
first commit
07 фев 2026, 20:41
07 фев 2026, 20:41
a3d2754
Код
Авторство
О чём код?
export default class Loop { constructor(update, display) { this.update = update; this.display = display; this.deltaTime = 0; this.lastUpdate = 0; this.maxInterval = 40; requestAnimationFrame(stampTime => this.animate(stampTime)); }; animate(currentTime) { requestAnimationFrame(stampTime => this.animate(stampTime)); this.deltaTime = currentTime - this.lastUpdate; if (this.deltaTime < this.maxInterval) { this.update(this.deltaTime / 1000); this.display(); }; this.lastUpdate = currentTime; }; };