Phase 2: ECS foundation — world, components, systems, bridge
- bitECS world with time tracking (delta, elapsed, tick) - 5 components: Position, Velocity, SpriteRef, Health, ChemicalComposition - Movement system (velocity * delta) + bounce system (boundary reflection) - Health system with damage, healing, death detection - Entity factory (createGameEntity/removeGameEntity) - Phaser bridge: polling sync creates/destroys/updates circle sprites - GameScene: 20 colored circles bouncing at 60fps - BootScene: click-to-start transition, version bump to v0.2.0 - 39 ECS unit tests passing (74 total) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
36
src/ecs/components.ts
Normal file
36
src/ecs/components.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* ECS Components — plain objects with number arrays (bitECS 0.4 pattern)
|
||||
*
|
||||
* Components define the data schema for entities.
|
||||
* Systems read/write component data.
|
||||
* Bridge syncs component data to Phaser rendering.
|
||||
*/
|
||||
|
||||
/** World position in pixels */
|
||||
export const Position = {
|
||||
x: [] as number[],
|
||||
y: [] as number[],
|
||||
};
|
||||
|
||||
/** Movement velocity in pixels per second */
|
||||
export const Velocity = {
|
||||
vx: [] as number[],
|
||||
vy: [] as number[],
|
||||
};
|
||||
|
||||
/** Visual representation — used by bridge to create/update Phaser objects */
|
||||
export const SpriteRef = {
|
||||
color: [] as number[], // hex color (e.g. 0x00ff88)
|
||||
radius: [] as number[], // circle radius in pixels
|
||||
};
|
||||
|
||||
/** Entity health — damage, healing, death */
|
||||
export const Health = {
|
||||
current: [] as number[],
|
||||
max: [] as number[],
|
||||
};
|
||||
|
||||
/** Link to chemistry system — stores atomic number of primary element */
|
||||
export const ChemicalComposition = {
|
||||
primaryElement: [] as number[], // atomic number (e.g. 11 for Na)
|
||||
};
|
||||
Reference in New Issue
Block a user