From dc63010b827f34f80fdc18a67952ee7a8759d4d9 Mon Sep 17 00:00:00 2001 From: Ali Shakiba Date: Wed, 20 Dec 2023 22:31:20 -0800 Subject: [PATCH] add Testbed.start() shortcut --- src/util/Testbed.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/util/Testbed.ts b/src/util/Testbed.ts index d134ccf1..347430da 100644 --- a/src/util/Testbed.ts +++ b/src/util/Testbed.ts @@ -20,10 +20,26 @@ export type ActiveKeys = { [key in KEY]?: boolean }; type TestbedMountOptions = {}; export abstract class Testbed { + /** + * Mount testbed. + * + * If you need to customize testbed before starting, use `Testbed.mount()` and `Testbed.start()` separately. + */ static mount(options?: TestbedMountOptions): Testbed { throw new Error('Not implemented'); } + /** + * Start simulation, and mount testbed if needed. + * + * If you need to customize testbed before starting, use `Testbed.mount().start()` separately. + */ + static start(world: World): Testbed { + const testbed = Testbed.mount(); + testbed.start(world); + return testbed; + } + /** World viewbox width. */ width: number = 80;