@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,116 +0,0 @@
|
|
|
1
|
-
// Snake 3D's rules, with no React or engine: the 20 x 20 grid, the snake (head first), food, and one
|
|
2
|
-
// move of the snake. Ported step for step from the original version's UI-thread physics
|
|
3
|
-
// (games/snake-3d/Snake3DPhysics.ts), with the same random draws in the same order.
|
|
4
|
-
|
|
5
|
-
export const GRID = 20;
|
|
6
|
-
export const INITIAL_LENGTH = 3;
|
|
7
|
-
/** Points per food: the original base points x its "medium" multiplier of 2. */
|
|
8
|
-
export const POINTS_PER_FOOD = 1000;
|
|
9
|
-
export const POINTS_PER_SPECIAL_FOOD = 2000;
|
|
10
|
-
export const SPECIAL_FOOD_CHANCE = 0.15;
|
|
11
|
-
export const SPECIAL_FOOD_DURATION = 10; // seconds before an uneaten bonus turns into normal food
|
|
12
|
-
const MAX_FOOD_ATTEMPTS = 100;
|
|
13
|
-
|
|
14
|
-
export type Direction = 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';
|
|
15
|
-
export const VECTORS: Record<Direction, [number, number]> = { UP: [0, -1], DOWN: [0, 1], LEFT: [-1, 0], RIGHT: [1, 0] };
|
|
16
|
-
const OPPOSITE: Record<Direction, Direction> = { UP: 'DOWN', DOWN: 'UP', LEFT: 'RIGHT', RIGHT: 'LEFT' };
|
|
17
|
-
|
|
18
|
-
/** expiresAt: game-clock seconds (bonus food only). */
|
|
19
|
-
export type Food = { id: number; x: number; y: number; isSpecial: boolean; expiresAt?: number };
|
|
20
|
-
|
|
21
|
-
/** The snake's cells, head first, flattened [x0, y0, x1, y1, …]. */
|
|
22
|
-
export type Snake = number[];
|
|
23
|
-
|
|
24
|
-
/** In the middle of the grid, heading right. */
|
|
25
|
-
export function initialSnake(): Snake {
|
|
26
|
-
const c = Math.floor(GRID / 2);
|
|
27
|
-
const s: Snake = [];
|
|
28
|
-
for (let i = 0; i < INITIAL_LENGTH; i++) s.push(c - i, c);
|
|
29
|
-
return s;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const onSnake = (x: number, y: number, s: Snake) => {
|
|
33
|
-
for (let i = 0; i < s.length; i += 2) if (s[i] === x && s[i + 1] === y) return true;
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/** A random cell off the snake (giving up after 100 tries, as before). */
|
|
38
|
-
export function generateFood(s: Snake, isSpecial: boolean, id: number, now: number): Food {
|
|
39
|
-
let x = 0;
|
|
40
|
-
let y = 0;
|
|
41
|
-
let attempts = 0;
|
|
42
|
-
do {
|
|
43
|
-
x = Math.floor(Math.random() * GRID);
|
|
44
|
-
y = Math.floor(Math.random() * GRID);
|
|
45
|
-
attempts++;
|
|
46
|
-
} while (attempts < MAX_FOOD_ATTEMPTS && onSnake(x, y, s));
|
|
47
|
-
const food: Food = { id, x, y, isSpecial };
|
|
48
|
-
if (isSpecial) food.expiresAt = now + SPECIAL_FOOD_DURATION;
|
|
49
|
-
return food;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type SnakeState = { snake: Snake; direction: Direction; nextDirection: Direction; turns: Direction[]; food: Food | null; nextFoodId: number };
|
|
53
|
-
|
|
54
|
-
export const freshState = (): SnakeState => ({
|
|
55
|
-
snake: initialSnake(),
|
|
56
|
-
direction: 'RIGHT',
|
|
57
|
-
nextDirection: 'RIGHT',
|
|
58
|
-
turns: [],
|
|
59
|
-
food: null,
|
|
60
|
-
nextFoodId: 1
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
/** Buffer up to two turns in swipe order; refuse duplicates and reversals against the queued heading. */
|
|
64
|
-
export function turn(st: SnakeState, d: Direction) {
|
|
65
|
-
const heading = st.turns[st.turns.length - 1] ?? st.direction;
|
|
66
|
-
if (st.turns.length >= 2 || d === heading || OPPOSITE[heading] === d) return;
|
|
67
|
-
st.turns.push(d);
|
|
68
|
-
st.nextDirection = st.turns[0]!;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StepResult = { crash: boolean; ate: Food | null; newFood: Food | null; grew: boolean };
|
|
72
|
-
|
|
73
|
-
/** One move: the head steps on, the tail follows; walls and the body kill; food grows it by one. */
|
|
74
|
-
export function step(st: SnakeState, now: number): StepResult {
|
|
75
|
-
const dir = st.nextDirection;
|
|
76
|
-
st.turns.shift();
|
|
77
|
-
st.nextDirection = st.turns[0] ?? dir;
|
|
78
|
-
const s = st.snake;
|
|
79
|
-
const [vx, vy] = VECTORS[dir];
|
|
80
|
-
const hx = s[0]! + vx;
|
|
81
|
-
const hy = s[1]! + vy;
|
|
82
|
-
const moved: Snake = new Array(s.length);
|
|
83
|
-
moved[0] = hx;
|
|
84
|
-
moved[1] = hy;
|
|
85
|
-
for (let i = 2; i < s.length; i++) moved[i] = s[i - 2]!;
|
|
86
|
-
// The head turns to face the fatal way even on a crash, as before
|
|
87
|
-
st.direction = dir;
|
|
88
|
-
const wall = hx < 0 || hx >= GRID || hy < 0 || hy >= GRID;
|
|
89
|
-
let self = false;
|
|
90
|
-
if (!wall)
|
|
91
|
-
for (let i = 2; i < moved.length; i += 2)
|
|
92
|
-
if (moved[i] === hx && moved[i + 1] === hy) {
|
|
93
|
-
self = true;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
if (wall || self) return { crash: true, ate: null, newFood: null, grew: false };
|
|
97
|
-
|
|
98
|
-
const food = st.food;
|
|
99
|
-
let next = moved;
|
|
100
|
-
let newFood: Food | null = null;
|
|
101
|
-
let ate: Food | null = null;
|
|
102
|
-
if (food && hx === food.x && hy === food.y) {
|
|
103
|
-
// Grow: a new tail segment on the tail's cell
|
|
104
|
-
next = moved.slice();
|
|
105
|
-
next.push(moved[moved.length - 2]!, moved[moved.length - 1]!);
|
|
106
|
-
ate = food;
|
|
107
|
-
const special = Math.random() < SPECIAL_FOOD_CHANCE;
|
|
108
|
-
newFood = generateFood(next, special, st.nextFoodId++, now);
|
|
109
|
-
} else if (food && food.isSpecial && food.expiresAt !== undefined && now > food.expiresAt) {
|
|
110
|
-
// An uneaten bonus turns into normal food somewhere else
|
|
111
|
-
newFood = generateFood(moved, false, st.nextFoodId++, now);
|
|
112
|
-
}
|
|
113
|
-
st.snake = next;
|
|
114
|
-
if (newFood) st.food = newFood;
|
|
115
|
-
return { crash: false, ate, newFood, grew: ate !== null };
|
|
116
|
-
}
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Camera,
|
|
3
|
-
type Color,
|
|
4
|
-
effects,
|
|
5
|
-
type Entity,
|
|
6
|
-
extrude,
|
|
7
|
-
merge,
|
|
8
|
-
type Model,
|
|
9
|
-
type MutableQuat,
|
|
10
|
-
Path,
|
|
11
|
-
quat,
|
|
12
|
-
shapeGeometry,
|
|
13
|
-
type Vec3,
|
|
14
|
-
type World
|
|
15
|
-
} from '@nayan-ui/engine';
|
|
16
|
-
import type { GameTheme } from '../../services/ThemeService';
|
|
17
|
-
import { setBackdropTheme, spawnBackdrop } from '../shared/EngineBackdrop';
|
|
18
|
-
import { getFruits } from '../shared/EngineFruits';
|
|
19
|
-
import { cacheGameAsset, createGameMesh as createShape } from '../shared/EngineMeshes';
|
|
20
|
-
import { placeTiltedBackdrop } from '../shared/EngineTilt';
|
|
21
|
-
// Everything Snake 3D draws: the board (themed, as the original board) checkered and walled in by a raised
|
|
22
|
-
// rim, the snake (glossy beads from a big head with eyes and a flicking tongue down to a thin tail,
|
|
23
|
-
// joined so it reads as one body, gliding cell to cell), and the food: a red apple, or a spinning gold
|
|
24
|
-
// star for a bonus. Seen from a little in front of straight down (shared/EngineTilt: an orthographic
|
|
25
|
-
// camera leaning back, one world unit per point). Every bead is the built-in sphere (one instanced draw).
|
|
26
|
-
import { toColor } from '../shared/EngineUtils';
|
|
27
|
-
import { COLORS, gridPoint, type Layout } from './Snake3DConstants';
|
|
28
|
-
import { sampleSnakeMotion } from './Snake3DMotion';
|
|
29
|
-
import { type Direction, type Food, GRID } from './Snake3DRules';
|
|
30
|
-
|
|
31
|
-
const meshes = new Map<string, Model>();
|
|
32
|
-
const cached = (key: string, build: () => Model) => {
|
|
33
|
-
let m = meshes.get(key);
|
|
34
|
-
if (!m) {
|
|
35
|
-
m = cacheGameAsset('snake-3d/Snake3DScene:' + key, build);
|
|
36
|
-
meshes.set(key, m);
|
|
37
|
-
}
|
|
38
|
-
return m;
|
|
39
|
-
};
|
|
40
|
-
const BOARD_DEPTH = 10;
|
|
41
|
-
const BACKDROP_DEPTH = 30;
|
|
42
|
-
const STAND_UP = quat.x(Math.PI / 2);
|
|
43
|
-
const headTurn: MutableQuat = [0, 0, 0, 1];
|
|
44
|
-
const HEADING: Record<Direction, number> = { RIGHT: 0, UP: Math.PI / 2, LEFT: Math.PI, DOWN: -Math.PI / 2 };
|
|
45
|
-
|
|
46
|
-
const panelMesh = (w: number, radius: number) =>
|
|
47
|
-
cached(`s3-panel:${w}:${radius}`, () =>
|
|
48
|
-
createShape(extrude(new Path().addRoundedRect(-w / 2, -w / 2, w, w, radius), { depth: BOARD_DEPTH }), { shine: 0.2 })
|
|
49
|
-
);
|
|
50
|
-
/** Every other cell of the board, a hair above it: one mesh. */
|
|
51
|
-
const checkerMesh = () =>
|
|
52
|
-
cached('s3-checker', () => {
|
|
53
|
-
const parts = [];
|
|
54
|
-
for (let y = 0; y < GRID; y++)
|
|
55
|
-
for (let x = 0; x < GRID; x++)
|
|
56
|
-
if ((x + y) % 2)
|
|
57
|
-
parts.push({ geometry: shapeGeometry('cube'), position: [x + 0.5 - GRID / 2, GRID / 2 - y - 0.5, 0] as Vec3, scale: [1, 1, 0.02] as Vec3 });
|
|
58
|
-
return createShape(merge(parts), { center: false });
|
|
59
|
-
});
|
|
60
|
-
/** The walls as one continuous frame round the grid: a rounded outside, a square inside, `h` tall. */
|
|
61
|
-
const rimMesh = (size: number, rim: number, radius: number, h: number) =>
|
|
62
|
-
cached(`s3-rim:${size.toFixed(1)}:${rim.toFixed(1)}:${radius}:${h.toFixed(1)}`, () => {
|
|
63
|
-
const outer = size + rim * 2;
|
|
64
|
-
return createShape(
|
|
65
|
-
extrude(new Path().addRoundedRect(-outer / 2, -outer / 2, outer, outer, radius).addRect(-size / 2, -size / 2, size, size), {
|
|
66
|
-
depth: h,
|
|
67
|
-
fillRule: 'evenodd'
|
|
68
|
-
}),
|
|
69
|
-
{ shine: 0.2 }
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
const starMesh = () => cached('s3-star', () => createShape(extrude(new Path().addStar(0, 0, 0.5, 0.22), { depth: 0.28 }), { shine: 0.7 }));
|
|
73
|
-
|
|
74
|
-
// ── Spawning ──────────────────────────────────────────────────────────
|
|
75
|
-
|
|
76
|
-
export type Scene = {
|
|
77
|
-
backdrop: Entity;
|
|
78
|
-
board: Entity[];
|
|
79
|
-
/** The head (eyes and tongue attached), the beads behind it, and the joints between them. */
|
|
80
|
-
head: Entity;
|
|
81
|
-
tongue: Entity;
|
|
82
|
-
beads: Entity[];
|
|
83
|
-
joints: Entity[];
|
|
84
|
-
food: Entity | null;
|
|
85
|
-
foodId: number;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
|
|
89
|
-
const mix = (a: Color, b: Color, t: number): Color => [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t), 1];
|
|
90
|
-
/** A bead's size (of a cell), from the head (0) to the tail (1): full through the body, tapering to a fine tail. */
|
|
91
|
-
const beadSize = (t: number) => (t < 0.6 ? lerp(0.8, 0.72, t / 0.6) : lerp(0.72, 0.3, ((t - 0.6) / 0.4) ** 1.3));
|
|
92
|
-
/** Its color: head to tail through the body color, with a dark scale band every third bead. */
|
|
93
|
-
const beadColor = (t: number, i: number) => {
|
|
94
|
-
const c = t < 0.5 ? mix(toColor(COLORS.HEAD), toColor(COLORS.BODY), t * 2) : mix(toColor(COLORS.BODY), toColor(COLORS.TAIL), t * 2 - 1);
|
|
95
|
-
const k = i % 3 === 0 ? 0.68 : 1;
|
|
96
|
-
return [c[0] * k, c[1] * k, c[2] * k, 1] as Color;
|
|
97
|
-
};
|
|
98
|
-
/** The body's beads are a little flattened, as a snake lies low on the ground. */
|
|
99
|
-
const FLAT = 0.72;
|
|
100
|
-
const HEAD_SCALE = (d: number): Vec3 => [d * 1.25, d * 0.95, d * 0.62];
|
|
101
|
-
|
|
102
|
-
function spawnBoard(world: World, l: Layout, theme: GameTheme): Entity[] {
|
|
103
|
-
const out: Entity[] = [];
|
|
104
|
-
const add = (o: Parameters<World['spawn']>[0]) => out.push(world.spawn({ pickable: false, ...o }));
|
|
105
|
-
const classic = theme.mode === 'classic';
|
|
106
|
-
const rim = l.cell * 0.5;
|
|
107
|
-
add({
|
|
108
|
-
mesh: panelMesh(l.size + rim * 2, classic ? 12 : 8),
|
|
109
|
-
position: [0, 0, -BOARD_DEPTH / 2],
|
|
110
|
-
color: toColor(classic ? COLORS.CLASSIC_BOARD : theme.BOARD.SURFACE)
|
|
111
|
-
});
|
|
112
|
-
add({ mesh: checkerMesh(), position: [0, 0, 0.05], scale: l.cell, color: toColor(classic ? COLORS.CLASSIC_DARK : theme.BOARD.CELL_EMPTY) });
|
|
113
|
-
// The walls: a low rim round the grid
|
|
114
|
-
const h = l.cell * 0.55;
|
|
115
|
-
const rimColor = toColor(classic ? COLORS.CLASSIC_RIM : theme.BOARD.BORDER);
|
|
116
|
-
add({ mesh: rimMesh(l.size, rim, classic ? 12 : 8, h), position: [0, 0, h / 2], color: rimColor });
|
|
117
|
-
return out;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function buildScene(world: World, l: Layout, theme: GameTheme): Scene {
|
|
121
|
-
const backdrop = spawnBackdrop(world, l.width, l.height, -BACKDROP_DEPTH, theme);
|
|
122
|
-
placeTiltedBackdrop(world, backdrop, l, BACKDROP_DEPTH);
|
|
123
|
-
const d = l.cell * 0.9;
|
|
124
|
-
// A wide, flat head (pointing +x): in the head's own units it's one unit across
|
|
125
|
-
const head = world.spawn({ mesh: 'sphere', scale: HEAD_SCALE(d), color: toColor(COLORS.HEAD), pickable: false });
|
|
126
|
-
for (const s of [-1, 1]) {
|
|
127
|
-
// Eyes set on the sides of the head, with upright slit pupils
|
|
128
|
-
world.spawn({
|
|
129
|
-
mesh: 'sphere',
|
|
130
|
-
parent: head,
|
|
131
|
-
position: [0.12, s * 0.3, 0.26],
|
|
132
|
-
scale: [0.24, 0.2, 0.22],
|
|
133
|
-
color: toColor(COLORS.EYE),
|
|
134
|
-
pickable: false
|
|
135
|
-
});
|
|
136
|
-
world.spawn({
|
|
137
|
-
mesh: 'sphere',
|
|
138
|
-
parent: head,
|
|
139
|
-
position: [0.2, s * 0.33, 0.33],
|
|
140
|
-
scale: [0.05, 0.13, 0.1],
|
|
141
|
-
color: toColor(COLORS.PUPIL),
|
|
142
|
-
pickable: false
|
|
143
|
-
});
|
|
144
|
-
// Nostrils on the snout
|
|
145
|
-
world.spawn({
|
|
146
|
-
mesh: 'sphere',
|
|
147
|
-
parent: head,
|
|
148
|
-
position: [0.47, s * 0.09, 0.22],
|
|
149
|
-
scale: [0.05, 0.04, 0.03],
|
|
150
|
-
color: [0.05, 0.05, 0.05, 1],
|
|
151
|
-
pickable: false
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
// A forked tongue: a stem and two tips, hidden until it flicks
|
|
155
|
-
const tongue = world.spawn({ mesh: 'none', parent: head, position: [0.5, 0, -0.05], scale: [0, 1, 1], pickable: false });
|
|
156
|
-
const red = toColor(COLORS.TONGUE);
|
|
157
|
-
world.spawn({ mesh: 'cube', parent: tongue, position: [0.18, 0, 0], scale: [0.36, 0.05, 0.03], color: red, pickable: false });
|
|
158
|
-
for (const s of [-1, 1])
|
|
159
|
-
world.spawn({
|
|
160
|
-
mesh: 'cube',
|
|
161
|
-
parent: tongue,
|
|
162
|
-
position: [0.42, s * 0.05, 0],
|
|
163
|
-
rotation: quat.z(s * 0.5),
|
|
164
|
-
scale: [0.16, 0.04, 0.03],
|
|
165
|
-
color: red,
|
|
166
|
-
pickable: false
|
|
167
|
-
});
|
|
168
|
-
return { backdrop, board: spawnBoard(world, l, theme), head, tongue, beads: [], joints: [], food: null, foodId: -1 };
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function removeScene(world: World, s: Scene) {
|
|
172
|
-
for (const e of [s.backdrop, ...s.board, s.head, ...s.beads, ...s.joints, s.food]) if (e != null) world.despawn(e);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export function setSceneTheme(world: World, l: Layout, s: Scene, theme: GameTheme) {
|
|
176
|
-
setBackdropTheme(world, s.backdrop, theme);
|
|
177
|
-
for (const e of s.board) world.despawn(e);
|
|
178
|
-
s.board = spawnBoard(world, l, theme);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// ── The snake ─────────────────────────────────────────────────────────
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Every bead follows the head's rounded turns between cells, `t` of the way (0..1).
|
|
185
|
-
* `prev` and `cur` are the cells (flattened x, y), head first.
|
|
186
|
-
*/
|
|
187
|
-
export function drawSnake(world: World, l: Layout, s: Scene, prev: number[], cur: number[], t: number) {
|
|
188
|
-
const updates = world.transforms;
|
|
189
|
-
const n = cur.length / 2;
|
|
190
|
-
// Enough beads and joints for the body (the head is its own)
|
|
191
|
-
while (s.beads.length < n - 1) s.beads.push(world.spawn({ mesh: 'sphere', pickable: false }));
|
|
192
|
-
while (s.joints.length < n - 1) s.joints.push(world.spawn({ mesh: 'sphere', pickable: false }));
|
|
193
|
-
for (let i = n - 1; i < s.beads.length; i++) updates.scale(s.beads[i]!, 0);
|
|
194
|
-
for (let i = n - 1; i < s.joints.length; i++) updates.scale(s.joints[i]!, 0);
|
|
195
|
-
let px = 0;
|
|
196
|
-
let py = 0;
|
|
197
|
-
let pr = 0;
|
|
198
|
-
for (let i = 0; i < n; i++) {
|
|
199
|
-
const [x, y, dx, dy] = sampleSnakeMotion(prev, cur, i, t);
|
|
200
|
-
const [wx, wy] = gridPoint(l, x + 0.5, y + 0.5);
|
|
201
|
-
const k = n > 1 ? i / (n - 1) : 0;
|
|
202
|
-
const r = (i === 0 ? 0.45 : beadSize(k) / 2) * l.cell;
|
|
203
|
-
if (i === 0) {
|
|
204
|
-
updates.position(s.head, wx, wy, r * 0.75);
|
|
205
|
-
if (dx || dy) {
|
|
206
|
-
const q = quat.z(Math.atan2(-dy, dx), headTurn);
|
|
207
|
-
updates.rotation(s.head, q[0], q[1], q[2], q[3]);
|
|
208
|
-
}
|
|
209
|
-
} else {
|
|
210
|
-
const bead = s.beads[i - 1]!;
|
|
211
|
-
const c = beadColor(k, i);
|
|
212
|
-
updates.position(bead, wx, wy, r * FLAT);
|
|
213
|
-
updates.scale(bead, r * 2, r * 2, r * 2 * FLAT);
|
|
214
|
-
updates.color(bead, c[0], c[1], c[2], c[3] ?? 1);
|
|
215
|
-
// A joint between this bead and the one ahead, so the body reads as one smooth length
|
|
216
|
-
const jr = (r + pr) / 2;
|
|
217
|
-
const joint = s.joints[i - 1]!;
|
|
218
|
-
const jc = beadColor(k, i + 1);
|
|
219
|
-
updates.position(joint, (wx + px) / 2, (wy + py) / 2, jr * FLAT * 0.95);
|
|
220
|
-
updates.scale(joint, jr * 2, jr * 2, jr * 2 * FLAT * 0.95);
|
|
221
|
-
updates.color(joint, jc[0], jc[1], jc[2], jc[3] ?? 1);
|
|
222
|
-
}
|
|
223
|
-
px = wx;
|
|
224
|
-
py = wy;
|
|
225
|
-
pr = r;
|
|
226
|
-
}
|
|
227
|
-
updates.flush();
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/** The head turns to face the way it's heading. */
|
|
231
|
-
export function faceHead(world: World, s: Scene, d: Direction) {
|
|
232
|
-
world.set(s.head, { rotation: quat.z(HEADING[d]) });
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** The tongue flicks out now and then while it's moving. */
|
|
236
|
-
export function flick(world: World, s: Scene) {
|
|
237
|
-
world.animate(s.tongue, [{ scale: [1, 1, 1], at: 0.35 }, { scale: [0.85, 1, 1], at: 0.6 }, { scale: [0, 1, 1] }], { duration: 0.32 });
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** A fresh snake's look (a new game or the preview). */
|
|
241
|
-
export function resetSnake(world: World, l: Layout, s: Scene) {
|
|
242
|
-
const d = l.cell * 0.9;
|
|
243
|
-
world.stopAnimation(s.head);
|
|
244
|
-
world.set(s.head, { scale: HEAD_SCALE(d), color: toColor(COLORS.HEAD), rotation: quat.z(0) });
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/** Food eaten: the head gulps and the food bursts. */
|
|
248
|
-
export function gulp(world: World, l: Layout, s: Scene, food: Food) {
|
|
249
|
-
const d = l.cell * 0.9;
|
|
250
|
-
const [hx, hy, hz] = HEAD_SCALE(d);
|
|
251
|
-
world.animate(s.head, [{ scale: [hx * 1.2, hy * 1.25, hz * 1.2], at: 0.3 }, { scale: HEAD_SCALE(d) }], { duration: 0.3 });
|
|
252
|
-
const [x, y] = gridPoint(l, food.x + 0.5, food.y + 0.5);
|
|
253
|
-
const position: Vec3 = [x, y, l.cell * 0.5];
|
|
254
|
-
if (food.isSpecial)
|
|
255
|
-
effects.sparkle(world, {
|
|
256
|
-
position,
|
|
257
|
-
count: 26,
|
|
258
|
-
size: l.cell * 0.14,
|
|
259
|
-
speed: l.cell * 5,
|
|
260
|
-
lifetime: 0.6,
|
|
261
|
-
gravity: -l.cell * 6,
|
|
262
|
-
colors: [toColor('#FFD54F'), toColor(COLORS.SPECIAL), [1, 1, 1, 1]]
|
|
263
|
-
});
|
|
264
|
-
else
|
|
265
|
-
effects.splash(world, {
|
|
266
|
-
position,
|
|
267
|
-
count: 14,
|
|
268
|
-
size: l.cell * 0.14,
|
|
269
|
-
speed: l.cell * 5,
|
|
270
|
-
lifetime: 0.5,
|
|
271
|
-
gravity: -l.cell * 10,
|
|
272
|
-
colors: [toColor('#E53935'), toColor('#FFCDD2')]
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/** A crash: the snake flushes red, a jolt runs through the board. */
|
|
277
|
-
export function crash(world: World, l: Layout, s: Scene, camera: Camera) {
|
|
278
|
-
const red = toColor(COLORS.CRASH);
|
|
279
|
-
world.animate(s.head, { color: red }, { duration: 0.2 });
|
|
280
|
-
for (const e of [...s.beads, ...s.joints]) world.animate(e, { color: red }, { duration: 0.35 });
|
|
281
|
-
world.animate(s.head, { shake: l.cell * 0.25 }, { duration: 0.4 });
|
|
282
|
-
camera.shake = l.cell * 0.35;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// ── Food ──────────────────────────────────────────────────────────────
|
|
286
|
-
|
|
287
|
-
/** The food on the board (an apple, or a spinning gold star for a bonus), or none. */
|
|
288
|
-
export function placeFood(world: World, l: Layout, s: Scene, food: Food | null) {
|
|
289
|
-
if (food && food.id === s.foodId) return;
|
|
290
|
-
if (s.food != null) world.despawn(s.food);
|
|
291
|
-
s.food = null;
|
|
292
|
-
s.foodId = food ? food.id : -1;
|
|
293
|
-
if (!food) return;
|
|
294
|
-
const [x, y] = gridPoint(l, food.x + 0.5, food.y + 0.5);
|
|
295
|
-
const size = l.cell * 0.8;
|
|
296
|
-
const root = world.spawn({
|
|
297
|
-
mesh: 'none',
|
|
298
|
-
position: [x, y, size / 2],
|
|
299
|
-
bob: { amplitude: [0, 0, l.cell * 0.12], speed: 4 },
|
|
300
|
-
spin: food.isSpecial ? [0, 0, 2.5] : [0, 0, 0],
|
|
301
|
-
pickable: false
|
|
302
|
-
});
|
|
303
|
-
if (food.isSpecial) {
|
|
304
|
-
world.spawn({ mesh: starMesh(), parent: root, rotation: STAND_UP, scale: size * 1.15, color: toColor(COLORS.SPECIAL), pickable: false });
|
|
305
|
-
world.spawn({ mesh: 'sphere', parent: root, scale: size * 0.55, color: [2, 1.6, 0.5, 0.35], pickable: false });
|
|
306
|
-
} else {
|
|
307
|
-
const fruit = getFruits().apple;
|
|
308
|
-
// The apple stands up off the board (its own y up becomes the board's z)
|
|
309
|
-
const c = fruit.center;
|
|
310
|
-
world.spawn({
|
|
311
|
-
mesh: fruit.whole,
|
|
312
|
-
parent: root,
|
|
313
|
-
rotation: STAND_UP,
|
|
314
|
-
position: [-c[0] * size, c[2] * size, -c[1] * size],
|
|
315
|
-
scale: size,
|
|
316
|
-
pickable: false
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
world.set(root, { scale: 0.01 });
|
|
320
|
-
world.animate(root, { scale: 1 }, { duration: 0.25, easing: 'back' });
|
|
321
|
-
s.food = root;
|
|
322
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// Snakes and Ladders' screen, on the Nayan engine: the board, snakes, ladders, pawns and die are one 3D
|
|
2
|
-
// scene (an orthographic camera leaning back over a wooden board), under Playtura's scoreboard,
|
|
3
|
-
// controls and modals. The rules and turns are in SnakesAndLaddersGame.ts, what it draws in
|
|
4
|
-
// SnakesAndLaddersScene.ts.
|
|
5
|
-
//
|
|
6
|
-
// One world serves the whole visit: Start, Stop and Play Again reset it in place and a theme change
|
|
7
|
-
// repaints the backdrop, so the GPU view is never rebuilt. Hops, slides and the die animate in the
|
|
8
|
-
// engine's Rust core; JS steps the turn's clock and the world once a frame.
|
|
9
|
-
import { HapticType } from '../../services/HapticsService';
|
|
10
|
-
import { GAME_SOUNDS } from '../../services/SoundsService';
|
|
11
|
-
import { GAME_IDS } from '../../services/UtilsService';
|
|
12
|
-
import { engineGame, EngineGameScreen } from '../shared/EngineGameScreen';
|
|
13
|
-
import { textColumn } from '../shared/EngineHud';
|
|
14
|
-
import { useEngineGame } from '../shared/useEngineGame';
|
|
15
|
-
import { useLiveState } from '../shared/useLiveState';
|
|
16
|
-
import { AI_COLOR, getLayout, LIGHT, PLAYER_COLOR, RIM } from './SnakesAndLaddersConstants';
|
|
17
|
-
import { createGame, dispose, type GameEvent, reset, setLayout, setTheme, start, tap, tick, type Turn } from './SnakesAndLaddersGame';
|
|
18
|
-
|
|
19
|
-
const SOUNDS = GAME_SOUNDS.SNAKES_AND_LADDERS;
|
|
20
|
-
|
|
21
|
-
/** Each turn event's sound and haptic: the AI's quieter ones skip what only made sense for your own move. */
|
|
22
|
-
const FEEDBACK: Record<GameEvent, { sound?: keyof typeof SOUNDS; haptic?: HapticType; youOnly?: boolean }> = {
|
|
23
|
-
tap: { sound: 'TAP', haptic: HapticType.MEDIUM },
|
|
24
|
-
roll: { sound: 'ROLL' },
|
|
25
|
-
six: { sound: 'SIX', haptic: HapticType.SUCCESS },
|
|
26
|
-
penalty: { sound: 'PENALTY', haptic: HapticType.ERROR },
|
|
27
|
-
cantMove: { sound: 'CANT_MOVE', haptic: HapticType.WARNING, youOnly: true },
|
|
28
|
-
move: { sound: 'MOVE', haptic: HapticType.LIGHT },
|
|
29
|
-
snake: { sound: 'SNAKE', haptic: HapticType.ERROR },
|
|
30
|
-
ladder: { sound: 'LADDER', haptic: HapticType.SUCCESS }
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const SnakesAndLadders = engineGame(GAME_IDS.SNAKES_AND_LADDERS, (props) => {
|
|
34
|
-
const [positions, setPositions] = useLiveState<[number, number]>([0, 0]);
|
|
35
|
-
const [turn, setTurn] = useLiveState<Turn>(0);
|
|
36
|
-
const [score, setScore] = useLiveState(0);
|
|
37
|
-
|
|
38
|
-
// Win or lose when someone reaches 100
|
|
39
|
-
const { status, screen, gameOver } = useEngineGame(props, {
|
|
40
|
-
gameId: GAME_IDS.SNAKES_AND_LADDERS,
|
|
41
|
-
create: createGame,
|
|
42
|
-
start,
|
|
43
|
-
reset,
|
|
44
|
-
dispose,
|
|
45
|
-
tick,
|
|
46
|
-
setTheme,
|
|
47
|
-
resize: (g, width, height, offset) => {
|
|
48
|
-
const l = getLayout(width, height, offset);
|
|
49
|
-
setLayout(g, l);
|
|
50
|
-
return l.size * (1 + RIM * 2);
|
|
51
|
-
},
|
|
52
|
-
tap,
|
|
53
|
-
sounds: SOUNDS,
|
|
54
|
-
onStart: (fx) => fx(SOUNDS.START, HapticType.MEDIUM),
|
|
55
|
-
onOver: (fx, s) => fx(s === 'win' ? SOUNDS.WIN : SOUNDS.GAME_OVER, s === 'win' ? HapticType.SUCCESS : HapticType.HEAVY),
|
|
56
|
-
wire: (g, fx) => {
|
|
57
|
-
g.onPositions = (you, ai) => setPositions([you, ai]);
|
|
58
|
-
g.onScore = setScore;
|
|
59
|
-
g.onTurn = setTurn;
|
|
60
|
-
g.onEvent = (event, who) => {
|
|
61
|
-
const f = FEEDBACK[event];
|
|
62
|
-
if (f.youOnly && who !== 0) return;
|
|
63
|
-
fx(f.sound ? SOUNDS[f.sound] : null, f.haptic);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<EngineGameScreen
|
|
70
|
-
{...screen}
|
|
71
|
-
light={LIGHT}
|
|
72
|
-
columns={[
|
|
73
|
-
textColumn('YOU', String(positions[0]), PLAYER_COLOR),
|
|
74
|
-
textColumn(turn === 0 ? 'YOUR TURN' : 'AI TURN', score.toLocaleString()),
|
|
75
|
-
textColumn('AI', String(positions[1]), AI_COLOR)
|
|
76
|
-
]}
|
|
77
|
-
subtext="Race to 100!"
|
|
78
|
-
gameOver={gameOver({
|
|
79
|
-
title: status === 'win' ? 'YOU WON!' : 'YOU LOST!',
|
|
80
|
-
message: status === 'win' ? 'You reached 100 first!' : 'AI reached 100 first!',
|
|
81
|
-
scoreLabel: status === 'win' ? 'You Won!' : 'You Lost',
|
|
82
|
-
score,
|
|
83
|
-
buttonText: status === 'win' ? 'Play Again!' : 'Try Again!'
|
|
84
|
-
})}
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// Snakes and Ladders' rules, board, timings and layout. The board, rules and scoring match the original
|
|
2
|
-
// version (games/snakes-and-ladders), so scores carry over.
|
|
3
|
-
import { getScoreBoardTop } from '../shared/EngineHud';
|
|
4
|
-
import { project } from '../shared/EngineTilt';
|
|
5
|
-
import { frontLight, gameWidthFor } from '../shared/EngineUtils';
|
|
6
|
-
|
|
7
|
-
// ── Rules ─────────────────────────────────────────────────────────────
|
|
8
|
-
|
|
9
|
-
export const BOARD_SIZE = 10; // 10 x 10 cells
|
|
10
|
-
export const WINNING_POSITION = 100;
|
|
11
|
-
export const MAX_SIXES = 3; // three sixes in a row lose the turn
|
|
12
|
-
|
|
13
|
-
export type SnakeData = { head: number; tail: number; color: string; accent: string; belly: string };
|
|
14
|
-
export type LadderData = { bottom: number; top: number; color: string; highlight: string };
|
|
15
|
-
|
|
16
|
-
/** Head (high) to tail (low): land on a head and slide down. */
|
|
17
|
-
export const SNAKES: readonly SnakeData[] = [
|
|
18
|
-
{ head: 16, tail: 6, color: '#43A047', accent: '#1B5E20', belly: '#C5E1A5' },
|
|
19
|
-
{ head: 47, tail: 26, color: '#E53935', accent: '#8E1B1B', belly: '#FFCDD2' },
|
|
20
|
-
{ head: 49, tail: 11, color: '#8E24AA', accent: '#4A148C', belly: '#E1BEE7' },
|
|
21
|
-
{ head: 62, tail: 19, color: '#F9A825', accent: '#5D4037', belly: '#FFF59D' },
|
|
22
|
-
{ head: 72, tail: 54, color: '#F4511E', accent: '#3E2723', belly: '#FFCCBC' },
|
|
23
|
-
{ head: 87, tail: 24, color: '#5E35B1', accent: '#FBC02D', belly: '#D1C4E9' },
|
|
24
|
-
{ head: 93, tail: 73, color: '#7CB342', accent: '#33691E', belly: '#F0F4C3' },
|
|
25
|
-
{ head: 98, tail: 78, color: '#1E88E5', accent: '#0D47A1', belly: '#BBDEFB' }
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
/** Bottom (low) to top (high): land on a foot and climb. */
|
|
29
|
-
export const LADDERS: readonly LadderData[] = [
|
|
30
|
-
{ bottom: 1, top: 38, color: '#8D5A2B', highlight: '#C08A52' },
|
|
31
|
-
{ bottom: 4, top: 14, color: '#7A4A22', highlight: '#B07A45' },
|
|
32
|
-
{ bottom: 9, top: 31, color: '#8D5A2B', highlight: '#C08A52' },
|
|
33
|
-
{ bottom: 21, top: 42, color: '#7A4A22', highlight: '#B07A45' },
|
|
34
|
-
{ bottom: 28, top: 84, color: '#8D5A2B', highlight: '#C08A52' },
|
|
35
|
-
{ bottom: 36, top: 44, color: '#7A4A22', highlight: '#B07A45' },
|
|
36
|
-
{ bottom: 51, top: 67, color: '#8D5A2B', highlight: '#C08A52' },
|
|
37
|
-
{ bottom: 71, top: 91, color: '#7A4A22', highlight: '#B07A45' },
|
|
38
|
-
{ bottom: 80, top: 99, color: '#8D5A2B', highlight: '#C08A52' }
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
export const SNAKE_AT: ReadonlyMap<number, SnakeData> = new Map(SNAKES.map((s) => [s.head, s]));
|
|
42
|
-
export const LADDER_AT: ReadonlyMap<number, LadderData> = new Map(LADDERS.map((l) => [l.bottom, l]));
|
|
43
|
-
|
|
44
|
-
/** Where a roll from `from` ends: past 100 it doesn't move; a snake or ladder at the landing cell is taken. */
|
|
45
|
-
export function landing(from: number, roll: number) {
|
|
46
|
-
const step = from + roll;
|
|
47
|
-
if (step > WINNING_POSITION) return { step: from, end: from };
|
|
48
|
-
return { step, end: SNAKE_AT.get(step)?.tail ?? LADDER_AT.get(step)?.top ?? step };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** The player's score: 100 a cell, or 10,000 plus 50 for every cell the opponent is short of 100 on a win. */
|
|
52
|
-
export function scoreFor(you: number, opponent: number) {
|
|
53
|
-
return you === WINNING_POSITION ? 10000 + Math.round((WINNING_POSITION - opponent) * 50) : you * 100;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ── Colors ────────────────────────────────────────────────────────────
|
|
57
|
-
|
|
58
|
-
/** Pastel cells, cycling along the diagonals as the original board did. */
|
|
59
|
-
export const CELL_PALETTE = ['#FFF9C4', '#C8E6C9', '#BBDEFB', '#F8BBD0', '#FFE0B2', '#D1C4E9', '#B2EBF2', '#FFCCBC', '#DCEDC8', '#F0F4C3'];
|
|
60
|
-
export const START_CELL = '#E8F5E9';
|
|
61
|
-
export const FINISH_CELL = '#FFF3E0';
|
|
62
|
-
export const NUMBER_COLOR = '#5B4E42';
|
|
63
|
-
export const STAR_NUMBER_COLOR = '#F57F17';
|
|
64
|
-
// The same green (you) and red (the AI) as Ludo King's pawns
|
|
65
|
-
export const PLAYER_COLOR = '#43A047';
|
|
66
|
-
export const AI_COLOR = '#E53935';
|
|
67
|
-
|
|
68
|
-
// ── Timings (seconds, as the original version's turn) ─────────────────────
|
|
69
|
-
|
|
70
|
-
export const ROLL_TIME = 0.9; // the die is tossed and bounces to rest
|
|
71
|
-
export const MOVE_DELAY = 0.4; // after the roll, before the token sets off
|
|
72
|
-
export const HOP_TIME = 0.17; // a cell
|
|
73
|
-
export const SLIDE_PAUSE = 0.15; // on a snake's head or a ladder's foot
|
|
74
|
-
export const NEXT_TURN_DELAY = 0.4;
|
|
75
|
-
export const PENALTY_DELAY = 1;
|
|
76
|
-
export const CANT_MOVE_DELAY = 0.5;
|
|
77
|
-
export const AI_DELAY = 0.8;
|
|
78
|
-
|
|
79
|
-
// ── The scene ─────────────────────────────────────────────────────────
|
|
80
|
-
|
|
81
|
-
/** The camera leans back this far from straight down, so the board's depth, snakes and pawns read as 3D. */
|
|
82
|
-
export const TILT = 0.35;
|
|
83
|
-
/** Lit from the upper left; surfaces facing up off the board (+z) keep their exact color. */
|
|
84
|
-
export const LIGHT = frontLight([-0.35, 0.3, 1], 0.5);
|
|
85
|
-
|
|
86
|
-
/** In board units (the board's playing area is 1 across, centred on the origin, y up the board). */
|
|
87
|
-
export const RIM = 0.014; // a slim wooden frame round the cells
|
|
88
|
-
export const TILE_TOP = 0.013; // height of the cells' top face
|
|
89
|
-
export const DIE_SIZE = 0.15;
|
|
90
|
-
export const DIE_Y = -0.5 - RIM - 0.06 - DIE_SIZE / 2; // the die's place below the board
|
|
91
|
-
export const START_X = -0.33; // the start pad, left of the die
|
|
92
|
-
export const START_Z = 0.01; // the start pad's top, where the pawns wait
|
|
93
|
-
export const TOKEN_HEIGHT = 0.062;
|
|
94
|
-
|
|
95
|
-
// ── Layout (view points) ──────────────────────────────────────────────
|
|
96
|
-
|
|
97
|
-
const SCOREBOARD_HEIGHT = 82;
|
|
98
|
-
const CONTROLS_HEIGHT = 110;
|
|
99
|
-
const TOP_EXTENT = 0.5 + RIM; // the board's far edge, in board units
|
|
100
|
-
const BOTTOM_EXTENT = -DIE_Y + DIE_SIZE * 0.75; // the die's near edge
|
|
101
|
-
|
|
102
|
-
export type Layout = {
|
|
103
|
-
width: number;
|
|
104
|
-
height: number;
|
|
105
|
-
/** Points per board unit. */
|
|
106
|
-
size: number;
|
|
107
|
-
/** Where the board's centre is in the view. */
|
|
108
|
-
centerY: number;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
/** The board as wide as the game area, centred between the scoreboard and the controls, the die below it. */
|
|
112
|
-
export function getLayout(width: number, height: number, offset: number): Layout {
|
|
113
|
-
const cos = Math.cos(TILT);
|
|
114
|
-
const top = getScoreBoardTop(offset) + SCOREBOARD_HEIGHT;
|
|
115
|
-
const room = Math.max(200, height - top - CONTROLS_HEIGHT);
|
|
116
|
-
// The whole board, its frame included, as wide as the other games' boards at most, and small enough
|
|
117
|
-
// that the die below it still clears the controls with the board centred
|
|
118
|
-
const size = Math.min(gameWidthFor(width) / (1 + RIM * 2), room / (2 * Math.max(TOP_EXTENT, BOTTOM_EXTENT) * cos));
|
|
119
|
-
const middle = top + room / 2;
|
|
120
|
-
// The board itself centred between the scoreboard and the controls (the die sits below it)
|
|
121
|
-
return { width, height, size, centerY: middle };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** Where a point on (or `z` above) the board, in board units, appears in the view. */
|
|
125
|
-
export function toView(l: Layout, x: number, y: number, z = 0): [number, number] {
|
|
126
|
-
return project({ width: l.width, height: l.height, centerY: l.centerY, tilt: TILT }, x * l.size, y * l.size, z * l.size);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** A cell's centre in board units: row 1 runs left to right along the bottom, then the rows snake upward. */
|
|
130
|
-
export function cellCenter(cell: number): [number, number] {
|
|
131
|
-
const i = cell - 1;
|
|
132
|
-
const row = Math.floor(i / BOARD_SIZE);
|
|
133
|
-
const along = i % BOARD_SIZE;
|
|
134
|
-
const col = row % 2 === 0 ? along : BOARD_SIZE - 1 - along;
|
|
135
|
-
return [-0.5 + (col + 0.5) / BOARD_SIZE, -0.5 + (row + 0.5) / BOARD_SIZE];
|
|
136
|
-
}
|