@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,280 +0,0 @@
|
|
|
1
|
-
import { type Camera, type Entity, type Vec3, type Voice } from '@nayan-ui/engine';
|
|
2
|
-
// Treasure Hunt: Pure swipe, camera and footstep helpers used by the engine tick.
|
|
3
|
-
import { HUMAN_CAMERA_HEIGHT, type HumanAnimation, MOVEMENT_START, MOVEMENT_STOP, type Point } from './TreasureHuntConstants';
|
|
4
|
-
import { caveAt, groundHeight, type NatureInput, type NatureMap, solidClearance, toLocal } from './TreasureHuntRules';
|
|
5
|
-
|
|
6
|
-
// Swipe input.
|
|
7
|
-
|
|
8
|
-
export interface SwipeContact {
|
|
9
|
-
identifier: number | string;
|
|
10
|
-
pageX: number;
|
|
11
|
-
pageY: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface TapContact {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
time: number;
|
|
18
|
-
dragged: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface SwipeInput {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
filtered: { x: number; y: number };
|
|
25
|
-
filterActive: boolean;
|
|
26
|
-
touchId: SwipeContact['identifier'] | null;
|
|
27
|
-
startX: number;
|
|
28
|
-
startY: number;
|
|
29
|
-
contacts: Map<SwipeContact['identifier'], TapContact>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const DEAD_ZONE = 8;
|
|
33
|
-
|
|
34
|
-
const RUN_DISTANCE = 80;
|
|
35
|
-
|
|
36
|
-
const TAP_DURATION = 280;
|
|
37
|
-
|
|
38
|
-
const INPUT_RESPONSE = 0.035;
|
|
39
|
-
|
|
40
|
-
export const createSwipeInput = (): SwipeInput => ({
|
|
41
|
-
x: 0,
|
|
42
|
-
y: 0,
|
|
43
|
-
filtered: { x: 0, y: 0 },
|
|
44
|
-
filterActive: false,
|
|
45
|
-
touchId: null,
|
|
46
|
-
startX: 0,
|
|
47
|
-
startY: 0,
|
|
48
|
-
contacts: new Map()
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
function stopMovement(input: SwipeInput) {
|
|
52
|
-
input.x = input.y = 0;
|
|
53
|
-
input.filtered.x = input.filtered.y = 0;
|
|
54
|
-
input.filterActive = false;
|
|
55
|
-
input.touchId = null;
|
|
56
|
-
input.startX = input.startY = 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function resetSwipe(input: SwipeInput) {
|
|
60
|
-
stopMovement(input);
|
|
61
|
-
input.contacts.clear();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function startSwipe(input: SwipeInput, touch: SwipeContact, time = 0) {
|
|
65
|
-
if (!Number.isFinite(touch.pageX + touch.pageY) || input.contacts.has(touch.identifier)) return;
|
|
66
|
-
input.contacts.set(touch.identifier, { x: touch.pageX, y: touch.pageY, time, dragged: false });
|
|
67
|
-
if (input.touchId !== null) return;
|
|
68
|
-
input.touchId = touch.identifier;
|
|
69
|
-
input.startX = touch.pageX;
|
|
70
|
-
input.startY = touch.pageY;
|
|
71
|
-
input.x = input.y = 0;
|
|
72
|
-
input.filtered.x = input.filtered.y = 0;
|
|
73
|
-
input.filterActive = false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function moveSwipe(input: SwipeInput, touch: SwipeContact) {
|
|
77
|
-
const contact = input.contacts.get(touch.identifier);
|
|
78
|
-
if (contact && Math.hypot(touch.pageX - contact.x, touch.pageY - contact.y) > DEAD_ZONE) contact.dragged = true;
|
|
79
|
-
if (input.touchId === null || input.touchId !== touch.identifier) return;
|
|
80
|
-
const dx = touch.pageX - input.startX,
|
|
81
|
-
dy = touch.pageY - input.startY,
|
|
82
|
-
distance = Math.hypot(dx, dy);
|
|
83
|
-
if (!Number.isFinite(distance) || distance <= DEAD_ZONE) {
|
|
84
|
-
input.x = input.y = 0;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
// Follow an overshooting finger so a long drag does not trap the control origin far behind it.
|
|
88
|
-
if (distance > RUN_DISTANCE) {
|
|
89
|
-
input.startX = touch.pageX - (dx / distance) * RUN_DISTANCE;
|
|
90
|
-
input.startY = touch.pageY - (dy / distance) * RUN_DISTANCE;
|
|
91
|
-
}
|
|
92
|
-
const amount = Math.min(1, (distance - DEAD_ZONE) / (RUN_DISTANCE - DEAD_ZONE));
|
|
93
|
-
const strength = amount * amount * (3 - 2 * amount);
|
|
94
|
-
input.x = (dx / distance) * strength;
|
|
95
|
-
input.y = (-dy / distance) * strength;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Sample once per engine frame: touch delivery frequency cannot introduce steering steps. */
|
|
99
|
-
export function sampleSwipe(input: SwipeInput, elapsed: number): { x: number; y: number } {
|
|
100
|
-
if (input.touchId === null) {
|
|
101
|
-
input.filtered.x = input.filtered.y = 0;
|
|
102
|
-
input.filterActive = false;
|
|
103
|
-
return input.filtered;
|
|
104
|
-
}
|
|
105
|
-
const dt = Math.max(0, Math.min(0.05, elapsed)),
|
|
106
|
-
blend = 1 - Math.exp(-dt / INPUT_RESPONSE);
|
|
107
|
-
input.filtered.x += (input.x - input.filtered.x) * blend;
|
|
108
|
-
input.filtered.y += (input.y - input.filtered.y) * blend;
|
|
109
|
-
const strength = Math.hypot(input.filtered.x, input.filtered.y);
|
|
110
|
-
if (strength >= MOVEMENT_START) input.filterActive = true;
|
|
111
|
-
else if (strength < MOVEMENT_STOP) input.filterActive = false;
|
|
112
|
-
return input.filterActive ? input.filtered : STILL;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const STILL = { x: 0, y: 0 };
|
|
116
|
-
|
|
117
|
-
/** A swipe, long hold or cancelled gesture never becomes a punch when the finger lifts. */
|
|
118
|
-
export function endSwipe(input: SwipeInput, touch: SwipeContact, time = 0): boolean {
|
|
119
|
-
const contact = input.contacts.get(touch.identifier);
|
|
120
|
-
const elapsed = contact ? time - contact.time : Infinity;
|
|
121
|
-
const tapped =
|
|
122
|
-
!!contact &&
|
|
123
|
-
!contact.dragged &&
|
|
124
|
-
elapsed >= 0 &&
|
|
125
|
-
elapsed <= TAP_DURATION &&
|
|
126
|
-
Math.hypot(touch.pageX - contact.x, touch.pageY - contact.y) <= DEAD_ZONE;
|
|
127
|
-
input.contacts.delete(touch.identifier);
|
|
128
|
-
if (touch.identifier === input.touchId) stopMovement(input);
|
|
129
|
-
return tapped;
|
|
130
|
-
}
|
|
131
|
-
// Rear camera and explorer-relative movement.
|
|
132
|
-
|
|
133
|
-
export const FOLLOW_OFFSET: Vec3 = [0, 0.8, 4.1];
|
|
134
|
-
|
|
135
|
-
const HEAD_HEIGHT = HUMAN_CAMERA_HEIGHT;
|
|
136
|
-
|
|
137
|
-
export function createNatureCamera(target: Entity, spawn: Point, yaw = 0, map?: NatureMap): Camera {
|
|
138
|
-
const camera: Camera = { eye: [0, 0, 0], target: [0, 0, 0], fov: 0.95, follow: { target, offset: FOLLOW_OFFSET, smoothing: 0.045 } };
|
|
139
|
-
resetNatureCamera(camera, spawn, yaw, map);
|
|
140
|
-
return camera;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/** Stay behind the facing direction, lift over rising ground and pull in under cave roofs. */
|
|
144
|
-
export function updateNatureCamera(camera: Camera, yaw: number, map?: NatureMap, player?: Point, dt = 0) {
|
|
145
|
-
if (!camera.follow) return;
|
|
146
|
-
const backX = -Math.sin(yaw),
|
|
147
|
-
backZ = -Math.cos(yaw);
|
|
148
|
-
let distance = FOLLOW_OFFSET[2],
|
|
149
|
-
lift = FOLLOW_OFFSET[1];
|
|
150
|
-
if (map && player) {
|
|
151
|
-
const floor = groundHeight(map, player.x, player.z),
|
|
152
|
-
cave = caveAt(map, player.x, player.z);
|
|
153
|
-
if (cave) lift = 0.65;
|
|
154
|
-
for (; distance >= 1.5; distance -= 0.25) {
|
|
155
|
-
let clear = true,
|
|
156
|
-
requiredLift = lift;
|
|
157
|
-
for (let sample = 1; sample <= 12; sample++) {
|
|
158
|
-
const t = sample / 12,
|
|
159
|
-
x = player.x + backX * distance * t,
|
|
160
|
-
z = player.z + backZ * distance * t;
|
|
161
|
-
requiredLift = Math.max(requiredLift, (groundHeight(map, x, z) + 0.6 - floor - HEAD_HEIGHT) / t);
|
|
162
|
-
const local = toLocal(map, x, z);
|
|
163
|
-
for (const tunnel of map.landscape.caves) {
|
|
164
|
-
const dx = Math.abs(local.x - tunnel.x);
|
|
165
|
-
const within = dx < 5.8 && Math.abs(local.z - tunnel.z) <= tunnel.length / 2 + 0.1;
|
|
166
|
-
const eyeY = floor + HEAD_HEIGHT + lift * t;
|
|
167
|
-
if (within && eyeY < tunnel.y + 7 && (dx > 2.8 || eyeY > tunnel.y + 4.7 * Math.sqrt(Math.max(0, 1 - (dx / 3.5) ** 2)) - 0.35))
|
|
168
|
-
clear = false;
|
|
169
|
-
}
|
|
170
|
-
const eyeY = floor + HEAD_HEIGHT + lift * t;
|
|
171
|
-
if (solidClearance(map.obstacleCells, x, z, 0.35, eyeY - 0.35, eyeY + 0.35) < 0) clear = false;
|
|
172
|
-
}
|
|
173
|
-
if (cave && requiredLift > lift + 0.1) clear = false;
|
|
174
|
-
if (clear) {
|
|
175
|
-
lift = Math.min(5, requiredLift);
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (dt > 0) {
|
|
181
|
-
const previous = camera.follow.offset,
|
|
182
|
-
previousDistance = Math.hypot(previous[0], previous[2]);
|
|
183
|
-
const response = distance < previousDistance ? 0.055 : 0.2;
|
|
184
|
-
distance = previousDistance + (distance - previousDistance) * (1 - Math.exp(-dt / response));
|
|
185
|
-
lift = previous[1] + (lift - previous[1]) * (1 - Math.exp(-dt / 0.12));
|
|
186
|
-
if (map && player) {
|
|
187
|
-
const floor = groundHeight(map, player.x, player.z);
|
|
188
|
-
lift = Math.max(lift, groundHeight(map, player.x + backX * distance, player.z + backZ * distance) + 0.35 - floor - HEAD_HEIGHT);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
camera.follow.offset = [backX * distance, lift, backZ * distance];
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export function resetNatureCamera(camera: Camera, spawn: Point, yaw = 0, map?: NatureMap) {
|
|
195
|
-
updateNatureCamera(camera, yaw, map, spawn);
|
|
196
|
-
const y = (map ? groundHeight(map, spawn.x, spawn.z) : 0) + HEAD_HEIGHT;
|
|
197
|
-
const offset = camera.follow?.offset ?? FOLLOW_OFFSET;
|
|
198
|
-
camera.target = [spawn.x, y, spawn.z];
|
|
199
|
-
camera.eye = [spawn.x + offset[0], y + offset[1], spawn.z + offset[2]];
|
|
200
|
-
camera.shake = 0;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export interface MovementReference {
|
|
204
|
-
active: boolean;
|
|
205
|
-
yaw: number;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Use the explorer's facing when a swipe gesture begins. Holding a direction keeps a steady world
|
|
210
|
-
* heading while the camera turns behind the explorer; recalculating against the rotating view every
|
|
211
|
-
* frame would turn a held sideways input into an endless spin. Ending the swipe rebases the next gesture to the explorer.
|
|
212
|
-
*/
|
|
213
|
-
export function explorerRelativeInput(input: NatureInput, explorerYaw: number, reference: MovementReference): NatureInput {
|
|
214
|
-
if (Math.hypot(input.x, input.y) <= MOVEMENT_STOP) {
|
|
215
|
-
reference.active = false;
|
|
216
|
-
return input;
|
|
217
|
-
}
|
|
218
|
-
if (!reference.active) {
|
|
219
|
-
reference.yaw = explorerYaw;
|
|
220
|
-
reference.active = true;
|
|
221
|
-
}
|
|
222
|
-
const sin = Math.sin(reference.yaw);
|
|
223
|
-
const cos = Math.cos(reference.yaw);
|
|
224
|
-
// The imported explorer faces +Z; his right is local -X (also screen-right from behind).
|
|
225
|
-
return { ...input, x: -cos * input.x + sin * input.y, y: -sin * input.x - cos * input.y };
|
|
226
|
-
}
|
|
227
|
-
// Footstep cadence.
|
|
228
|
-
|
|
229
|
-
type FootstepSound = 'footstepWalk' | 'footstepRun';
|
|
230
|
-
|
|
231
|
-
interface FootstepPlayback {
|
|
232
|
-
play: (name: FootstepSound, options: { volume: number; pitch: number; pan: number }) => Voice | null;
|
|
233
|
-
stop: (voice: Voice | null) => void;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
interface FootstepMotion {
|
|
237
|
-
animation: HumanAnimation | null;
|
|
238
|
-
from: number;
|
|
239
|
-
to: number;
|
|
240
|
-
speed: number;
|
|
241
|
-
audible: boolean;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Heel/forefoot landings in the imported CMU gait cycles, rather than an independent timer.
|
|
245
|
-
const CONTACTS = { walk: [0.44, 0.94], run: [0.22, 0.72] } as const;
|
|
246
|
-
|
|
247
|
-
/** One short native voice per landing. No timers, loop gaps or delayed playback after stopping. */
|
|
248
|
-
export function createFootsteps(playback: FootstepPlayback) {
|
|
249
|
-
let voice: Voice | null = null;
|
|
250
|
-
let cooldown = 0;
|
|
251
|
-
let variation = 0;
|
|
252
|
-
const stop = () => {
|
|
253
|
-
playback.stop(voice);
|
|
254
|
-
voice = null;
|
|
255
|
-
cooldown = 0;
|
|
256
|
-
};
|
|
257
|
-
return {
|
|
258
|
-
stop,
|
|
259
|
-
update(motion: FootstepMotion, dt: number) {
|
|
260
|
-
cooldown = Math.max(0, cooldown - Math.max(0, Math.min(0.05, dt)));
|
|
261
|
-
const { animation, from, to, speed, audible } = motion;
|
|
262
|
-
if (!audible || speed < 0.15 || (animation !== 'walk' && animation !== 'run')) {
|
|
263
|
-
stop();
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
if (from === to || cooldown > 0) return;
|
|
267
|
-
const contact = CONTACTS[animation].findIndex((phase) => (from < to ? phase > from && phase <= to : phase > from || phase <= to));
|
|
268
|
-
if (contact < 0) return;
|
|
269
|
-
playback.stop(voice);
|
|
270
|
-
const running = animation === 'run';
|
|
271
|
-
voice = playback.play(running ? 'footstepRun' : 'footstepWalk', {
|
|
272
|
-
volume: (running ? 0.5 : 0.35) * Math.min(1, speed / (running ? 4 : 1.6)),
|
|
273
|
-
pitch: [0.97, 1.02, 1, 1.04][variation++ % 4]!,
|
|
274
|
-
pan: contact === 0 ? -0.06 : 0.06
|
|
275
|
-
});
|
|
276
|
-
// Avoid double impacts when switching gaits near a landing.
|
|
277
|
-
cooldown = 0.17;
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
}
|
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
import { audio, type Camera, effects, type Entity, haptics, warmUpEngine, World } from '@nayan-ui/engine';
|
|
2
|
-
import { playBankSound } from '../../services/SoundsService';
|
|
3
|
-
import { popAndBurst } from '../shared/EngineBlasts';
|
|
4
|
-
// Treasure Hunt: Run lifecycle, engine updates and gameplay feedback.
|
|
5
|
-
import {
|
|
6
|
-
ATTACK_COOLDOWN,
|
|
7
|
-
type GameAssets,
|
|
8
|
-
HUMAN_CAMERA_HEIGHT,
|
|
9
|
-
HUMAN_CLIP_TIME,
|
|
10
|
-
HUMAN_GUARD_TIME,
|
|
11
|
-
locomotionAnimation,
|
|
12
|
-
MAX_HEALTH,
|
|
13
|
-
sounds
|
|
14
|
-
} from './TreasureHuntConstants';
|
|
15
|
-
import {
|
|
16
|
-
createFootsteps,
|
|
17
|
-
createNatureCamera,
|
|
18
|
-
createSwipeInput,
|
|
19
|
-
explorerRelativeInput,
|
|
20
|
-
type MovementReference,
|
|
21
|
-
resetNatureCamera,
|
|
22
|
-
resetSwipe,
|
|
23
|
-
sampleSwipe,
|
|
24
|
-
type SwipeInput,
|
|
25
|
-
updateNatureCamera
|
|
26
|
-
} from './TreasureHuntControls';
|
|
27
|
-
import { advanceHuman, type Human, placeHuman, playHuman, resetHuman, spawnHuman } from './TreasureHuntModel';
|
|
28
|
-
import { createState, groundHeight, type NatureEvent, type NatureInput, type NatureState, peekNextMap, step, warmNextMap } from './TreasureHuntRules';
|
|
29
|
-
import {
|
|
30
|
-
animateNature,
|
|
31
|
-
type NatureVisual,
|
|
32
|
-
placeRobot,
|
|
33
|
-
type RobotVisual,
|
|
34
|
-
spawnGem,
|
|
35
|
-
spawnNature,
|
|
36
|
-
spawnRobot,
|
|
37
|
-
warmMapScenery
|
|
38
|
-
} from './TreasureHuntScene';
|
|
39
|
-
|
|
40
|
-
// Run lifecycle and engine updates.
|
|
41
|
-
|
|
42
|
-
export interface NatureGame {
|
|
43
|
-
readonly phase: 'ready' | 'playing' | 'over';
|
|
44
|
-
readonly score: number;
|
|
45
|
-
readonly won: boolean;
|
|
46
|
-
onPhase: (phase: 'ready' | 'playing' | 'over') => void;
|
|
47
|
-
world: World;
|
|
48
|
-
assets: GameAssets;
|
|
49
|
-
camera: Camera;
|
|
50
|
-
movementReference: MovementReference;
|
|
51
|
-
nature: NatureVisual;
|
|
52
|
-
state: NatureState;
|
|
53
|
-
human: Human;
|
|
54
|
-
footsteps: ReturnType<typeof createFootsteps>;
|
|
55
|
-
swipe: SwipeInput;
|
|
56
|
-
attackBuffer: number;
|
|
57
|
-
enemies: Map<number, RobotVisual>;
|
|
58
|
-
gems: Map<number, Entity>;
|
|
59
|
-
animationTime: number;
|
|
60
|
-
combatTime: number;
|
|
61
|
-
hudTime: number;
|
|
62
|
-
nextRun: Iterator<() => void> | null;
|
|
63
|
-
preparing: boolean;
|
|
64
|
-
prepareDelay: number;
|
|
65
|
-
onChange: () => void;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function createGame(assets: GameAssets): NatureGame {
|
|
69
|
-
warmUpEngine();
|
|
70
|
-
const world = new World(6500);
|
|
71
|
-
try {
|
|
72
|
-
const state = createState();
|
|
73
|
-
const nature = spawnNature(world, state.map, assets);
|
|
74
|
-
const human = spawnHuman(world, [state.player.x, groundHeight(state.map, state.player.x, state.player.z), state.player.z], assets.human);
|
|
75
|
-
const cameraTarget = world.spawn({ mesh: 'none', parent: human.root, position: [0, HUMAN_CAMERA_HEIGHT, 0], pickable: false });
|
|
76
|
-
const game: NatureGame = {
|
|
77
|
-
get phase() {
|
|
78
|
-
return this.state.phase === 'ready' ? 'ready' : this.state.phase === 'won' || this.state.phase === 'lost' ? 'over' : 'playing';
|
|
79
|
-
},
|
|
80
|
-
get score() {
|
|
81
|
-
return this.state.score;
|
|
82
|
-
},
|
|
83
|
-
get won() {
|
|
84
|
-
return this.state.phase === 'won';
|
|
85
|
-
},
|
|
86
|
-
onPhase: () => {},
|
|
87
|
-
world,
|
|
88
|
-
assets,
|
|
89
|
-
camera: createNatureCamera(cameraTarget, state.player, state.yaw, state.map),
|
|
90
|
-
movementReference: { active: false, yaw: state.yaw },
|
|
91
|
-
nature,
|
|
92
|
-
state,
|
|
93
|
-
human,
|
|
94
|
-
footsteps: createFootsteps({ play: (name, options) => playBankSound(sounds, name, options) ?? null, stop: (voice) => audio.stop(voice) }),
|
|
95
|
-
swipe: createSwipeInput(),
|
|
96
|
-
attackBuffer: 0,
|
|
97
|
-
enemies: new Map(),
|
|
98
|
-
gems: new Map(),
|
|
99
|
-
animationTime: 0,
|
|
100
|
-
combatTime: 0,
|
|
101
|
-
hudTime: 0,
|
|
102
|
-
nextRun: null,
|
|
103
|
-
preparing: false,
|
|
104
|
-
prepareDelay: 0.3,
|
|
105
|
-
onChange: () => {}
|
|
106
|
-
};
|
|
107
|
-
rebuildActors(game);
|
|
108
|
-
game.nextRun = warmNextRun()[Symbol.iterator]();
|
|
109
|
-
return game;
|
|
110
|
-
} catch (error) {
|
|
111
|
-
world.dispose();
|
|
112
|
-
throw error;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function rebuildActors(game: NatureGame) {
|
|
117
|
-
clearInput(game);
|
|
118
|
-
game.footsteps.stop();
|
|
119
|
-
for (const robot of game.enemies.values()) game.world.despawn(robot.root);
|
|
120
|
-
for (const gem of game.gems.values()) game.world.despawn(gem);
|
|
121
|
-
game.enemies.clear();
|
|
122
|
-
game.gems.clear();
|
|
123
|
-
for (const enemy of game.state.enemies)
|
|
124
|
-
game.enemies.set(enemy.id, spawnRobot(game.world, enemy.x, groundHeight(game.state.map, enemy.x, enemy.z), enemy.z));
|
|
125
|
-
syncGems(game);
|
|
126
|
-
resetHuman(game.world, game.human);
|
|
127
|
-
placeHuman(game.world, game.human, game.state.map, game.state.player, game.state.yaw);
|
|
128
|
-
game.animationTime = 0;
|
|
129
|
-
game.combatTime = 0;
|
|
130
|
-
game.movementReference.active = false;
|
|
131
|
-
resetNatureCamera(game.camera, game.state.player, game.state.yaw, game.state.map);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function syncGems(game: NatureGame) {
|
|
135
|
-
for (const gem of game.state.pickups)
|
|
136
|
-
if (!gem.taken && !game.gems.has(gem.id)) game.gems.set(gem.id, spawnGem(game.world, gem.x, groundHeight(game.state.map, gem.x, gem.z), gem.z));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function start(game: NatureGame) {
|
|
140
|
-
if (game.world.isDisposed || game.preparing || game.state.phase !== 'ready') return;
|
|
141
|
-
game.state.phase = 'playing';
|
|
142
|
-
game.prepareDelay = 0.3;
|
|
143
|
-
clearInput(game);
|
|
144
|
-
game.onPhase('playing');
|
|
145
|
-
game.onChange();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function reset(game: NatureGame) {
|
|
149
|
-
if (game.world.isDisposed || game.preparing) return;
|
|
150
|
-
// Report/controls change immediately. A rapid Stop must never finish a cold terrain factory
|
|
151
|
-
// on the input callback; the existing frame loop finishes preparation behind the game loader.
|
|
152
|
-
clearInput(game);
|
|
153
|
-
game.footsteps.stop();
|
|
154
|
-
resetHuman(game.world, game.human);
|
|
155
|
-
if (!game.nextRun && !peekNextMap()) game.nextRun = warmNextRun()[Symbol.iterator]();
|
|
156
|
-
game.preparing = true;
|
|
157
|
-
game.prepareDelay = 0;
|
|
158
|
-
game.state.phase = 'ready';
|
|
159
|
-
game.state.score = game.state.gems = game.state.defeated = 0;
|
|
160
|
-
game.state.health = MAX_HEALTH;
|
|
161
|
-
game.onPhase('ready');
|
|
162
|
-
game.onChange();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function commitReset(game: NatureGame) {
|
|
166
|
-
game.nextRun?.return?.();
|
|
167
|
-
game.nextRun = null;
|
|
168
|
-
game.state = createState();
|
|
169
|
-
game.world.despawn(game.nature.root);
|
|
170
|
-
game.nature = spawnNature(game.world, game.state.map, game.assets);
|
|
171
|
-
rebuildActors(game);
|
|
172
|
-
game.hudTime = 0;
|
|
173
|
-
game.preparing = false;
|
|
174
|
-
game.prepareDelay = 0.3;
|
|
175
|
-
game.nextRun = warmNextRun()[Symbol.iterator]();
|
|
176
|
-
game.onPhase('ready');
|
|
177
|
-
game.onChange();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** Advance one preparation batch per existing engine frame, including the idle Start screen. */
|
|
181
|
-
function* warmNextRun(): Iterable<() => void> {
|
|
182
|
-
yield* warmNextMap();
|
|
183
|
-
const map = peekNextMap();
|
|
184
|
-
if (map) yield* warmMapScenery(map);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function prepareNextRun(game: NatureGame, dt: number) {
|
|
188
|
-
if (!game.nextRun || dt <= 0) return;
|
|
189
|
-
game.prepareDelay = Math.max(0, game.prepareDelay - dt);
|
|
190
|
-
if (game.prepareDelay > 0) return;
|
|
191
|
-
const deadline = performance.now() + 4;
|
|
192
|
-
for (let jobs = 0; jobs < 32 && game.nextRun; jobs++) {
|
|
193
|
-
const task = game.nextRun.next();
|
|
194
|
-
if (task.done) {
|
|
195
|
-
game.nextRun = null;
|
|
196
|
-
if (game.preparing) commitReset(game);
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
task.value();
|
|
200
|
-
if (performance.now() >= deadline) break;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function feedback(game: NatureGame, event: NatureEvent) {
|
|
205
|
-
const { world, human } = game;
|
|
206
|
-
const y = groundHeight(game.state.map, event.x, event.z);
|
|
207
|
-
const position = [event.x, y + 0.9, event.z] as const;
|
|
208
|
-
switch (event.kind) {
|
|
209
|
-
case 'attack': {
|
|
210
|
-
const ready =
|
|
211
|
-
human.animation === 'combatIdle' || human.animation === 'punchStart' || human.animation === 'punchRight' || human.animation === 'punchLeft';
|
|
212
|
-
if (!ready) human.strikes = 0;
|
|
213
|
-
const animation = !ready ? 'punchStart' : human.strikes % 2 === 0 ? 'punchRight' : 'punchLeft';
|
|
214
|
-
human.strikes++;
|
|
215
|
-
playHuman(world, human, animation);
|
|
216
|
-
game.combatTime = HUMAN_GUARD_TIME;
|
|
217
|
-
game.animationTime = HUMAN_CLIP_TIME.punchRight;
|
|
218
|
-
playBankSound(sounds, 'punch', { volume: 0.35, pitch: 1.2 });
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
case 'hit':
|
|
222
|
-
case 'defeated': {
|
|
223
|
-
playBankSound(sounds, event.kind === 'defeated' ? 'defeat' : 'impact', { volume: 0.5 });
|
|
224
|
-
const towardX = game.state.player.x - event.x,
|
|
225
|
-
towardZ = game.state.player.z - event.z;
|
|
226
|
-
const length = Math.hypot(towardX, towardZ) || 1;
|
|
227
|
-
effects.sparks(world, {
|
|
228
|
-
position: [event.x + (towardX / length) * 0.2, y + 1.45, event.z + (towardZ / length) * 0.2],
|
|
229
|
-
colors: [
|
|
230
|
-
[1.8, 0.65, 0.4, 1],
|
|
231
|
-
[1, 1.5, 2, 1]
|
|
232
|
-
],
|
|
233
|
-
count: 12,
|
|
234
|
-
size: 0.1,
|
|
235
|
-
speed: 4,
|
|
236
|
-
lifetime: 0.3
|
|
237
|
-
});
|
|
238
|
-
haptics.impact(event.kind === 'defeated' ? 0.8 : 0.45);
|
|
239
|
-
if (event.kind === 'defeated' && event.id !== undefined) {
|
|
240
|
-
const robot = game.enemies.get(event.id);
|
|
241
|
-
if (robot) {
|
|
242
|
-
game.enemies.delete(event.id);
|
|
243
|
-
void popAndBurst(
|
|
244
|
-
world,
|
|
245
|
-
robot.root,
|
|
246
|
-
{ scale: 1, color: [1, 0.4, 0.48, 1], duration: 0.3 },
|
|
247
|
-
{ position, size: 1.2, color: [1, 0.4, 0.48, 1] }
|
|
248
|
-
).then(() => world.despawn(robot.root));
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
case 'gem': {
|
|
254
|
-
const gem = event.id === undefined ? undefined : game.gems.get(event.id);
|
|
255
|
-
if (gem !== undefined) {
|
|
256
|
-
// Keep a shrinking pickup in the map until it is despawned, so reset also cleans it up.
|
|
257
|
-
void popAndBurst(
|
|
258
|
-
world,
|
|
259
|
-
gem,
|
|
260
|
-
{ scale: 0.7, color: [0.92, 1.02, 1.12, 1], duration: 0.2 },
|
|
261
|
-
{ position, size: 0.6, color: [0.92, 1.02, 1.12, 1], count: 7 }
|
|
262
|
-
).then(() => {
|
|
263
|
-
world.despawn(gem);
|
|
264
|
-
if (game.gems.get(event.id!) === gem) game.gems.delete(event.id!);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
playBankSound(sounds, 'gem', { volume: 0.55 });
|
|
268
|
-
haptics.selection();
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
case 'hurt':
|
|
272
|
-
playHuman(world, human, 'hit');
|
|
273
|
-
game.animationTime = HUMAN_CLIP_TIME.hit;
|
|
274
|
-
game.camera.shake = 0.25;
|
|
275
|
-
playBankSound(sounds, 'hurt', { volume: 0.5 });
|
|
276
|
-
haptics.impact(0.9);
|
|
277
|
-
break;
|
|
278
|
-
case 'won':
|
|
279
|
-
game.state.yaw = 0;
|
|
280
|
-
playHuman(world, human, 'celebrate');
|
|
281
|
-
effects.confetti(world, {
|
|
282
|
-
position: [event.x, y + 2, event.z],
|
|
283
|
-
colors: [
|
|
284
|
-
[0.4, 1.5, 1.8, 1],
|
|
285
|
-
[1.8, 1.2, 0.3, 1],
|
|
286
|
-
[1.5, 0.4, 0.8, 1]
|
|
287
|
-
],
|
|
288
|
-
size: 0.17,
|
|
289
|
-
speed: 6,
|
|
290
|
-
count: 60,
|
|
291
|
-
lifetime: 2,
|
|
292
|
-
gravity: -3
|
|
293
|
-
});
|
|
294
|
-
playBankSound(sounds, 'win');
|
|
295
|
-
haptics.notify('success');
|
|
296
|
-
game.onPhase('over');
|
|
297
|
-
break;
|
|
298
|
-
case 'lost':
|
|
299
|
-
playHuman(world, human, 'fall');
|
|
300
|
-
haptics.notify('error');
|
|
301
|
-
game.onPhase('over');
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export function clearInput(game: NatureGame) {
|
|
307
|
-
resetSwipe(game.swipe);
|
|
308
|
-
game.attackBuffer = 0;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export function punch(game: NatureGame) {
|
|
312
|
-
if (game.state.phase === 'playing') game.attackBuffer = ATTACK_COOLDOWN + 0.1;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/** Shared screen frame callback: sample gestures and consume at most one buffered punch. */
|
|
316
|
-
export function update(game: NatureGame, dt: number) {
|
|
317
|
-
const elapsed = Math.max(0, Math.min(0.05, dt));
|
|
318
|
-
const buffered = game.attackBuffer > 0;
|
|
319
|
-
const canPunch = elapsed > 0 && game.state.phase === 'playing' && game.state.attackCooldown <= elapsed;
|
|
320
|
-
const movement = sampleSwipe(game.swipe, elapsed);
|
|
321
|
-
tick(game, { x: movement.x, y: movement.y, attack: buffered }, dt);
|
|
322
|
-
game.attackBuffer = buffered && canPunch ? 0 : Math.max(0, game.attackBuffer - elapsed);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/** Called exclusively by GameView, which also suspends frames on AppState changes. */
|
|
326
|
-
export function tick(game: NatureGame, input: NatureInput, elapsed: number) {
|
|
327
|
-
if (game.world.isDisposed) return;
|
|
328
|
-
const dt = Math.min(0.05, Math.max(0, elapsed));
|
|
329
|
-
if (game.preparing) {
|
|
330
|
-
game.world.update(0);
|
|
331
|
-
if (!game.nextRun && dt > 0) commitReset(game);
|
|
332
|
-
else prepareNextRun(game, dt);
|
|
333
|
-
if (!game.preparing) game.world.update(0);
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
const events = step(game.state, explorerRelativeInput(input, game.state.yaw, game.movementReference), dt);
|
|
337
|
-
const { state, world } = game;
|
|
338
|
-
for (const event of events) feedback(game, event);
|
|
339
|
-
updateNatureCamera(game.camera, state.yaw, state.map, state.player, dt);
|
|
340
|
-
syncGems(game);
|
|
341
|
-
game.animationTime = Math.max(0, game.animationTime - dt);
|
|
342
|
-
game.combatTime = Math.max(0, game.combatTime - dt);
|
|
343
|
-
if (state.phase === 'playing' && game.animationTime === 0) {
|
|
344
|
-
if (game.combatTime > 0 && state.speed < 0.05) playHuman(world, game.human, 'combatIdle');
|
|
345
|
-
else if (game.human.animation === 'combatIdle' && state.speed < 0.05) {
|
|
346
|
-
playHuman(world, game.human, 'combatExit');
|
|
347
|
-
game.animationTime = HUMAN_CLIP_TIME.combatExit;
|
|
348
|
-
game.human.strikes = 0;
|
|
349
|
-
} else {
|
|
350
|
-
const animation = locomotionAnimation(state.speed, game.human.animation);
|
|
351
|
-
playHuman(world, game.human, animation, animation === 'run' ? state.speed / 4 : animation === 'walk' ? state.speed / 1.6 : 1);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
const updates = world.transforms;
|
|
355
|
-
placeHuman(world, game.human, state.map, state.player, state.yaw, dt, updates);
|
|
356
|
-
for (const enemy of state.enemies) {
|
|
357
|
-
const visual = game.enemies.get(enemy.id);
|
|
358
|
-
if (visual)
|
|
359
|
-
placeRobot(
|
|
360
|
-
world,
|
|
361
|
-
visual,
|
|
362
|
-
enemy.x,
|
|
363
|
-
enemy.z,
|
|
364
|
-
groundHeight(state.map, enemy.x, enemy.z),
|
|
365
|
-
enemy.yaw,
|
|
366
|
-
enemy.windup,
|
|
367
|
-
enemy.stagger,
|
|
368
|
-
enemy.moving,
|
|
369
|
-
state.time,
|
|
370
|
-
updates
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
updates.flush();
|
|
374
|
-
animateNature(world, game.nature, dt);
|
|
375
|
-
const previousPhase = game.human.phase;
|
|
376
|
-
world.update(dt);
|
|
377
|
-
advanceHuman(game.human, dt);
|
|
378
|
-
game.footsteps.update(
|
|
379
|
-
{
|
|
380
|
-
animation: game.human.animation,
|
|
381
|
-
from: previousPhase,
|
|
382
|
-
to: game.human.phase,
|
|
383
|
-
speed: state.speed,
|
|
384
|
-
audible: state.phase === 'playing' && !audio.muted
|
|
385
|
-
},
|
|
386
|
-
dt
|
|
387
|
-
);
|
|
388
|
-
game.hudTime += dt;
|
|
389
|
-
if (events.length || game.hudTime >= 0.12) {
|
|
390
|
-
game.hudTime = 0;
|
|
391
|
-
game.onChange();
|
|
392
|
-
}
|
|
393
|
-
prepareNextRun(game, dt);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
export function dispose(game: NatureGame) {
|
|
397
|
-
clearInput(game);
|
|
398
|
-
game.nextRun?.return?.();
|
|
399
|
-
game.nextRun = null;
|
|
400
|
-
game.footsteps.stop();
|
|
401
|
-
game.world.dispose();
|
|
402
|
-
}
|