New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

powertrain

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

powertrain

A lightweight game loop written to prioritize updates and fill in with extra renders.

latest
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

Powertrain

A lightweight game loop written to prioritize updates and fill in with extra renders.

Updates will be called as accurately as possible while render operations will happen as often as possible. If, for some reason, lag has caused more than enough time for more than one update to occur they will be called sequentially until caught up. A render will always happen afterwards upates are done.

Testing and dev are done with babel.

import Powertrain from 'powertrain'

const engine = new Powertrain({
  playspeed: 1,     // optional, default = 1
  fps: 60,          // optional, default = 60
  update: () => {}, // optional, default = no-op
  render: () => {}, // optional, default = no-op
})

engine.start()
engine.stop()

Usage

NPM

constructor()

NameTypeAttributesDefaultDescription
obj.playSpeednumber1A scalar for the speed of play.
obj.fpsnumber60The target fraes per second. This is the number of updates per second that should occur. Not the number of renders.
obj.updatefunction()=>{}The function to update game logic.
obj.renderfunction(scalar)=>{}The function to render the game. Accepts a scalar representing progress towards next frame. Can be used for interpolation.

start()

Starts update loop and sets running flag to true and calls for a requestAnimationFrame (provided by a crossplatform polyfill).

stop()

Sets running flag to false. This will stop the loop.

TODO:

Feedback ✉️

It is greatly appreciated! 🎉

Website 🌐

js@jacobsmith.tech

https://github.com/limeandcoconut

@limeandcoconut 🐦

Cheers!

License

ISC, see LICENSE.md for details.

Keywords

engine

FAQs

Package last updated on 11 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts