@@ -2,12 +2,6 @@ import { useCallback, useEffect, useRef, useState } from "react";
22import Phaser from "phaser" ;
33import { gameConfig } from "../game/config" ;
44import { ConnectDevice } from "./ConnectDevice" ;
5- import { GameScene } from "../game/scenes/GameScene" ;
6- import { MenuScene } from "../game/scenes/MenuScene" ;
7- import { GameOverScene } from "../game/scenes/GameOverScene" ;
8- import { NameEntryScene } from "../game/scenes/NameEntryScene" ;
9- import { HighScoresScene } from "../game/scenes/HighScoresScene" ;
10- import { ScenarioScene } from "../game/scenes/ScenarioScene" ;
115
126const Game = ( ) => {
137 const [ device , setDevice ] = useState < HIDDevice | null > ( null ) ;
@@ -25,19 +19,16 @@ const Game = () => {
2519 ...gameConfig ,
2620 } ;
2721
22+ const params = new URLSearchParams ( window . location . search ) ;
23+ const titleString = params . get ( "title" ) || "Switchy plushie when? ;)" ;
24+
2825 // Small delay to ensure DOM has fully rendered
2926 const initTimer = setTimeout ( ( ) => {
3027 gameRef . current = new Phaser . Game ( {
3128 ...config ,
32- scene : [
33- MenuScene ,
34- GameScene ,
35- GameOverScene ,
36- NameEntryScene ,
37- HighScoresScene ,
38- ScenarioScene ,
39- ] ,
4029 } ) ;
30+
31+ gameRef . current . scene . start ( "MenuScene" , { titleString } ) ;
4132 } , 50 ) ;
4233
4334 // Handle orientation change and resize events
@@ -89,18 +80,6 @@ const Game = () => {
8980 }
9081 } , [ ] ) ;
9182
92- useEffect ( ( ) => {
93- if ( device ) {
94- (
95- gameRef . current ?. scene . getScene ( "ScenarioScene" ) as GameScene
96- ) ?. setDevice ( device ) ;
97- } else {
98- (
99- gameRef . current ?. scene . getScene ( "ScenarioScene" ) as GameScene
100- ) ?. closeDevice ( ) ;
101- }
102- } , [ device , gameRef , gameRef . current ] ) ;
103-
10483 const onDeviceConnect = useCallback ( ( device : HIDDevice ) => {
10584 setDevice ( ( existing ) => {
10685 if ( existing ) {
0 commit comments