npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kobandavis/ecs

v1.0.5

Published

This is a simple ECS engine written in TypeScript, intended to learn about the ECS architecture within game development. I use the library `@kobandavis/canvas` as a utility.

Downloads

14

Readme

ECS

This is a simple ECS engine written in TypeScript, intended to learn about the ECS architecture within game development.
I use the library @kobandavis/canvas as a utility.

Concept

ECS stands for Entity-Component-System.
This pattern follows the idea that:

  1. Everything is a game is an Entity,
  2. an Entity will contain Components, or essentially data, that
  3. are passed into a series of Systems every frame of the game loop.

ECS screenshot

Exports

  • @kobandavis/ecs

    The following classes are the core of the ECS architecture, relying on the principle of composition over inheritance.
    These classes are made to be imported, and then implemented by other classes, using the class x implements y {} syntax.

    • Entity

      An entity is the base object of the project. It will have 4 public methods for manipulating Components:

      • getComponent -> Component
      • hasComponent -> boolean
      • addComponent -> void
      • removeComponent -> void

      It also has a print method, useful for debugging.

    • Component

      A component is a piece of data that is tied to an entity. Think of it as a key/value pair. It will have 1 public method:

      • update

        This method should be called when the value of the component needs to be updated. It will also have 2 public properties:

      • name

        The name of the component, or essentially the key, which is used when <Entity>.getComponent(name) is called

      • value

        The value of the component, which is used as state.

    • System

      A system is the logic of the project. It will have 3 public methods:

      • enter

        This method is called whenever a new entity is added to the engine, usually to add entities to a local store.

      • update

        This method is called every frame of the game loop. This is where the logic happens, usually applied to the entities stored prior.

      • exit

        This method is called whenever an entity is removed from the engine. A common use case is to remove the entity from the local store, and to take necessary steps to teardown the entity.

    Also included is an engine. This class helps to run the project.

    • Engine

      This class has 2 public properties:

      • canvas

        This is an instance of @kobandavis/canvas's Canvas class. This is useful for rendering the project, especially when used inside nextTick as explained below.

      • systems

        This is an array of the systems used to process the projects logic. Each of the lifecycle methods below will call the respective methods on each system in the array.

      This class also has 3 public methods:

      • nextTick

        This method clears the canvas, then calls <System>.update() on each system in the Engine.systems array.

      • addEntity

        This method accepts an entity, which will be fed into all of the systems, using <System>.enter(entity)

      • removeEntity

        This method accepts an entity id, or string, which will call <System>.exit(entityId) for each system.