web-engine-canvas
v1.1.1-alpha
Published
A simple, lightweight and completely dependency free html canvas engine.
Readme
Web Engine Canvas
Version 1.1.1-alpha
A simple, lightweight and completely dependency free canvas engine. Create games, complex animations or specialized business solutions.
Examples
Package Footprint
| Library | Size | |---------|-------| | ESM | ~38KB | | UMD | ~31KB |
Concept
The engine follows a simple concept → scenes with entities:
- A scene is a component that consumes entities and calls three phases for them.
- A entity is a component that can react to every scene phase.
Scene Phases:
- Update: Update programmatic logic for the entity.
- Collision: Handle collisions with other entities.
- Draw: Display the entity on the canvas.
Quick Setup
- Install the package.
npm install web-engine-canvas- Embed the WebComponent within your page.
<engine-canvas id="webcomponent-id"></engine-canvas>- Retrieve the engine from the WebComponent.
import { EngineCanvas } from "web-engine-canvas";
const engine = EngineCanvas.getEngine("webcomponent-id", window);- Initialize your assets.
const assetsFactory = new FactoryAssets();
const assets = assetsFactory.create();
assets.addImage(...);
assets.addAudio(...);
await assets.loadImagesAsync();
await assets.loadAudiosAsync();- Create your scenes and entities.
const scene = new Scene(assets);
scene.push(...new Entity());
engine.push(scene);- Start the engine.
engine.start();License
The Web Engine Canvas is licensed under MIT. See the license file for more details.
