# extra-game-loop

> ```sh npm install --save extra-game-loop # or yarn add extra-game-loop ```

Latest version **0.3.9** (published 2026-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install extra-game-loop
pnpm add extra-game-loop
yarn add extra-game-loop
bun add extra-game-loop
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.9 |
| Published | 2026-02-11 |
| First published | 2022-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 22.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/extra-game-loop
- Repository: https://github.com/BlackGlory/extra-game-loop
- Homepage: https://github.com/BlackGlory/extra-game-loop#readme
- Issues: https://github.com/BlackGlory/extra-game-loop/issues
- npm.io page: https://npm.io/package/extra-game-loop

## Dependencies (2)

- [extra-fsm](https://npm.io/package/extra-fsm.md) ^0.1.0
- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.1.5

## Recent versions

- 0.3.9 (latest) — 2026-02-11
- 0.3.8 — 2025-11-03
- 0.3.7 — 2024-08-24
- 0.3.6 — 2024-08-14
- 0.3.5 — 2024-08-14
- 0.3.4 — 2023-06-10
- 0.3.3 — 2023-05-08
- 0.3.2 — 2022-10-15
- 0.3.1 — 2022-10-12
- 0.3.0 — 2022-09-23
- 0.2.0 — 2022-09-22
- 0.1.4 — 2022-09-16
- 0.1.3 — 2022-09-15
- 0.1.2 — 2022-09-15
- 0.1.1 — 2022-08-28
- … 1 more at https://npm.io/package/extra-game-loop/versions

## README

# extra-game-loop
## Install
```sh
npm install --save extra-game-loop
# or
yarn add extra-game-loop
```

## Usage
```ts
import { GameLoop } from 'extra-game-loop'

const gameLoop = new GameLoop({
  fixedDeltaTime: 1000 / 50
, maximumDeltaTime: (1000 / 50) * 30
, update(deltaTime: number): void {
    // ...
  }
, fixedUpdate(deltaTime: number): void {
    // ...
  }
, lateUpdate(deltaTime: number, alpha: number): void {
    // ...
  }
, render(alpha: number): void {
    // ...
  }
})

gameLoop.start()
```

## API
### GameLoop
```ts
class GameLoop<FixedDeltaTime extends number = number> {
  constructor(options: {
    fixedDeltaTime: FixedDeltaTime /* ms */
    maximumDeltaTime: number /* ms */
    update?: (deltaTime: number /* ms */) => void
    fixedUpdate?: (deltaTime: FixedDeltaTime /* ms */) => void
    lateUpdate?: (deltaTime: number /* ms */, alpha: number) => void
    render?: (alpha: number /* [0, 1) */) => void
  })

  start(): void
  stop(): void
  getFramesOfSecond(): number

  /**
   * This method allows you to manually advance to the next frame.
   */
  nextFrame(deltaTime: number): void
}
```

### GameLoopLite
```ts
class GameLoopLite {
  constructor(options: {
    update?: (deltaTime: number /* ms */) => void
    render?: () => void
  })

  start(): void
  stop(): void
  getFramesOfSecond(): number

  /**
   * This method allows you to manually advance to the next frame.
   */
  nextFrame(deltaTime: number): void
}
```

The lite version of `GameLoop` for situations where the physics system is not needed.

Basically, it can be seen as an OOP wrapper for `requestAnimationFrame`,
so it can be used for non-game projects as well.

---
_Source: https://npm.io/package/extra-game-loop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
