diff options
| author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-09-07 20:20:07 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-09-12 17:23:30 -0700 |
| commit | 8ec7f5368232d59f344e1067e1bad5e48dbcb7ae (patch) | |
| tree | 1ad2df4dc00773f2307d1525cc80ac7410ea8fba /static/src/engine/trailing_position.ts | |
| parent | e4e31978bae7e45be57b376415a4b925ac8cbc03 (diff) | |
| download | kennel.hatecomputers.club-8ec7f5368232d59f344e1067e1bad5e48dbcb7ae.tar.gz kennel.hatecomputers.club-8ec7f5368232d59f344e1067e1bad5e48dbcb7ae.zip | |
get "cats" up there
Diffstat (limited to 'static/src/engine/trailing_position.ts')
| -rw-r--r-- | static/src/engine/trailing_position.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/static/src/engine/trailing_position.ts b/static/src/engine/trailing_position.ts new file mode 100644 index 0000000..1ea22d3 --- /dev/null +++ b/static/src/engine/trailing_position.ts @@ -0,0 +1,33 @@ +import { ComponentType, TrailingPositionComponent } from "./component"; +import { Game } from "./game"; +import { System, SystemType } from "./system"; + +export class TrailingPositionSystem extends System { + constructor( + private readonly point_filter: ( + trail_point: { + x: number; + y: number; + time: number; + }[], + ) => { + x: number; + y: number; + time: number; + }[], + ) { + super(SystemType.TRAILING_POSITION); + } + + public update(_dt: number, game: Game) { + game.for_each_entity_with_component( + ComponentType.TRAILING_POSITION, + (entity) => { + const trailing_position = entity.components[ + ComponentType.TRAILING_POSITION + ] as TrailingPositionComponent; + trailing_position.trails = this.point_filter(trailing_position.trails); + }, + ); + } +} |
