@null-studios/browser-game-engine
v7.0.0
Published
TypeScript game engine for the browser.
Downloads
11
Readme
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"