Experimental canvas 2D engine for tile-based sidescroller/sandbox games, created strictly for educational purposes.
entity-component-system game-engine canvas-2d
at develop 919 B view raw
1import { Cosmic, Entity, System } from "@cosmic/core"; 2import { Name } from "@cosmic/kit/components"; 3 4export class LoggingSystem extends System { 5 private worldStore: Map<string, any>; 6 7 constructor(engine: Cosmic) { 8 super(); 9 10 this.worldStore = engine.getStore("cosmic.world"); 11 } 12 13 public readonly requiredComponents = new Set([Name.name]); 14 15 public update(entities: Entity[], _deltaTime: number) { 16 for (const entity of entities) { 17 console.log(` 18 ==================== Entity ==================== 19 ID: ${entity.id} 20 Name: '${entity.getComponent(Name)?.name}' 21 Description: '${entity.getComponent(Name)?.description}' 22 23 =============== World Properties =============== 24 Gravitational Strength: ${this.worldStore.get("cosmic.world.gravity.strength") ?? 0} 25 Cell Size: ${this.worldStore.get("cosmic.world.grid.cellSize") ?? 0} 26 `); 27 } 28 } 29}