# game-time-accumulator

> game-time-accumulator class for creating a game

Latest version **1.3.0** (published 2017-10-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install game-time-accumulator
pnpm add game-time-accumulator
yarn add game-time-accumulator
bun add game-time-accumulator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2017-10-07 |
| First published | 2015-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yuval Saraf |
| Maintainers | unimonkiez, yuvalsaraf |
| Keywords | game, time, accumulator, game, es6 |

## Links

- npm: https://www.npmjs.com/package/game-time-accumulator
- Repository: https://github.com/yuvalsaraf/game-time-accumulator
- Homepage: https://github.com/yuvalsaraf/game-time-accumulator#readme
- Issues: https://github.com/yuvalsaraf/game-time-accumulator/issues
- npm.io page: https://npm.io/package/game-time-accumulator

## Dependencies (1)

- [raf](https://npm.io/package/raf.md) ^3.1.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 1.3.0 (latest) — 2017-10-07
- 1.2.2 — 2015-09-16
- 1.0.0 — 2015-08-11

## README

[![npm version](https://badge.fury.io/js/game-time-accumulator.svg)](http://badge.fury.io/js/game-time-accumulator)
# game-time-accumulator
A great class to manage updates to your own game using time accumulator principle.
Works on browser + NodeJS (check [this](https://github.com/chrisdickinson/raf) for compability table)

### Install
```npm install game-time-accumulator``` or ```bower install game-time-accumulator```.

### Use
```
var GameTimeAccumulator = require('game-time-accumulator');

var canvas = document.getElementById('game-canvas');
var ctx = canvas.getContext('2d');

// Happens exactly in a loop you define
var stepFn = function(){
  player.move();
}

// Happen every requestAnimationFrame
var drawFn = function(){
  // Clear canvas before each fraw
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  player.draw(ctx);
}

var game = new GameTimeAccumulator(stepFn, drawFn, 200);
game.start();

```

### Parameters
**stepFn** - (Function, default noop) - Run every step loop (you define the time)

**drawFn** - (Function, default noop) - Run every requestAnimationFrame loop (system defines the time)

**stepSize** - (Number, default 16 - ~60fps) - Milliseconds of step to loop

## Functions
```start()``` - Starts the game

```stop()``` - Stops the game

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