Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitecs

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitecs

Tiny, data-driven, high performance ECS library written in Javascript

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
923
increased by7.08%
Maintainers
1
Weekly downloads
 
Created
Source

👾 bitECS 👾

Tiny, data-driven, high performance ECS library written using JavaScript TypedArrays.

Features

  • <3kb gzipped
  • Zero dependencies
  • Node or Browser
  • Fast

Install

npm i bitecs

Example

import World from 'bitecs'

// Create a world
const world = World()

// Register some components
world.registerComponent('POSITION', { x: 'float32', y: 'float32' })
world.registerComponent('VELOCITY', { vx: 'int8', vy: 'int8', speed: 'uint16' })

// Register a system
world.registerSystem({
  name: 'MOVEMENT',
  components: ['POSITION', 'VELOCITY'],
  update: (position, velocity) => eid => {
    position.x[eid] += velocity.vx[eid] * velocity.speed[eid]
    position.y[eid] += velocity.vy[eid] * velocity.speed[eid]
  }
})

// Create an entity
const eid = world.addEntity()

// Add components to entity
world.addComponent('POSITION', eid, { x: 100, y: 100 })
world.addComponent('VELOCITY', eid, { vx: 1, vy: -1, speed: 100 })

// Create an event loop and step world
setInterval(() => {
  world.step()
}, 1000 / 30) // 30 tick on server

// For browser, use frame rate
const loop = () => {
  world.step()
  requestAnimationFrame(loop)
}
loop()

Full documentation and feature rich examples can be found here.

FAQs

Package last updated on 28 Oct 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc