@nayan-ui/games 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/games/arrows/Arrows.js +1 -1
- package/lib/module/games/arrows/ArrowsScene.js +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterScene.js +1 -1
- package/lib/module/games/bike-racing/BikeMeshes.js +1 -1
- package/lib/module/games/bike-racing/BikeRacing.js +1 -1
- package/lib/module/games/bike-racing/BikeRacingConstants.js +1 -1
- package/lib/module/games/bike-racing/BikeRacingScene.js +1 -1
- package/lib/module/games/block-blast/BlockBlast.js +1 -1
- package/lib/module/games/block-blast/BlockBlastScene.js +1 -1
- package/lib/module/games/block-breaker/BlockBreaker.js +1 -1
- package/lib/module/games/block-breaker/BlockBreakerScene.js +1 -1
- package/lib/module/games/bluk/Bluk.js +1 -1
- package/lib/module/games/bluk/BlukScene.js +1 -1
- package/lib/module/games/bubble-shooter/BubbleShooter.js +1 -1
- package/lib/module/games/bubble-shooter/BubbleShooterScene.js +1 -1
- package/lib/module/games/candy-crush/CandyCrush.js +1 -1
- package/lib/module/games/candy-crush/CandyCrushScene.js +1 -1
- package/lib/module/games/car-racing/CarMeshes.js +1 -1
- package/lib/module/games/car-racing/CarRacing.js +1 -1
- package/lib/module/games/car-racing/CarRacingScene.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRun.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRunBackdrop.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRunMeshes.js +1 -1
- package/lib/module/games/checkers/Checkers.js +1 -1
- package/lib/module/games/checkers/CheckersScene.js +1 -1
- package/lib/module/games/color-switch/ColorSwitch.js +1 -1
- package/lib/module/games/color-switch/ColorSwitchScene.js +1 -1
- package/lib/module/games/colors-sort/ColorsSort.js +1 -1
- package/lib/module/games/colors-sort/ColorsSortScene.js +1 -1
- package/lib/module/games/connect-em-all/ConnectEmAll.js +1 -1
- package/lib/module/games/connect-em-all/ConnectEmAllScene.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoad.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoadMeshes.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoadPerson.js +1 -1
- package/lib/module/games/dino-jump/DinoJump.js +1 -1
- package/lib/module/games/dino-jump/DinoJumpScene.js +1 -1
- package/lib/module/games/dots-and-boxes/DotsAndBoxes.js +1 -1
- package/lib/module/games/dots-and-boxes/DotsAndBoxesScene.js +1 -1
- package/lib/module/games/falling-sticks/FallingSticks.js +1 -1
- package/lib/module/games/falling-sticks/FallingSticksScene.js +1 -1
- package/lib/module/games/find-different-number/FindDifferentNumber.js +1 -1
- package/lib/module/games/find-different-number/FindDifferentNumberScene.js +1 -1
- package/lib/module/games/flappy-bird/FlappyBird.js +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdScene.js +1 -1
- package/lib/module/games/fruit-merger/FruitMerger.js +1 -1
- package/lib/module/games/fruit-merger/FruitMergerScene.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinja.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaScene.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaWorld.js +1 -1
- package/lib/module/games/game-2048/Game2048.js +1 -1
- package/lib/module/games/game-2048/Game2048Scene.js +1 -1
- package/lib/module/games/knife-hit/KnifeHit.js +1 -1
- package/lib/module/games/knife-hit/KnifeHitScene.js +1 -1
- package/lib/module/games/ludo-king/LudoKing.js +1 -1
- package/lib/module/games/ludo-king/LudoKingScene.js +1 -1
- package/lib/module/games/maze-runner/MazeRunner.js +1 -1
- package/lib/module/games/maze-runner/MazeRunnerScene.js +1 -1
- package/lib/module/games/memory-match/MemoryMatch.js +1 -1
- package/lib/module/games/memory-match/MemoryMatchScene.js +1 -1
- package/lib/module/games/mine-sweeper/MineSweeper.js +1 -1
- package/lib/module/games/mine-sweeper/MineSweeperScene.js +1 -1
- package/lib/module/games/mob-control/MobControl.js +1 -1
- package/lib/module/games/mob-control/MobControlGame.js +1 -1
- package/lib/module/games/mob-control/MobControlMeshes.js +1 -1
- package/lib/module/games/mob-control/MobControlRenderer.js +1 -1
- package/lib/module/games/mob-control/MobControlRules.js +1 -1
- package/lib/module/games/mob-control/MobControlScene.js +1 -1
- package/lib/module/games/nuts-and-bolts/NutsAndBolts.js +1 -1
- package/lib/module/games/nuts-and-bolts/NutsAndBoltsScene.js +1 -1
- package/lib/module/games/pac-man/PacMan.js +1 -1
- package/lib/module/games/pac-man/PacManGame.js +1 -1
- package/lib/module/games/pac-man/PacManScene.js +1 -1
- package/lib/module/games/paper-io/PaperIo.js +1 -1
- package/lib/module/games/paper-io/PaperIoMeshes.js +1 -1
- package/lib/module/games/paper-io/PaperIoScene.js +1 -1
- package/lib/module/games/penguin-run/PenguinMeshes.js +1 -1
- package/lib/module/games/penguin-run/PenguinRun.js +1 -1
- package/lib/module/games/penguin-run/PenguinRunScene.js +1 -1
- package/lib/module/games/perfect-circle/PerfectCircle.js +1 -1
- package/lib/module/games/perfect-circle/PerfectCircleScene.js +1 -1
- package/lib/module/games/pipe-connect/PipeConnect.js +1 -1
- package/lib/module/games/pipe-connect/PipeConnectScene.js +1 -1
- package/lib/module/games/play-with-tua/PlayWithTua.js +1 -1
- package/lib/module/games/popit-fidget/PopitFidget.js +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetScene.js +1 -1
- package/lib/module/games/reversi/Reversi.js +1 -1
- package/lib/module/games/reversi/ReversiScene.js +1 -1
- package/lib/module/games/search-grid/SearchGrid.js +1 -1
- package/lib/module/games/search-grid/SearchGridScene.js +1 -1
- package/lib/module/games/shared/BackdropCard.js +1 -1
- package/lib/module/games/shared/EngineBackdrop.js +1 -1
- package/lib/module/games/shared/EngineBlasts.js +1 -1
- package/lib/module/games/shared/EngineBlocks.js +1 -1
- package/lib/module/games/shared/EngineDice.js +1 -1
- package/lib/module/games/shared/EngineFruits.js +1 -1
- package/lib/module/games/shared/EngineGameLoader.js +1 -1
- package/lib/module/games/shared/EngineGameScreen.js +1 -1
- package/lib/module/games/shared/EngineGlyphs.js +1 -1
- package/lib/module/games/shared/EngineHud.js +1 -1
- package/lib/module/games/shared/EngineMeadow.js +1 -1
- package/lib/module/games/shared/EngineTouchSurface.js +1 -1
- package/lib/module/games/shared/GameActivity.js +1 -1
- package/lib/module/games/shared/GameLoading.js +1 -1
- package/lib/module/games/shared/GameLoadingTransition.js +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersScene.js +1 -1
- package/lib/module/games/snake-3d/Snake3D.js +1 -1
- package/lib/module/games/snake-3d/Snake3DScene.js +1 -1
- package/lib/module/games/snakes-and-ladders/SnakesAndLadders.js +1 -1
- package/lib/module/games/snakes-and-ladders/SnakesAndLaddersScene.js +1 -1
- package/lib/module/games/space-fighter/SpaceFighter.js +1 -1
- package/lib/module/games/space-fighter/SpaceFighterScene.js +1 -1
- package/lib/module/games/spider-solitaire/SpiderSolitaire.js +1 -1
- package/lib/module/games/spider-solitaire/SpiderSolitaireScene.js +1 -1
- package/lib/module/games/stack-tower/StackTower.js +1 -1
- package/lib/module/games/stack-tower/StackTowerScene.js +1 -1
- package/lib/module/games/sudoku/Sudoku.js +1 -1
- package/lib/module/games/sudoku/SudokuScene.js +1 -1
- package/lib/module/games/tangram/Tangram.js +1 -1
- package/lib/module/games/tangram/TangramScene.js +1 -1
- package/lib/module/games/tank-1990/Tank1990.js +1 -1
- package/lib/module/games/tank-1990/Tank1990Scene.js +1 -1
- package/lib/module/games/tic-tac-toe/TicTacToe.js +1 -1
- package/lib/module/games/tic-tac-toe/TicTacToeScene.js +1 -1
- package/lib/module/games/tile-home/TileHome.js +1 -1
- package/lib/module/games/tile-home/TileHomeScene.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHunt.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntConstants.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntModel.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntScene.js +1 -1
- package/lib/module/games/whack-a-mole/WhackAMole.js +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleScene.js +1 -1
- package/lib/module/helpers/GameSettingsModal.js +1 -1
- package/lib/module/helpers/GameTheme.js +1 -1
- package/package.json +1 -2
- package/src/assets/fonts/Inter-SemiBold.ttf +0 -0
- package/src/assets/models/explorer/explorer.glb +0 -0
- package/src/assets/models/explorer/params.json +0 -51
- package/src/assets/models/explorer/source.json +0 -222
- package/src/assets/models/play-with-tua/play-with-tua.glb +0 -0
- package/src/assets/models/play-with-tua/sources.json +0 -141
- package/src/assets/sfx/balloon_pop.wav +0 -0
- package/src/assets/sfx/blocked.wav +0 -0
- package/src/assets/sfx/boing.wav +0 -0
- package/src/assets/sfx/bonus.wav +0 -0
- package/src/assets/sfx/boom.wav +0 -0
- package/src/assets/sfx/bump.wav +0 -0
- package/src/assets/sfx/cannon.wav +0 -0
- package/src/assets/sfx/capture.wav +0 -0
- package/src/assets/sfx/card_flip.wav +0 -0
- package/src/assets/sfx/card_place.wav +0 -0
- package/src/assets/sfx/catch.wav +0 -0
- package/src/assets/sfx/chime.wav +0 -0
- package/src/assets/sfx/chomp.wav +0 -0
- package/src/assets/sfx/chomp_alt.wav +0 -0
- package/src/assets/sfx/clack.wav +0 -0
- package/src/assets/sfx/clang.wav +0 -0
- package/src/assets/sfx/clash.wav +0 -0
- package/src/assets/sfx/click.wav +0 -0
- package/src/assets/sfx/coin.wav +0 -0
- package/src/assets/sfx/combo.wav +0 -0
- package/src/assets/sfx/crash.wav +0 -0
- package/src/assets/sfx/crunch.wav +0 -0
- package/src/assets/sfx/dance.wav +0 -0
- package/src/assets/sfx/deselect.wav +0 -0
- package/src/assets/sfx/dice_roll.wav +0 -0
- package/src/assets/sfx/die.wav +0 -0
- package/src/assets/sfx/draw.wav +0 -0
- package/src/assets/sfx/drop.wav +0 -0
- package/src/assets/sfx/eat.wav +0 -0
- package/src/assets/sfx/engine.wav +0 -0
- package/src/assets/sfx/error.wav +0 -0
- package/src/assets/sfx/flag.wav +0 -0
- package/src/assets/sfx/flap.wav +0 -0
- package/src/assets/sfx/flip_disc.wav +0 -0
- package/src/assets/sfx/footstep_run.wav +0 -0
- package/src/assets/sfx/footstep_walk.wav +0 -0
- package/src/assets/sfx/game_over.wav +0 -0
- package/src/assets/sfx/gate.wav +0 -0
- package/src/assets/sfx/hit.wav +0 -0
- package/src/assets/sfx/hop.wav +0 -0
- package/src/assets/sfx/hurt.wav +0 -0
- package/src/assets/sfx/invalid.wav +0 -0
- package/src/assets/sfx/jump.wav +0 -0
- package/src/assets/sfx/ladder.wav +0 -0
- package/src/assets/sfx/land.wav +0 -0
- package/src/assets/sfx/laugh.wav +0 -0
- package/src/assets/sfx/lose.wav +0 -0
- package/src/assets/sfx/merge.wav +0 -0
- package/src/assets/sfx/miss.wav +0 -0
- package/src/assets/sfx/nitro.wav +0 -0
- package/src/assets/sfx/pew.wav +0 -0
- package/src/assets/sfx/place.wav +0 -0
- package/src/assets/sfx/pling.wav +0 -0
- package/src/assets/sfx/point.wav +0 -0
- package/src/assets/sfx/pop.wav +0 -0
- package/src/assets/sfx/pop_soft.wav +0 -0
- package/src/assets/sfx/power_up.wav +0 -0
- package/src/assets/sfx/reveal.wav +0 -0
- package/src/assets/sfx/robot.wav +0 -0
- package/src/assets/sfx/rotate.wav +0 -0
- package/src/assets/sfx/run_steps.wav +0 -0
- package/src/assets/sfx/select.wav +0 -0
- package/src/assets/sfx/shuffle.wav +0 -0
- package/src/assets/sfx/six.wav +0 -0
- package/src/assets/sfx/slice.wav +0 -0
- package/src/assets/sfx/slide.wav +0 -0
- package/src/assets/sfx/snake.wav +0 -0
- package/src/assets/sfx/snap.wav +0 -0
- package/src/assets/sfx/splash.wav +0 -0
- package/src/assets/sfx/star.wav +0 -0
- package/src/assets/sfx/start.wav +0 -0
- package/src/assets/sfx/swoosh.wav +0 -0
- package/src/assets/sfx/tap.wav +0 -0
- package/src/assets/sfx/thud.wav +0 -0
- package/src/assets/sfx/thunk.wav +0 -0
- package/src/assets/sfx/tick.wav +0 -0
- package/src/assets/sfx/time_up.wav +0 -0
- package/src/assets/sfx/tock.wav +0 -0
- package/src/assets/sfx/walk_steps.wav +0 -0
- package/src/assets/sfx/warning.wav +0 -0
- package/src/assets/sfx/whack.wav +0 -0
- package/src/assets/sfx/whoosh.wav +0 -0
- package/src/assets/sfx/win.wav +0 -0
- package/src/assets/sfx/zap.wav +0 -0
- package/src/assets/textures/ad_bolt.png +0 -0
- package/src/assets/textures/ad_bubbles.png +0 -0
- package/src/assets/textures/ad_chevrons.png +0 -0
- package/src/assets/textures/asphalt.png +0 -0
- package/src/assets/textures/bark.jpg +0 -0
- package/src/assets/textures/explorer-atlas.png +0 -0
- package/src/assets/textures/facade.png +0 -0
- package/src/assets/textures/grass.png +0 -0
- package/src/assets/textures/leaves.png +0 -0
- package/src/assets/textures/limestone.jpg +0 -0
- package/src/assets/textures/meadow.jpg +0 -0
- package/src/assets/textures/nature-sources.json +0 -87
- package/src/assets/textures/pine.png +0 -0
- package/src/assets/textures/river.jpg +0 -0
- package/src/assets/textures/soft_glow.png +0 -0
- package/src/games/arrows/Arrows.tsx +0 -69
- package/src/games/arrows/ArrowsConstants.ts +0 -107
- package/src/games/arrows/ArrowsGame.ts +0 -735
- package/src/games/arrows/ArrowsScene.ts +0 -395
- package/src/games/balloon-blaster/BalloonBlaster.tsx +0 -75
- package/src/games/balloon-blaster/BalloonBlasterConstants.ts +0 -79
- package/src/games/balloon-blaster/BalloonBlasterGame.ts +0 -287
- package/src/games/balloon-blaster/BalloonBlasterPhysics.ts +0 -95
- package/src/games/balloon-blaster/BalloonBlasterScene.ts +0 -225
- package/src/games/bike-racing/BikeMeshes.ts +0 -273
- package/src/games/bike-racing/BikeRacing.tsx +0 -211
- package/src/games/bike-racing/BikeRacingConstants.ts +0 -103
- package/src/games/bike-racing/BikeRacingGame.ts +0 -557
- package/src/games/bike-racing/BikeRacingScene.ts +0 -119
- package/src/games/block-blast/BlockBlast.tsx +0 -73
- package/src/games/block-blast/BlockBlastConstants.ts +0 -179
- package/src/games/block-blast/BlockBlastGame.ts +0 -471
- package/src/games/block-blast/BlockBlastScene.ts +0 -156
- package/src/games/block-breaker/BlockBreaker.tsx +0 -79
- package/src/games/block-breaker/BlockBreakerConstants.ts +0 -139
- package/src/games/block-breaker/BlockBreakerGame.ts +0 -459
- package/src/games/block-breaker/BlockBreakerScene.ts +0 -257
- package/src/games/bluk/Bluk.tsx +0 -82
- package/src/games/bluk/BlukConstants.ts +0 -121
- package/src/games/bluk/BlukGame.ts +0 -323
- package/src/games/bluk/BlukRules.ts +0 -154
- package/src/games/bluk/BlukScene.ts +0 -514
- package/src/games/bubble-shooter/BubbleShooter.tsx +0 -76
- package/src/games/bubble-shooter/BubbleShooterConstants.ts +0 -103
- package/src/games/bubble-shooter/BubbleShooterGame.ts +0 -459
- package/src/games/bubble-shooter/BubbleShooterScene.ts +0 -158
- package/src/games/candy-crush/CandyCrush.tsx +0 -77
- package/src/games/candy-crush/CandyCrushConstants.ts +0 -94
- package/src/games/candy-crush/CandyCrushGame.ts +0 -477
- package/src/games/candy-crush/CandyCrushScene.ts +0 -209
- package/src/games/car-racing/CarMeshes.ts +0 -440
- package/src/games/car-racing/CarRacing.tsx +0 -211
- package/src/games/car-racing/CarRacingConstants.ts +0 -167
- package/src/games/car-racing/CarRacingFacade.ts +0 -40
- package/src/games/car-racing/CarRacingGame.ts +0 -539
- package/src/games/car-racing/CarRacingScene.ts +0 -1026
- package/src/games/car-racing/CarRacingScenery.ts +0 -265
- package/src/games/chameleon-run/ChameleonRun.tsx +0 -96
- package/src/games/chameleon-run/ChameleonRunBackdrop.ts +0 -186
- package/src/games/chameleon-run/ChameleonRunConstants.ts +0 -47
- package/src/games/chameleon-run/ChameleonRunGame.ts +0 -309
- package/src/games/chameleon-run/ChameleonRunMeshes.ts +0 -305
- package/src/games/chameleon-run/ChameleonRunRules.ts +0 -252
- package/src/games/chameleon-run/ChameleonRunScene.ts +0 -310
- package/src/games/checkers/Checkers.tsx +0 -83
- package/src/games/checkers/CheckersAI.ts +0 -255
- package/src/games/checkers/CheckersConstants.ts +0 -68
- package/src/games/checkers/CheckersGame.ts +0 -322
- package/src/games/checkers/CheckersRules.ts +0 -167
- package/src/games/checkers/CheckersScene.ts +0 -308
- package/src/games/color-switch/ColorSwitch.tsx +0 -75
- package/src/games/color-switch/ColorSwitchConstants.ts +0 -61
- package/src/games/color-switch/ColorSwitchGame.ts +0 -329
- package/src/games/color-switch/ColorSwitchScene.ts +0 -220
- package/src/games/colors-sort/ColorsSort.tsx +0 -82
- package/src/games/colors-sort/ColorsSortConstants.ts +0 -119
- package/src/games/colors-sort/ColorsSortGame.ts +0 -246
- package/src/games/colors-sort/ColorsSortScene.ts +0 -315
- package/src/games/connect-em-all/ConnectEmAll.tsx +0 -70
- package/src/games/connect-em-all/ConnectEmAllConstants.ts +0 -77
- package/src/games/connect-em-all/ConnectEmAllGame.ts +0 -401
- package/src/games/connect-em-all/ConnectEmAllScene.ts +0 -235
- package/src/games/crossy-road/CrossyRoad.tsx +0 -74
- package/src/games/crossy-road/CrossyRoadCamera.ts +0 -59
- package/src/games/crossy-road/CrossyRoadConstants.ts +0 -132
- package/src/games/crossy-road/CrossyRoadGame.ts +0 -293
- package/src/games/crossy-road/CrossyRoadMeshes.ts +0 -195
- package/src/games/crossy-road/CrossyRoadPerson.ts +0 -198
- package/src/games/crossy-road/CrossyRoadRules.ts +0 -99
- package/src/games/crossy-road/CrossyRoadScene.ts +0 -355
- package/src/games/dino-jump/DinoJump.tsx +0 -77
- package/src/games/dino-jump/DinoJumpConstants.ts +0 -80
- package/src/games/dino-jump/DinoJumpGame.ts +0 -344
- package/src/games/dino-jump/DinoJumpScene.ts +0 -686
- package/src/games/dots-and-boxes/DotsAndBoxes.tsx +0 -83
- package/src/games/dots-and-boxes/DotsAndBoxesConstants.ts +0 -77
- package/src/games/dots-and-boxes/DotsAndBoxesGame.ts +0 -271
- package/src/games/dots-and-boxes/DotsAndBoxesScene.ts +0 -249
- package/src/games/falling-sticks/FallingSticks.tsx +0 -72
- package/src/games/falling-sticks/FallingSticksConstants.ts +0 -62
- package/src/games/falling-sticks/FallingSticksGame.ts +0 -220
- package/src/games/falling-sticks/FallingSticksRules.ts +0 -145
- package/src/games/falling-sticks/FallingSticksScene.ts +0 -245
- package/src/games/find-different-number/FindDifferentNumber.tsx +0 -74
- package/src/games/find-different-number/FindDifferentNumberConstants.ts +0 -74
- package/src/games/find-different-number/FindDifferentNumberGame.ts +0 -174
- package/src/games/find-different-number/FindDifferentNumberRules.ts +0 -43
- package/src/games/find-different-number/FindDifferentNumberScene.ts +0 -193
- package/src/games/flappy-bird/FlappyBird.tsx +0 -73
- package/src/games/flappy-bird/FlappyBirdConstants.ts +0 -95
- package/src/games/flappy-bird/FlappyBirdGame.ts +0 -375
- package/src/games/flappy-bird/FlappyBirdScene.ts +0 -630
- package/src/games/fruit-merger/FruitMerger.tsx +0 -73
- package/src/games/fruit-merger/FruitMergerConstants.ts +0 -102
- package/src/games/fruit-merger/FruitMergerGame.ts +0 -285
- package/src/games/fruit-merger/FruitMergerRules.ts +0 -286
- package/src/games/fruit-merger/FruitMergerScene.ts +0 -498
- package/src/games/fruit-ninja/FruitNinja.tsx +0 -129
- package/src/games/fruit-ninja/FruitNinjaConstants.ts +0 -107
- package/src/games/fruit-ninja/FruitNinjaGame.ts +0 -391
- package/src/games/fruit-ninja/FruitNinjaScene.ts +0 -319
- package/src/games/fruit-ninja/FruitNinjaWorld.ts +0 -17
- package/src/games/game-2048/Game2048.tsx +0 -84
- package/src/games/game-2048/Game2048Constants.ts +0 -68
- package/src/games/game-2048/Game2048Game.ts +0 -181
- package/src/games/game-2048/Game2048Rules.ts +0 -101
- package/src/games/game-2048/Game2048Scene.ts +0 -206
- package/src/games/knife-hit/KnifeHit.tsx +0 -78
- package/src/games/knife-hit/KnifeHitConstants.ts +0 -89
- package/src/games/knife-hit/KnifeHitGame.ts +0 -264
- package/src/games/knife-hit/KnifeHitScene.ts +0 -360
- package/src/games/ludo-king/LudoKing.tsx +0 -86
- package/src/games/ludo-king/LudoKingConstants.ts +0 -212
- package/src/games/ludo-king/LudoKingGame.ts +0 -326
- package/src/games/ludo-king/LudoKingRules.ts +0 -143
- package/src/games/ludo-king/LudoKingScene.ts +0 -397
- package/src/games/maze-runner/MazeRunner.tsx +0 -88
- package/src/games/maze-runner/MazeRunnerConstants.ts +0 -65
- package/src/games/maze-runner/MazeRunnerGame.ts +0 -176
- package/src/games/maze-runner/MazeRunnerRules.ts +0 -161
- package/src/games/maze-runner/MazeRunnerScene.ts +0 -245
- package/src/games/memory-match/MemoryMatch.tsx +0 -77
- package/src/games/memory-match/MemoryMatchConstants.ts +0 -105
- package/src/games/memory-match/MemoryMatchGame.ts +0 -222
- package/src/games/memory-match/MemoryMatchRules.ts +0 -38
- package/src/games/memory-match/MemoryMatchScene.ts +0 -268
- package/src/games/mine-sweeper/MineSweeper.tsx +0 -77
- package/src/games/mine-sweeper/MineSweeperConstants.ts +0 -94
- package/src/games/mine-sweeper/MineSweeperGame.ts +0 -234
- package/src/games/mine-sweeper/MineSweeperRules.ts +0 -67
- package/src/games/mine-sweeper/MineSweeperScene.ts +0 -262
- package/src/games/mob-control/MobControl.tsx +0 -73
- package/src/games/mob-control/MobControlConstants.ts +0 -106
- package/src/games/mob-control/MobControlGame.ts +0 -176
- package/src/games/mob-control/MobControlMeshes.ts +0 -85
- package/src/games/mob-control/MobControlRenderer.ts +0 -108
- package/src/games/mob-control/MobControlRules.ts +0 -522
- package/src/games/mob-control/MobControlScene.ts +0 -399
- package/src/games/number-search/NumberSearch.tsx +0 -18
- package/src/games/number-search/NumberSearchNumbers.ts +0 -623
- package/src/games/nuts-and-bolts/NutsAndBolts.tsx +0 -85
- package/src/games/nuts-and-bolts/NutsAndBoltsConstants.ts +0 -75
- package/src/games/nuts-and-bolts/NutsAndBoltsGame.ts +0 -298
- package/src/games/nuts-and-bolts/NutsAndBoltsRules.ts +0 -474
- package/src/games/nuts-and-bolts/NutsAndBoltsScene.ts +0 -498
- package/src/games/pac-man/PacMan.tsx +0 -86
- package/src/games/pac-man/PacManConstants.ts +0 -169
- package/src/games/pac-man/PacManGame.ts +0 -406
- package/src/games/pac-man/PacManRules.ts +0 -255
- package/src/games/pac-man/PacManScene.ts +0 -387
- package/src/games/paper-io/PaperIo.tsx +0 -91
- package/src/games/paper-io/PaperIoConstants.ts +0 -86
- package/src/games/paper-io/PaperIoGame.ts +0 -193
- package/src/games/paper-io/PaperIoMeshes.ts +0 -233
- package/src/games/paper-io/PaperIoRules.ts +0 -315
- package/src/games/paper-io/PaperIoScene.ts +0 -310
- package/src/games/penguin-run/PenguinMeshes.ts +0 -269
- package/src/games/penguin-run/PenguinModel.ts +0 -712
- package/src/games/penguin-run/PenguinRun.tsx +0 -77
- package/src/games/penguin-run/PenguinRunConstants.ts +0 -69
- package/src/games/penguin-run/PenguinRunGame.ts +0 -406
- package/src/games/penguin-run/PenguinRunScene.ts +0 -949
- package/src/games/perfect-circle/PerfectCircle.tsx +0 -74
- package/src/games/perfect-circle/PerfectCircleConstants.ts +0 -52
- package/src/games/perfect-circle/PerfectCircleGame.ts +0 -153
- package/src/games/perfect-circle/PerfectCircleRules.ts +0 -111
- package/src/games/perfect-circle/PerfectCircleScene.ts +0 -176
- package/src/games/pipe-connect/PipeConnect.tsx +0 -69
- package/src/games/pipe-connect/PipeConnectConstants.ts +0 -101
- package/src/games/pipe-connect/PipeConnectGame.ts +0 -179
- package/src/games/pipe-connect/PipeConnectRules.ts +0 -326
- package/src/games/pipe-connect/PipeConnectScene.ts +0 -271
- package/src/games/play-with-tua/PlayWithTua.tsx +0 -123
- package/src/games/play-with-tua/PlayWithTuaConstants.ts +0 -70
- package/src/games/play-with-tua/PlayWithTuaGame.ts +0 -167
- package/src/games/play-with-tua/PlayWithTuaModel.ts +0 -42
- package/src/games/play-with-tua/PlayWithTuaScene.ts +0 -36
- package/src/games/popit-fidget/PopitFidget.tsx +0 -72
- package/src/games/popit-fidget/PopitFidgetConstants.ts +0 -71
- package/src/games/popit-fidget/PopitFidgetGame.ts +0 -148
- package/src/games/popit-fidget/PopitFidgetScene.ts +0 -242
- package/src/games/reversi/Reversi.tsx +0 -94
- package/src/games/reversi/ReversiConstants.ts +0 -67
- package/src/games/reversi/ReversiGame.ts +0 -266
- package/src/games/reversi/ReversiRules.ts +0 -176
- package/src/games/reversi/ReversiScene.ts +0 -240
- package/src/games/search-grid/SearchGrid.tsx +0 -92
- package/src/games/search-grid/SearchGridConstants.ts +0 -178
- package/src/games/search-grid/SearchGridGame.ts +0 -209
- package/src/games/search-grid/SearchGridScene.ts +0 -301
- package/src/games/shared/BackdropCard.tsx +0 -54
- package/src/games/shared/EngineBackdrop.ts +0 -300
- package/src/games/shared/EngineBlasts.ts +0 -136
- package/src/games/shared/EngineBlocks.ts +0 -91
- package/src/games/shared/EngineControlText.ts +0 -17
- package/src/games/shared/EngineDice.ts +0 -250
- package/src/games/shared/EngineFootprint.ts +0 -35
- package/src/games/shared/EngineFruits.ts +0 -1435
- package/src/games/shared/EngineGameLoader.tsx +0 -88
- package/src/games/shared/EngineGameScreen.tsx +0 -325
- package/src/games/shared/EngineGameWidth.ts +0 -3
- package/src/games/shared/EngineGameWidth.web.ts +0 -3
- package/src/games/shared/EngineGlyphs.ts +0 -178
- package/src/games/shared/EngineHud.ts +0 -815
- package/src/games/shared/EngineLoading.ts +0 -477
- package/src/games/shared/EngineMeadow.ts +0 -725
- package/src/games/shared/EngineMeshCache.ts +0 -15
- package/src/games/shared/EngineMeshes.ts +0 -10
- package/src/games/shared/EngineRacingChase.ts +0 -21
- package/src/games/shared/EngineRacingHandling.ts +0 -48
- package/src/games/shared/EngineReadyContext.ts +0 -4
- package/src/games/shared/EngineTilt.ts +0 -44
- package/src/games/shared/EngineTouchSurface.tsx +0 -103
- package/src/games/shared/EngineUtils.ts +0 -52
- package/src/games/shared/GameActivity.ts +0 -13
- package/src/games/shared/GameLoading.tsx +0 -202
- package/src/games/shared/GameLoadingTransition.tsx +0 -61
- package/src/games/shared/ProceduralCacheVersion.ts +0 -2
- package/src/games/shared/useEngineGame.ts +0 -240
- package/src/games/shared/useGameResource.ts +0 -21
- package/src/games/shared/useLiveState.ts +0 -58
- package/src/games/sliding-numbers/SlidingNumbers.tsx +0 -71
- package/src/games/sliding-numbers/SlidingNumbersConstants.ts +0 -65
- package/src/games/sliding-numbers/SlidingNumbersGame.ts +0 -192
- package/src/games/sliding-numbers/SlidingNumbersRules.ts +0 -79
- package/src/games/sliding-numbers/SlidingNumbersScene.ts +0 -193
- package/src/games/snake-3d/Snake3D.tsx +0 -76
- package/src/games/snake-3d/Snake3DConstants.ts +0 -61
- package/src/games/snake-3d/Snake3DGame.ts +0 -192
- package/src/games/snake-3d/Snake3DMotion.ts +0 -22
- package/src/games/snake-3d/Snake3DRules.ts +0 -116
- package/src/games/snake-3d/Snake3DScene.ts +0 -322
- package/src/games/snakes-and-ladders/SnakesAndLadders.tsx +0 -87
- package/src/games/snakes-and-ladders/SnakesAndLaddersConstants.ts +0 -136
- package/src/games/snakes-and-ladders/SnakesAndLaddersGame.ts +0 -310
- package/src/games/snakes-and-ladders/SnakesAndLaddersScene.ts +0 -515
- package/src/games/space-fighter/SpaceFighter.tsx +0 -74
- package/src/games/space-fighter/SpaceFighterConstants.ts +0 -86
- package/src/games/space-fighter/SpaceFighterGame.ts +0 -292
- package/src/games/space-fighter/SpaceFighterScene.ts +0 -550
- package/src/games/spider-solitaire/SpiderSolitaire.tsx +0 -80
- package/src/games/spider-solitaire/SpiderSolitaireConstants.ts +0 -107
- package/src/games/spider-solitaire/SpiderSolitaireGame.ts +0 -387
- package/src/games/spider-solitaire/SpiderSolitaireRules.ts +0 -123
- package/src/games/spider-solitaire/SpiderSolitaireScene.ts +0 -352
- package/src/games/stack-tower/StackTower.tsx +0 -76
- package/src/games/stack-tower/StackTowerConstants.ts +0 -74
- package/src/games/stack-tower/StackTowerGame.ts +0 -236
- package/src/games/stack-tower/StackTowerScene.ts +0 -186
- package/src/games/sudoku/Sudoku.tsx +0 -73
- package/src/games/sudoku/SudokuConstants.ts +0 -127
- package/src/games/sudoku/SudokuGame.ts +0 -250
- package/src/games/sudoku/SudokuRules.ts +0 -125
- package/src/games/sudoku/SudokuScene.ts +0 -304
- package/src/games/tangram/Tangram.tsx +0 -79
- package/src/games/tangram/TangramConstants.ts +0 -64
- package/src/games/tangram/TangramGame.ts +0 -356
- package/src/games/tangram/TangramRules.ts +0 -409
- package/src/games/tangram/TangramScene.ts +0 -203
- package/src/games/tank-1990/Tank1990.tsx +0 -78
- package/src/games/tank-1990/Tank1990Constants.ts +0 -81
- package/src/games/tank-1990/Tank1990Game.ts +0 -331
- package/src/games/tank-1990/Tank1990Rules.ts +0 -390
- package/src/games/tank-1990/Tank1990Scene.ts +0 -434
- package/src/games/tic-tac-toe/TicTacToe.tsx +0 -98
- package/src/games/tic-tac-toe/TicTacToeConstants.ts +0 -69
- package/src/games/tic-tac-toe/TicTacToeGame.ts +0 -200
- package/src/games/tic-tac-toe/TicTacToeRules.ts +0 -103
- package/src/games/tic-tac-toe/TicTacToeScene.ts +0 -245
- package/src/games/tile-home/TileHome.tsx +0 -92
- package/src/games/tile-home/TileHomeConstants.ts +0 -139
- package/src/games/tile-home/TileHomeGame.ts +0 -435
- package/src/games/tile-home/TileHomeScene.ts +0 -154
- package/src/games/treasure-hunt/TreasureHunt.tsx +0 -206
- package/src/games/treasure-hunt/TreasureHuntConstants.ts +0 -266
- package/src/games/treasure-hunt/TreasureHuntControls.ts +0 -280
- package/src/games/treasure-hunt/TreasureHuntGame.ts +0 -402
- package/src/games/treasure-hunt/TreasureHuntMeshes.ts +0 -422
- package/src/games/treasure-hunt/TreasureHuntModel.ts +0 -506
- package/src/games/treasure-hunt/TreasureHuntRules.ts +0 -1210
- package/src/games/treasure-hunt/TreasureHuntScene.ts +0 -586
- package/src/games/whack-a-mole/WhackAMole.tsx +0 -79
- package/src/games/whack-a-mole/WhackAMoleConstants.ts +0 -94
- package/src/games/whack-a-mole/WhackAMoleGame.ts +0 -233
- package/src/games/whack-a-mole/WhackAMoleScene.ts +0 -349
- package/src/games/word-search/WordSearch.tsx +0 -18
- package/src/games/word-search/WordSearchWords.ts +0 -1642
- package/src/helpers/GamePatternData.ts +0 -120
- package/src/helpers/GameSettingsModal.tsx +0 -384
- package/src/helpers/GameTheme.tsx +0 -37
- package/src/helpers/IconPaths.ts +0 -6
- package/src/helpers/index.ts +0 -2
- package/src/index.tsx +0 -60
- package/src/services/GameAssetLoader.ts +0 -111
- package/src/services/GameAssets.ts +0 -149
- package/src/services/GameLoaders.ts +0 -93
- package/src/services/GamesConstants.ts +0 -193
- package/src/services/GamesMetadata.ts +0 -711
- package/src/services/GamesService.ts +0 -116
- package/src/services/HapticsService.ts +0 -48
- package/src/services/ScoringService.ts +0 -19
- package/src/services/SfxSources.ts +0 -81
- package/src/services/SoundsService.ts +0 -582
- package/src/services/ThemeService.ts +0 -281
- package/src/services/UtilsService.ts +0 -134
- package/src/services/index.ts +0 -6
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Maze Runner's rules, colors, timings and layout. The maze size, clock and scoring match the original
|
|
2
|
-
// version (games/maze-runner), so scores carry over.
|
|
3
|
-
import { getScoreBoardTop } from '../shared/EngineHud';
|
|
4
|
-
import type { TiltView } from '../shared/EngineTilt';
|
|
5
|
-
import { frontLight, gameWidthFor } from '../shared/EngineUtils';
|
|
6
|
-
|
|
7
|
-
// ── Rules ─────────────────────────────────────────────────────────────
|
|
8
|
-
|
|
9
|
-
export const GRID = 14; // 14 x 14 cells
|
|
10
|
-
export const GAME_DURATION = 120; // seconds
|
|
11
|
-
/** A win scores by its time against the full three minutes. */
|
|
12
|
-
export const BASE_SCORE = 100;
|
|
13
|
-
export const GAME_OVER_DELAY = 0.5; // the game-over card shows this long after the end, as the original game
|
|
14
|
-
|
|
15
|
-
// ── Colors ────────────────────────────────────────────────────────────
|
|
16
|
-
|
|
17
|
-
export const COLORS = {
|
|
18
|
-
WALLS: ['#7A4A24', '#8B4513', '#A0522D', '#9A5B2E'],
|
|
19
|
-
WALL_TOP: '#D2A06A',
|
|
20
|
-
BALL: '#4ECDC4',
|
|
21
|
-
BALL_BAND: '#FFFFFF',
|
|
22
|
-
BALL_DOT: '#2C8C86',
|
|
23
|
-
START: '#4CAF50',
|
|
24
|
-
START_INNER: '#81C784',
|
|
25
|
-
GOAL: '#FF5722',
|
|
26
|
-
GOAL_INNER: '#FF8A65'
|
|
27
|
-
} as const;
|
|
28
|
-
|
|
29
|
-
// ── The scene ─────────────────────────────────────────────────────────
|
|
30
|
-
|
|
31
|
-
/** Directly overhead so raised walls do not obscure the maze's passages. */
|
|
32
|
-
export const TILT = 0;
|
|
33
|
-
/** Overhead light, with cast shadows disabled by frontLight. */
|
|
34
|
-
export const LIGHT = frontLight([0, 0, 1], 0.45);
|
|
35
|
-
/** A wall's thickness and height, and the ball's size, of a cell. */
|
|
36
|
-
export const WALL_THICKNESS = 0.14;
|
|
37
|
-
export const WALL_HEIGHT = 0.42;
|
|
38
|
-
export const BALL_SIZE = 0.56;
|
|
39
|
-
|
|
40
|
-
// ── Layout (view points) ──────────────────────────────────────────────
|
|
41
|
-
|
|
42
|
-
const SCOREBOARD_HEIGHT = 82;
|
|
43
|
-
const CONTROLS_HEIGHT = 120;
|
|
44
|
-
/** The board's rim round the maze, in points: it counts toward the max width. */
|
|
45
|
-
export const BORDER = 6;
|
|
46
|
-
const MIN_SIZE = 240;
|
|
47
|
-
const MAX_SIZE = 600; // as the original maze (the game width, at most 500, now always binds first)
|
|
48
|
-
|
|
49
|
-
export type Layout = TiltView & { n: number; cell: number; size: number };
|
|
50
|
-
|
|
51
|
-
/** The maze square as big as the game area allows, viewed directly overhead. */
|
|
52
|
-
export function getLayout(width: number, height: number, offset: number): Layout {
|
|
53
|
-
const top = getScoreBoardTop(offset) + SCOREBOARD_HEIGHT;
|
|
54
|
-
const room = Math.max(MIN_SIZE, height - top - CONTROLS_HEIGHT);
|
|
55
|
-
// The tilted square takes size * cos(tilt) of the view's height, plus its walls' height above the far edge
|
|
56
|
-
const fromHeight = room / (Math.cos(TILT) + (WALL_HEIGHT / GRID) * Math.sin(TILT));
|
|
57
|
-
const size =
|
|
58
|
-
Math.floor(Math.max(MIN_SIZE, Math.min(MAX_SIZE, (gameWidthFor(width) - BORDER * 2) / (1 + WALL_THICKNESS / GRID), fromHeight)) / GRID) * GRID;
|
|
59
|
-
return { width, height, tilt: TILT, centerY: top + room / 2, n: GRID, cell: size / GRID, size };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** A cell's centre (or any point in cells: 0.5 is the middle of the first column / row), in world units. */
|
|
63
|
-
export function cellPoint(l: Layout, cx: number, cy: number): [number, number] {
|
|
64
|
-
return [cx * l.cell - l.size / 2, l.size / 2 - cy * l.cell];
|
|
65
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
// Maze Runner's play, with no React: build a game with `createGame`, give it a layout, `start` it and
|
|
2
|
-
// `tick` it every frame. Swipe anywhere to roll the ball: it rolls down a corridor until a wall, turns
|
|
3
|
-
// at the next junction open the way you last swiped, and reverses at once on a swipe back. Reach the
|
|
4
|
-
// exit, bottom right, inside three minutes to win (the quicker, the higher the score).
|
|
5
|
-
//
|
|
6
|
-
// The maze and the roll are the original version's (MazeRunnerRules.ts), rolled on the same display frames.
|
|
7
|
-
import { type Camera, type DragEvent, World } from '@nayan-ui/engine';
|
|
8
|
-
import { calculateTimeBasedScore } from '../../services/ScoringService';
|
|
9
|
-
import type { GameTheme } from '../../services/ThemeService';
|
|
10
|
-
import { aimTilted } from '../shared/EngineTilt';
|
|
11
|
-
import { BASE_SCORE, GAME_DURATION, GAME_OVER_DELAY, GRID, type Layout } from './MazeRunnerConstants';
|
|
12
|
-
import { generateMaze, homeRoll, roll, rollAt, swipe } from './MazeRunnerRules';
|
|
13
|
-
import { buildScene, bump, celebrate, placeBall, removeScene, resetBall, type Scene, setMaze, setSceneTheme, timeUp } from './MazeRunnerScene';
|
|
14
|
-
|
|
15
|
-
/** ready: the maze waits; playing: rolling; over: won or lost (the game-over card comes up a beat later, through `onCard`). */
|
|
16
|
-
export type Phase = 'ready' | 'playing' | 'over';
|
|
17
|
-
/** turn: a swipe taken; bump: rolled into a wall; win / lose: how it ended. */
|
|
18
|
-
export type GameEvent = 'turn' | 'bump' | 'win' | 'lose';
|
|
19
|
-
|
|
20
|
-
const WORLD_CAPACITY = 300; // about 60 walls, the board, pads, ball, and the bursts
|
|
21
|
-
|
|
22
|
-
export function createGame(theme: GameTheme) {
|
|
23
|
-
const world = new World(WORLD_CAPACITY);
|
|
24
|
-
const camera: Camera = { eye: [0, 0, 240], target: [0, 0, 0], fov: 1, ortho: 1 };
|
|
25
|
-
const g = {
|
|
26
|
-
world,
|
|
27
|
-
camera,
|
|
28
|
-
theme,
|
|
29
|
-
layout: null as Layout | null,
|
|
30
|
-
scene: null as Scene | null,
|
|
31
|
-
phase: 'ready' as Phase,
|
|
32
|
-
open: generateMaze(GRID),
|
|
33
|
-
ball: homeRoll(),
|
|
34
|
-
/** Where the ball was last drawn (in cells), so its turn follows how far it rolled. */
|
|
35
|
-
drawn: [0.5, 0.5] as [number, number],
|
|
36
|
-
/** Running: the clock's ticking and swipes roll the ball (false from the moment it ends). */
|
|
37
|
-
running: false,
|
|
38
|
-
/** Seconds played and the score: the clock and score live in the engine (Rust), advanced by world.update. */
|
|
39
|
-
get elapsed() {
|
|
40
|
-
return GAME_DURATION - world.scoreboard.shownSeconds;
|
|
41
|
-
},
|
|
42
|
-
get score() {
|
|
43
|
-
return world.scoreboard.score;
|
|
44
|
-
},
|
|
45
|
-
won: false,
|
|
46
|
-
// UI hooks, set by the screen.
|
|
47
|
-
onPhase: (_p: Phase) => {},
|
|
48
|
-
onCard: () => {},
|
|
49
|
-
onTime: (_remaining: number) => {},
|
|
50
|
-
onEvent: (_e: GameEvent) => {}
|
|
51
|
-
};
|
|
52
|
-
world.scoreboard.reset(0, GAME_DURATION);
|
|
53
|
-
world.scoreboard.handlers = {
|
|
54
|
-
onSecond: (t) => g.onTime(t),
|
|
55
|
-
onTimeUp: () => g.running && end(g, false)
|
|
56
|
-
};
|
|
57
|
-
return g;
|
|
58
|
-
}
|
|
59
|
-
export type Game = ReturnType<typeof createGame>;
|
|
60
|
-
|
|
61
|
-
// ── Scene ─────────────────────────────────────────────────────────────
|
|
62
|
-
|
|
63
|
-
/** Lays the maze out for the view (first layout, header height, rotation): rebuilt where things stand. */
|
|
64
|
-
export function setLayout(g: Game, l: Layout) {
|
|
65
|
-
if (g.scene) removeScene(g.world, g.scene);
|
|
66
|
-
g.layout = l;
|
|
67
|
-
aimTilted(g.camera, l);
|
|
68
|
-
g.scene = buildScene(g.world, l, g.theme, g.open);
|
|
69
|
-
const [x, y] = rollAt(g.ball);
|
|
70
|
-
placeBall(g.world, l, g.scene, x, y, x, y);
|
|
71
|
-
g.drawn = [x, y];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function setTheme(g: Game, theme: GameTheme) {
|
|
75
|
-
g.theme = theme;
|
|
76
|
-
if (g.layout && g.scene) setSceneTheme(g.world, g.layout, g.scene, theme);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function drawBall(g: Game) {
|
|
80
|
-
const { layout: l, scene: s } = g;
|
|
81
|
-
if (!l || !s) return;
|
|
82
|
-
const [x, y] = rollAt(g.ball);
|
|
83
|
-
placeBall(g.world, l, s, x, y, g.drawn[0], g.drawn[1]);
|
|
84
|
-
g.drawn = [x, y];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** The ball home on the start pad, still (Start, Stop, a new maze). */
|
|
88
|
-
function home(g: Game) {
|
|
89
|
-
g.ball = homeRoll();
|
|
90
|
-
g.world.cancelTimers();
|
|
91
|
-
if (g.layout && g.scene) resetBall(g.world, g.layout, g.scene);
|
|
92
|
-
drawBall(g);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// ── Run ───────────────────────────────────────────────────────────────
|
|
96
|
-
|
|
97
|
-
/** Starts on the maze already shown, the ball at the start. */
|
|
98
|
-
export function start(g: Game) {
|
|
99
|
-
if (g.phase !== 'ready') return;
|
|
100
|
-
home(g);
|
|
101
|
-
g.world.scoreboard.reset();
|
|
102
|
-
g.world.scoreboard.startCountdown(GAME_DURATION);
|
|
103
|
-
g.won = false;
|
|
104
|
-
g.running = true;
|
|
105
|
-
g.phase = 'playing';
|
|
106
|
-
g.onTime(GAME_DURATION);
|
|
107
|
-
g.onPhase('playing');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** Stop: the same maze, the ball back at the start, not running (as the original game). */
|
|
111
|
-
export function stop(g: Game) {
|
|
112
|
-
g.running = false;
|
|
113
|
-
g.world.scoreboard.reset(0, GAME_DURATION);
|
|
114
|
-
g.won = false;
|
|
115
|
-
g.phase = 'ready';
|
|
116
|
-
home(g);
|
|
117
|
-
g.onTime(GAME_DURATION);
|
|
118
|
-
g.onPhase('ready');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Play Again: a new maze rises, the ball at the start, not running. */
|
|
122
|
-
export function newMaze(g: Game) {
|
|
123
|
-
g.open = generateMaze(GRID);
|
|
124
|
-
if (g.layout && g.scene) setMaze(g.world, g.layout, g.scene, g.open, true);
|
|
125
|
-
stop(g);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function dispose(g: Game) {
|
|
129
|
-
g.world.dispose();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function tick(g: Game, dt: number) {
|
|
133
|
-
if (g.world.isDisposed) return;
|
|
134
|
-
if (g.running && g.layout) {
|
|
135
|
-
const { bumped, reached } = roll(g.ball, g.open, GRID, dt * 1000);
|
|
136
|
-
if (bumped) {
|
|
137
|
-
if (g.scene) bump(g.world, g.layout, g.scene);
|
|
138
|
-
g.onEvent('bump');
|
|
139
|
-
}
|
|
140
|
-
drawBall(g);
|
|
141
|
-
if (reached && reached[0] === GRID - 1 && reached[1] === GRID - 1) {
|
|
142
|
-
g.world.scoreboard.set(calculateTimeBasedScore(g.elapsed, GAME_DURATION, BASE_SCORE));
|
|
143
|
-
end(g, true);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
g.world.update(dt);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** The run's over: its feedback and the result now, the card a beat later (as the original game's half-second wait). */
|
|
150
|
-
function end(g: Game, won: boolean) {
|
|
151
|
-
g.world.scoreboard.stop();
|
|
152
|
-
g.running = false;
|
|
153
|
-
g.won = won;
|
|
154
|
-
const { layout: l, scene: s } = g;
|
|
155
|
-
if (l && s) {
|
|
156
|
-
if (won) celebrate(g.world, l, s);
|
|
157
|
-
else timeUp(g.world, s);
|
|
158
|
-
}
|
|
159
|
-
g.phase = 'over';
|
|
160
|
-
g.onPhase('over');
|
|
161
|
-
g.onEvent(won ? 'win' : 'lose');
|
|
162
|
-
g.world.after(GAME_OVER_DELAY, () => g.onCard());
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ── The finger ────────────────────────────────────────────────────────
|
|
166
|
-
|
|
167
|
-
/** Swipes anywhere: each stretch of a drag one way is a swipe, so one drag can chain turns. */
|
|
168
|
-
export function drag(g: Game, e: DragEvent) {
|
|
169
|
-
if (e.phase === 'start') {
|
|
170
|
-
g.ball.anchorX = e.x;
|
|
171
|
-
g.ball.anchorY = e.y;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (!g.running) return;
|
|
175
|
-
if (swipe(g.ball, e.x, e.y)) g.onEvent('turn');
|
|
176
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// Maze Runner's rules, with no React or engine: the maze (carved by randomized depth-first
|
|
2
|
-
// backtracking from the top-left cell, so there's exactly one way through), which sides of each cell
|
|
3
|
-
// are open, and the ball's roll: along a corridor until a wall, turning at the next junction that's
|
|
4
|
-
// open the way last swiped (buffered, like Pac-Man), reversing at once on a swipe backwards. Ported
|
|
5
|
-
// step for step from the original version's store and UI-thread physics (games/maze-runner).
|
|
6
|
-
|
|
7
|
-
/** Directions: 0 none, 1 up, 2 right, 3 down, 4 left. A cell's open sides are a bitmask (1 << (dir - 1)). */
|
|
8
|
-
export const NONE = 0;
|
|
9
|
-
export const UP = 1;
|
|
10
|
-
export const RIGHT = 2;
|
|
11
|
-
export const DOWN = 3;
|
|
12
|
-
export const LEFT = 4;
|
|
13
|
-
|
|
14
|
-
export const ROLL_CELLS_PER_SEC = 5;
|
|
15
|
-
export const SWIPE_PX = 16; // each stretch of this many points in one direction is a swipe
|
|
16
|
-
export const FRAME_MS = 16.67;
|
|
17
|
-
|
|
18
|
-
export const dirDX = (d: number) => (d === RIGHT ? 1 : d === LEFT ? -1 : 0);
|
|
19
|
-
export const dirDY = (d: number) => (d === UP ? -1 : d === DOWN ? 1 : 0);
|
|
20
|
-
const opposite = (d: number) => (d === NONE ? NONE : ((d + 1) % 4) + 1);
|
|
21
|
-
|
|
22
|
-
/** Candidates carved per maze: the hardest one is kept. */
|
|
23
|
-
const CANDIDATES = 24;
|
|
24
|
-
|
|
25
|
-
/** How many cells the one way through runs, top-left to bottom-right (breadth first over the open sides). */
|
|
26
|
-
function routeLength(open: number[], n: number): number {
|
|
27
|
-
const dist = new Array<number>(n * n).fill(-1);
|
|
28
|
-
dist[0] = 0;
|
|
29
|
-
const queue = [0];
|
|
30
|
-
for (let q = 0; q < queue.length; q++) {
|
|
31
|
-
const i = queue[q]!;
|
|
32
|
-
const x = i % n;
|
|
33
|
-
for (let direction = 0; direction < 4; direction++) {
|
|
34
|
-
const bit = 1 << direction;
|
|
35
|
-
const j = direction === 0 ? i - n : direction === 1 ? i + 1 : direction === 2 ? i + n : i - 1;
|
|
36
|
-
if (open[i]! & bit && dist[j] === -1 && !(bit === 2 && x === n - 1) && !(bit === 8 && x === 0)) {
|
|
37
|
-
dist[j] = dist[i]! + 1;
|
|
38
|
-
queue.push(j);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return dist[n * n - 1]!;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Junctions along the board: cells with three or more ways out, each a choice to get wrong. */
|
|
46
|
-
const junctions = (open: number[]) => open.reduce((k, o) => k + ((o & 1) + ((o >> 1) & 1) + ((o >> 2) & 1) + ((o >> 3) & 1) >= 3 ? 1 : 0), 0);
|
|
47
|
-
|
|
48
|
-
/** A fresh maze: the hardest of several carved ones, by the length of the way through and its choices. */
|
|
49
|
-
export function generateMaze(n: number): number[] {
|
|
50
|
-
let best: number[] = [];
|
|
51
|
-
let bestScore = -1;
|
|
52
|
-
for (let c = 0; c < CANDIDATES; c++) {
|
|
53
|
-
const open = carveMaze(n);
|
|
54
|
-
const score = routeLength(open, n) + junctions(open) * 0.5;
|
|
55
|
-
if (score > bestScore) {
|
|
56
|
-
best = open;
|
|
57
|
-
bestScore = score;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return best;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** One maze: each cell's open sides (row-major), carved as the original store carved it. */
|
|
64
|
-
function carveMaze(n: number): number[] {
|
|
65
|
-
const open = new Array<number>(n * n).fill(0);
|
|
66
|
-
const visited = new Uint8Array(n * n);
|
|
67
|
-
const stack = [0];
|
|
68
|
-
const candidates = new Int32Array(4);
|
|
69
|
-
visited[0] = 1;
|
|
70
|
-
while (stack.length) {
|
|
71
|
-
const current = stack[stack.length - 1]!;
|
|
72
|
-
const x = current % n,
|
|
73
|
-
y = Math.floor(current / n);
|
|
74
|
-
let count = 0;
|
|
75
|
-
if (y > 0 && !visited[current - n]) candidates[count++] = current - n;
|
|
76
|
-
if (x < n - 1 && !visited[current + 1]) candidates[count++] = current + 1;
|
|
77
|
-
if (y < n - 1 && !visited[current + n]) candidates[count++] = current + n;
|
|
78
|
-
if (x > 0 && !visited[current - 1]) candidates[count++] = current - 1;
|
|
79
|
-
if (!count) {
|
|
80
|
-
stack.pop();
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const next = candidates[Math.floor(Math.random() * count)]!;
|
|
84
|
-
if (next === current - 1) {
|
|
85
|
-
open[current]! |= 8;
|
|
86
|
-
open[next]! |= 2;
|
|
87
|
-
} else if (next === current + 1) {
|
|
88
|
-
open[current]! |= 2;
|
|
89
|
-
open[next]! |= 8;
|
|
90
|
-
} else if (next === current - n) {
|
|
91
|
-
open[current]! |= 1;
|
|
92
|
-
open[next]! |= 4;
|
|
93
|
-
} else {
|
|
94
|
-
open[current]! |= 4;
|
|
95
|
-
open[next]! |= 1;
|
|
96
|
-
}
|
|
97
|
-
visited[next] = 1;
|
|
98
|
-
stack.push(next);
|
|
99
|
-
}
|
|
100
|
-
return open;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export const isOpen = (open: number[], n: number, x: number, y: number, d: number) => ((open[y * n + x] ?? 0) & (1 << (d - 1))) !== 0;
|
|
104
|
-
|
|
105
|
-
/** The ball's roll: the cell it last centred on, how far (0..1) it's gone toward the next, and which way. */
|
|
106
|
-
export type Roll = { cx: number; cy: number; p: number; dir: number; queued: number; anchorX: number; anchorY: number };
|
|
107
|
-
export const homeRoll = (): Roll => ({ cx: 0, cy: 0, p: 0, dir: NONE, queued: NONE, anchorX: 0, anchorY: 0 });
|
|
108
|
-
|
|
109
|
-
/** A finger moved to (x, y): a swipe once it's gone SWIPE_PX one way from where the last began. Returns whether a new way was taken. */
|
|
110
|
-
export function swipe(r: Roll, x: number, y: number): boolean {
|
|
111
|
-
const dx = x - r.anchorX;
|
|
112
|
-
const dy = y - r.anchorY;
|
|
113
|
-
const ax = Math.abs(dx);
|
|
114
|
-
const ay = Math.abs(dy);
|
|
115
|
-
if (ax < SWIPE_PX && ay < SWIPE_PX) return false;
|
|
116
|
-
const d = ax > ay ? (dx > 0 ? RIGHT : LEFT) : dy > 0 ? DOWN : UP;
|
|
117
|
-
r.anchorX = x;
|
|
118
|
-
r.anchorY = y;
|
|
119
|
-
if (d === r.queued || (d === r.dir && r.queued === NONE)) return false;
|
|
120
|
-
r.queued = d;
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** One display frame of rolling. Says whether the ball bumped a wall, and the cell it reached (if it reached one). */
|
|
125
|
-
export function roll(r: Roll, open: number[], n: number, frameMs: number): { bumped: boolean; reached: [number, number] | null } {
|
|
126
|
-
let bumped = false;
|
|
127
|
-
let reached: [number, number] | null = null;
|
|
128
|
-
// Reverse mid-corridor at once
|
|
129
|
-
if (r.dir !== NONE && r.queued !== NONE && r.p > 0 && r.queued === opposite(r.dir)) {
|
|
130
|
-
r.cx += dirDX(r.dir);
|
|
131
|
-
r.cy += dirDY(r.dir);
|
|
132
|
-
r.p = 1 - r.p;
|
|
133
|
-
r.dir = r.queued;
|
|
134
|
-
r.queued = NONE;
|
|
135
|
-
}
|
|
136
|
-
// At a cell centre: take a buffered turn if that way is open, stop at a wall
|
|
137
|
-
if (r.p === 0) {
|
|
138
|
-
if (r.queued !== NONE && isOpen(open, n, r.cx, r.cy, r.queued)) {
|
|
139
|
-
r.dir = r.queued;
|
|
140
|
-
r.queued = NONE;
|
|
141
|
-
}
|
|
142
|
-
if (r.dir !== NONE && !isOpen(open, n, r.cx, r.cy, r.dir)) {
|
|
143
|
-
r.dir = NONE;
|
|
144
|
-
bumped = true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (r.dir !== NONE) {
|
|
148
|
-
// A long frame is clamped to three: never a fast-forward
|
|
149
|
-
r.p += (ROLL_CELLS_PER_SEC * Math.min(frameMs, FRAME_MS * 3)) / 1000;
|
|
150
|
-
if (r.p >= 1) {
|
|
151
|
-
r.cx += dirDX(r.dir);
|
|
152
|
-
r.cy += dirDY(r.dir);
|
|
153
|
-
r.p = 0;
|
|
154
|
-
reached = [r.cx, r.cy];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return { bumped, reached };
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** Where the ball is drawn, in cells (its centre: 0.5 is the middle of the first column / row). */
|
|
161
|
-
export const rollAt = (r: Roll): [number, number] => [r.cx + dirDX(r.dir) * r.p + 0.5, r.cy + dirDY(r.dir) * r.p + 0.5];
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
// Everything Maze Runner draws: a maze board (themed, as the original board) walled with wooden walls that
|
|
2
|
-
// stand up off it, a green start pad, an orange exit pad with a ring pulsing over it, and the striped
|
|
3
|
-
// ball, which really rolls (it turns as it goes, so its stripe shows the way it's rolling). Seen from
|
|
4
|
-
// directly overhead (shared/EngineTilt with zero tilt, one world unit per point).
|
|
5
|
-
// Walls along one line are joined into one, so a maze is about 60 walls; every wall is
|
|
6
|
-
// the built-in rounded box (one instanced draw).
|
|
7
|
-
import { type Color, effects, type Entity, extrude, type Model, Path, type Quat, quat, recolor, shapeGeometry, type World } from '@nayan-ui/engine';
|
|
8
|
-
import { PRIMARY_COLOR } from '../../services/GamesConstants';
|
|
9
|
-
import type { GameTheme } from '../../services/ThemeService';
|
|
10
|
-
import { setBackdropTheme, spawnBackdrop } from '../shared/EngineBackdrop';
|
|
11
|
-
import { cacheGameAsset, createGameMesh as createShape } from '../shared/EngineMeshes';
|
|
12
|
-
import { placeTiltedBackdrop } from '../shared/EngineTilt';
|
|
13
|
-
import { toColor } from '../shared/EngineUtils';
|
|
14
|
-
import { BALL_SIZE, BORDER, cellPoint, COLORS, type Layout, WALL_HEIGHT, WALL_THICKNESS } from './MazeRunnerConstants';
|
|
15
|
-
import { DOWN, isOpen, RIGHT } from './MazeRunnerRules';
|
|
16
|
-
|
|
17
|
-
const meshes = new Map<string, Model>();
|
|
18
|
-
const cached = (key: string, build: () => Model) => {
|
|
19
|
-
let m = meshes.get(key);
|
|
20
|
-
if (!m) {
|
|
21
|
-
m = cacheGameAsset('maze-runner/MazeRunnerScene:' + key, build);
|
|
22
|
-
meshes.set(key, m);
|
|
23
|
-
}
|
|
24
|
-
return m;
|
|
25
|
-
};
|
|
26
|
-
const STAND_UP = quat.x(Math.PI / 2);
|
|
27
|
-
const BOARD_DEPTH = 8;
|
|
28
|
-
const BACKDROP_DEPTH = 25;
|
|
29
|
-
const PAD_HEIGHT = 0.05; // of a cell
|
|
30
|
-
/** The ball lit warm and a little self-lit when it reaches the exit. */
|
|
31
|
-
const WIN_GLOW: Color = [1.3, 1.15, 0.55, 1];
|
|
32
|
-
const RISE_STEP = 0.012; // a new maze's walls rise from the start outward, this much a cell
|
|
33
|
-
|
|
34
|
-
// ── Meshes ────────────────────────────────────────────────────────────
|
|
35
|
-
|
|
36
|
-
/** The ball: teal with a white band round it and two dark spots, so its roll shows. */
|
|
37
|
-
const ballMesh = () =>
|
|
38
|
-
cached('mr-ball', () => {
|
|
39
|
-
const teal = toColor(COLORS.BALL);
|
|
40
|
-
const band = toColor(COLORS.BALL_BAND);
|
|
41
|
-
const dot = toColor(COLORS.BALL_DOT);
|
|
42
|
-
return createShape(
|
|
43
|
-
recolor(shapeGeometry('sphere'), ({ position: [x, y, z] }) => {
|
|
44
|
-
const r = Math.hypot(x, y, z) || 1;
|
|
45
|
-
if (Math.abs(z / r) < 0.2) return band;
|
|
46
|
-
if (Math.abs(x / r) > 0.86) return dot;
|
|
47
|
-
return teal;
|
|
48
|
-
}),
|
|
49
|
-
{ shine: 0.9 }
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const panelMesh = (size: number, radius: number) =>
|
|
54
|
-
cached(`mr-panel:${size}:${radius}`, () =>
|
|
55
|
-
createShape(extrude(new Path().addRoundedRect(-size / 2, -size / 2, size, size, radius), { depth: BOARD_DEPTH }), { shine: 0.2 })
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
// ── Spawning ──────────────────────────────────────────────────────────
|
|
59
|
-
|
|
60
|
-
export type Scene = {
|
|
61
|
-
backdrop: Entity;
|
|
62
|
-
floor: Entity;
|
|
63
|
-
inner: Entity | null;
|
|
64
|
-
walls: Entity[];
|
|
65
|
-
pads: Entity[];
|
|
66
|
-
ring: Entity;
|
|
67
|
-
ball: Entity;
|
|
68
|
-
/** The ball's turn so far, from rolling. */
|
|
69
|
-
spin: Quat;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const floorColor = (theme: GameTheme): Color => toColor(theme.mode === 'classic' ? `${PRIMARY_COLOR}30` : theme.BOARD.SURFACE);
|
|
73
|
-
|
|
74
|
-
/** A pad on a cell: a flat disc a little proud of the floor. */
|
|
75
|
-
const pad = (world: World, l: Layout, cx: number, cy: number, size: number, color: string, z = 0) => {
|
|
76
|
-
const [x, y] = cellPoint(l, cx + 0.5, cy + 0.5);
|
|
77
|
-
const h = l.cell * PAD_HEIGHT;
|
|
78
|
-
return world.spawn({
|
|
79
|
-
mesh: 'cylinder',
|
|
80
|
-
position: [x, y, h / 2 + z],
|
|
81
|
-
rotation: STAND_UP,
|
|
82
|
-
scale: [l.cell * size, h, l.cell * size],
|
|
83
|
-
color: toColor(color),
|
|
84
|
-
pickable: false
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export function buildScene(world: World, l: Layout, theme: GameTheme, open: number[]): Scene {
|
|
89
|
-
const backdrop = spawnBackdrop(world, l.width, l.height, -BACKDROP_DEPTH, theme);
|
|
90
|
-
placeTiltedBackdrop(world, backdrop, l, BACKDROP_DEPTH);
|
|
91
|
-
const classic = theme.mode === 'classic';
|
|
92
|
-
const floor = world.spawn({
|
|
93
|
-
mesh: panelMesh(l.size + BORDER * 2, classic ? 12 : 8),
|
|
94
|
-
position: [0, 0, -BOARD_DEPTH / 2],
|
|
95
|
-
color: floorColor(theme),
|
|
96
|
-
pickable: false
|
|
97
|
-
});
|
|
98
|
-
const inner = classic
|
|
99
|
-
? world.spawn({ mesh: panelMesh(l.size, 8), position: [0, 0, -BOARD_DEPTH / 2 + 0.3], color: toColor(`${PRIMARY_COLOR}25`), pickable: false })
|
|
100
|
-
: null;
|
|
101
|
-
const last = l.n - 1;
|
|
102
|
-
const pads = [
|
|
103
|
-
pad(world, l, 0, 0, 0.72, COLORS.START),
|
|
104
|
-
pad(world, l, 0, 0, 0.32, COLORS.START_INNER, l.cell * PAD_HEIGHT),
|
|
105
|
-
pad(world, l, last, last, 0.72, COLORS.GOAL),
|
|
106
|
-
pad(world, l, last, last, 0.32, COLORS.GOAL_INNER, l.cell * PAD_HEIGHT)
|
|
107
|
-
];
|
|
108
|
-
// A ring hovering over the exit, breathing as the original marker did
|
|
109
|
-
const [gx, gy] = cellPoint(l, last + 0.5, last + 0.5);
|
|
110
|
-
const ring = world.spawn({
|
|
111
|
-
mesh: 'torus',
|
|
112
|
-
position: [gx, gy, l.cell * 0.22],
|
|
113
|
-
rotation: STAND_UP,
|
|
114
|
-
scale: l.cell * 0.62,
|
|
115
|
-
color: toColor(COLORS.GOAL),
|
|
116
|
-
pickable: false
|
|
117
|
-
});
|
|
118
|
-
world.animate(ring, { scale: l.cell * 0.62 * 1.12 }, { duration: 0.9, easing: 'easeInOut', repeat: 'forever', yoyo: true });
|
|
119
|
-
const d = l.cell * BALL_SIZE;
|
|
120
|
-
const ball = world.spawn({ mesh: ballMesh(), scale: d, pickable: false });
|
|
121
|
-
const s: Scene = { backdrop, floor, inner, walls: [], pads, ring, ball, spin: [0, 0, 0, 1] };
|
|
122
|
-
setMaze(world, l, s, open, false);
|
|
123
|
-
return s;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function removeScene(world: World, s: Scene) {
|
|
127
|
-
for (const e of [s.backdrop, s.floor, s.inner, ...s.walls, ...s.pads, s.ring, s.ball]) if (e != null) world.despawn(e);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function setSceneTheme(world: World, l: Layout, s: Scene, theme: GameTheme) {
|
|
131
|
-
setBackdropTheme(world, s.backdrop, theme);
|
|
132
|
-
const classic = theme.mode === 'classic';
|
|
133
|
-
world.set(s.floor, { mesh: panelMesh(l.size + BORDER * 2, classic ? 12 : 8), color: floorColor(theme) });
|
|
134
|
-
if (s.inner != null) world.set(s.inner, { scale: classic ? 1 : 0 });
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* The maze's walls: every closed side, those along one line joined end to end. Each runs along a line
|
|
139
|
-
* between cells (row lines across, column lines down), from `from` to `to` (in cells).
|
|
140
|
-
*/
|
|
141
|
-
function wallRuns(open: number[], n: number) {
|
|
142
|
-
const runs: { across: boolean; line: number; from: number; to: number }[] = [];
|
|
143
|
-
const closed = (across: boolean, line: number, i: number) => {
|
|
144
|
-
// A row line's piece above cell (i, line); a column line's piece left of cell (line, i). The rim is always closed.
|
|
145
|
-
if (line === 0 || line === n) return true;
|
|
146
|
-
return across ? !isOpen(open, n, i, line - 1, DOWN) : !isOpen(open, n, line - 1, i, RIGHT);
|
|
147
|
-
};
|
|
148
|
-
for (const across of [true, false])
|
|
149
|
-
for (let line = 0; line <= n; line++) {
|
|
150
|
-
let start = -1;
|
|
151
|
-
for (let i = 0; i <= n; i++) {
|
|
152
|
-
const c = i < n && closed(across, line, i);
|
|
153
|
-
if (c && start < 0) start = i;
|
|
154
|
-
if (!c && start >= 0) {
|
|
155
|
-
runs.push({ across, line, from: start, to: i });
|
|
156
|
-
start = -1;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return runs;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** Builds a maze's walls; on a new maze they rise out of the board, from the start corner outward. */
|
|
164
|
-
export function setMaze(world: World, l: Layout, s: Scene, open: number[], animate: boolean) {
|
|
165
|
-
for (const w of s.walls) world.despawn(w);
|
|
166
|
-
s.walls = [];
|
|
167
|
-
const t = l.cell * WALL_THICKNESS;
|
|
168
|
-
const h = l.cell * WALL_HEIGHT;
|
|
169
|
-
wallRuns(open, l.n).forEach((r, k) => {
|
|
170
|
-
const mid = (r.from + r.to) / 2;
|
|
171
|
-
const [x, y] = r.across ? cellPoint(l, mid, r.line) : cellPoint(l, r.line, mid);
|
|
172
|
-
const len = (r.to - r.from) * l.cell + t;
|
|
173
|
-
const scale: [number, number, number] = r.across ? [len, t, h] : [t, len, h];
|
|
174
|
-
const color = toColor(COLORS.WALLS[k % COLORS.WALLS.length]!);
|
|
175
|
-
const e = world.spawn({
|
|
176
|
-
mesh: 'roundedBox',
|
|
177
|
-
position: [x, y, animate ? 0 : h / 2],
|
|
178
|
-
scale: animate ? [scale[0], scale[1], 0.01] : scale,
|
|
179
|
-
color,
|
|
180
|
-
pickable: false
|
|
181
|
-
});
|
|
182
|
-
if (animate) {
|
|
183
|
-
const delay = Math.hypot(r.across ? mid : r.line, r.across ? r.line : mid) * RISE_STEP * l.n;
|
|
184
|
-
world.animate(e, { position: [x, y, h / 2], scale }, { duration: 0.28, delay: delay * 0.25, easing: 'back' });
|
|
185
|
-
}
|
|
186
|
-
s.walls.push(e);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// ── The ball ──────────────────────────────────────────────────────────
|
|
191
|
-
|
|
192
|
-
/** The ball at a point (in cells), turned by how far it rolled to get there from (px, py). */
|
|
193
|
-
export function placeBall(world: World, l: Layout, s: Scene, cx: number, cy: number, px: number, py: number) {
|
|
194
|
-
const r = (l.cell * BALL_SIZE) / 2;
|
|
195
|
-
const [x, y] = cellPoint(l, cx, cy);
|
|
196
|
-
const [ox, oy] = cellPoint(l, px, py);
|
|
197
|
-
const dx = x - ox;
|
|
198
|
-
const dy = y - oy;
|
|
199
|
-
const dist = Math.hypot(dx, dy);
|
|
200
|
-
// Rolling on the board turns it about the axis across its way (up × motion)
|
|
201
|
-
if (dist > 1e-6) s.spin = quat.multiply(quat.axisAngle(-dy / dist, dx / dist, 0, dist / r), s.spin);
|
|
202
|
-
world.set(s.ball, { position: [x, y, r], rotation: s.spin });
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/** Back to the start's look (a new game, or the preview). */
|
|
206
|
-
export function resetBall(world: World, l: Layout, s: Scene) {
|
|
207
|
-
world.stopAnimation(s.ball);
|
|
208
|
-
world.set(s.ball, { scale: l.cell * BALL_SIZE, color: [1, 1, 1, 1] });
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** It ran into a wall: a little jolt. */
|
|
212
|
-
export function bump(world: World, l: Layout, s: Scene) {
|
|
213
|
-
world.animate(s.ball, { shake: l.cell * 0.06 }, { duration: 0.18 });
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** The exit reached: the ball turns gold with a pop, and confetti bursts over the maze. */
|
|
217
|
-
export function celebrate(world: World, l: Layout, s: Scene) {
|
|
218
|
-
const d = l.cell * BALL_SIZE;
|
|
219
|
-
world.set(s.ball, { color: WIN_GLOW });
|
|
220
|
-
world.animate(s.ball, [{ scale: d * 1.5, at: 0.4 }, { scale: d * 1.15 }], { duration: 0.5, easing: 'easeOut' });
|
|
221
|
-
const [gx, gy] = cellPoint(l, l.n - 0.5, l.n - 0.5);
|
|
222
|
-
effects.sparkle(world, {
|
|
223
|
-
position: [gx, gy, l.cell],
|
|
224
|
-
count: 30,
|
|
225
|
-
size: l.cell * 0.12,
|
|
226
|
-
speed: l.cell * 5,
|
|
227
|
-
lifetime: 1,
|
|
228
|
-
gravity: -l.cell * 6,
|
|
229
|
-
colors: ['#FFD700', '#4CAF50', '#2196F3', '#FF5722'].map((c) => toColor(c))
|
|
230
|
-
});
|
|
231
|
-
effects.confetti(world, {
|
|
232
|
-
position: [0, 0, l.cell],
|
|
233
|
-
count: 50,
|
|
234
|
-
size: l.cell * 0.14,
|
|
235
|
-
speed: l.size * 1.3,
|
|
236
|
-
lifetime: 1.3,
|
|
237
|
-
gravity: -l.size * 2.2,
|
|
238
|
-
colors: ['#FFD700', '#E91E63', '#4ECDC4', '#FFEB3B'].map((c) => toColor(c))
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/** Out of time: the ball dims where it stopped. */
|
|
243
|
-
export function timeUp(world: World, s: Scene) {
|
|
244
|
-
world.animate(s.ball, { color: [0.55, 0.55, 0.6, 1] }, { duration: 0.4 });
|
|
245
|
-
}
|