Experimental canvas 2D engine for tile-based sidescroller/sandbox games, created strictly for educational purposes.
entity-component-system game-engine canvas-2d
TypeScript 87.4%
HTML 12.6%
8 2 0

Clone this repository

https://tangled.org/thevoid.cafe/cosmic https://tangled.org/did:plc:jzipyzvpwhyfnn3jeymuabfv/cosmic
git@tangled.org:thevoid.cafe/cosmic git@tangled.org:did:plc:jzipyzvpwhyfnn3jeymuabfv/cosmic

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

Cosmic#

The experimental pixi.js based engine for tile-based 2D games, created strictly for educational purposes.

Requirements#

To run the demo project and experiment with the engine, the following tools are required.

  • Bun v1.3+

Try it out!#

You can try out the ever evolving demo project at any time, by running the following commands.

bun install
bun dev

Architecture#

The following will explain the data-flow and general architecture of the engine, including the main class, the ECS and more!

The Cosmic class#

The Pipeline class#

Pipelines are singular, scoped and enqueue-able looping directives.

For example, there might be a "rendering" pipeline, which draws the state of various entities onto the screen, on each frame, using drawing APIs.

These are enqueued separately, rather than having one hard-coded main loop, to allow varying execution speeds, like a rendering pipeline running on every frame, and a physics pipeline running at a calculated interval of 60 FPS.

The Layer class#

The EntityComponentSystem class#

The Store class#

Stores are utilized as a means of shared state throughout the engine.

They are defined as static DTO-like (data transfer object) classes that extend the Store class.