Skip to content

Commit

Permalink
Update engine.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonmorixe authored Oct 24, 2024
1 parent c733411 commit 2f8f27f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ export class AnimationEngine {

addSystem(system: System) {
this.systems.push(system);
}
}

update() {
private prepare() {
// Prepare all systems
this.systems.forEach((system) => {
if(system.prepare) {
system.prepare(this.entities);
}
});
}

private update() {
// let anyActive = false;

// Update all systems, but only for active entities
Expand Down Expand Up @@ -61,6 +70,7 @@ export class AnimationEngine {

// Start the loop on initialization
start() {
this.prepare();
this.loop();
}
}

0 comments on commit 2f8f27f

Please sign in to comment.