Skip to content

Commit a59bfcc

Browse files
Add timeskip key shortcuts
1 parent c720809 commit a59bfcc

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/lib/engine/ECSApp.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ export default class ECSApp {
4949
});
5050

5151
window.addEventListener('keydown', (e) => {
52-
if (e.key === ' ') {
53-
console.log('tick');
52+
if (e.key === 'ArrowRight') {
5453
this.simulation.tick();
54+
} else if (e.key === ' ') {
55+
for (let i = 0; i < 10; i++) {
56+
this.simulation.tick();
57+
}
5558
}
5659
});
5760

src/lib/engine/Simulation.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,15 @@ export default class Simulation {
2020
public readonly gravity = { x: 0, y: 100 } as const;
2121

2222
private physics: PhysicsWorld;
23-
private readonly world: World<Entity>;
24-
private readonly graphics: Application;
25-
private readonly rapier: typeof import('@dimforge/rapier2d');
23+
private readonly world: World<Entity> = new World();
2624
private readonly queries;
2725

2826
private constructor(
29-
rapier: typeof import('@dimforge/rapier2d'),
30-
graphics: Application,
27+
private readonly rapier: typeof import('@dimforge/rapier2d'),
28+
private readonly graphics: Application,
3129
scene: Scene,
3230
) {
3331
this.physics = new rapier.World(this.gravity);
34-
this.world = new World();
35-
this.graphics = graphics;
36-
this.rapier = rapier;
3732
this.queries = {
3833
renderable: this.world.with('graphics'),
3934
dynamic: this.world.with('rigidBody'),

0 commit comments

Comments
 (0)