Something went wrong. Try again.
Experimental canvas 2D engine for tile-based sidescroller/sandbox games, created strictly for educational purposes.
Something went wrong. Try again.
Files
Verified signature Signed by thevoid.cafe SHA256:cqr/kf/Bi96Qd3VT8KlFEz3NtC+p1uhh+U4G+R1omi4 Click to copy SHA
Verified signature Signed by thevoid.cafe SHA256:cqr/kf/Bi96Qd3VT8KlFEz3NtC+p1uhh+U4G+R1omi4 Click to copy SHA
Verified signature Signed by thevoid.cafe SHA256:cqr/kf/Bi96Qd3VT8KlFEz3NtC+p1uhh+U4G+R1omi4 Click to copy SHA
- TypeScript 86%
- CSS 7%
- Docker 3%
- HTML 3%
- Shell <1%
README.md
# Cosmic
The experimental 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.
```sh
bun install
```
```sh
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 `Entity Component System`
The ECS handles Entities, their Components and the Features (Systems), that work with the former.
#### The `Entity` type
The Entity type is the most simple part of the ECS, it's a numeric value that identifies the entity within the rest of the stack.
Internally, a secondary map within the ECS
#### The `Component` class
Components are classes that hold flat data for a specific feature/function of an entity.
An example of a component could be "Position", which holds x and y values, as shown below.
```ts
class Position {
public constructor(
public x = 0,
public y = 0,
) {}
}
```
#### The `System` class
Systems declare a set of components whose data is required for an entity to be passed through them.
Once all supported entities have been collected, the System.execute() method is called by the ECS pipeline, receiving exactly one argument, an array of all entities to process.
The system then transforms the data connected to each e…