@null-studios/browser-game-engine
TypeScript icon, indicating that this package has built-in type declarations

7.0.0 • Public • Published

browser-game-engine

TypeScript game engine for the browser.

yarn add @null-studios/browser-game-engine

Usage

import { IoCGameContainer, Game } from '@null-studios/browser-game-engine';

class Configuration {
  public frameRate?: number;

  constructor(config: ConfigurationArguments) {
    this.frameRate = config.frameRate;
  }
}

class Application extends Game {
  public static inject = [
    'document',
    'configuration',
    'ecs',
    'graphics',
    'assets',
    'frame',
  ] as const;

  constructor(
    document: Document,
    configuration: Configuration,
    ecs: Ecs,
    graphics: Graphics,
    assets: Assets,
    frame: Frame,
  ) {
    super(
      document,
      configuration,
      ecs,
      graphics,
      assets,
      frame,
      configuration.metrics,
    );

    /* Do Stuff - Setup ECS, Assets, etc << */
  }
}

const container = new IoCGameContainer().register(
  {
    type: 'class',
    name: 'application',
    constructor: Application,
    lifetime: 'singleton',
  },
  {
    type: 'value',
    name: 'configuration',
    value: {
      frameRate: 120
      metrics: false,
    },
  },
);

const application = container.resolve('application');

application.start();

Publish

publish --access="public"

Readme

Keywords

none

Package Sidebar

Install

npm i @null-studios/browser-game-engine

Weekly Downloads

0

Version

7.0.0

License

Apache-2.0

Unpacked Size

8.11 MB

Total Files

107

Last publish

Collaborators

  • nate-wilkins