File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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' ) ,
You can’t perform that action at this time.
0 commit comments