react-native-games 1.1.0 → 1.3.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/README.md +101 -30
- package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -167
- package/lib/module/games/balloon-blaster/BalloonBlaster.js.map +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js +1 -182
- package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js.map +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterService.js +1 -318
- package/lib/module/games/balloon-blaster/BalloonBlasterStore.js +1 -183
- package/lib/module/games/balloon-blaster/components/BalloonComponent.js +1 -237
- package/lib/module/games/balloon-blaster/components/GameArea.js +1 -156
- package/lib/module/games/balloon-blaster/components/GameBackground.js +1 -476
- package/lib/module/games/balloon-blaster/components/ScoreBoard.js +1 -112
- package/lib/module/games/balloon-blaster/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/balloon-blaster/components/index.js +1 -7
- package/lib/module/games/bike-racing/BikeRacing.js +1 -0
- package/lib/module/games/bike-racing/BikeRacing.js.map +1 -0
- package/lib/module/games/bike-racing/BikeRacingConstants.js +1 -0
- package/lib/module/games/bike-racing/BikeRacingConstants.js.map +1 -0
- package/lib/module/games/bike-racing/BikeRacingService.js +1 -0
- package/lib/module/games/bike-racing/BikeRacingService.js.map +1 -0
- package/lib/module/games/bike-racing/BikeRacingStore.js +1 -0
- package/lib/module/games/bike-racing/BikeRacingStore.js.map +1 -0
- package/lib/module/games/bike-racing/components/BikeComponent.js +1 -0
- package/lib/module/games/bike-racing/components/BikeComponent.js.map +1 -0
- package/lib/module/games/bike-racing/components/GameBackground.js +1 -0
- package/lib/module/games/bike-racing/components/GameBackground.js.map +1 -0
- package/lib/module/games/bike-racing/components/ScoreBoard.js +1 -0
- package/lib/module/games/bike-racing/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/bike-racing/components/index.js +1 -0
- package/lib/module/games/bike-racing/components/index.js.map +1 -0
- package/lib/module/games/bike-racing/index.js +1 -0
- package/lib/module/games/bike-racing/index.js.map +1 -0
- package/lib/module/games/block-blast/BlockBlast.js +1 -0
- package/lib/module/games/block-blast/BlockBlast.js.map +1 -0
- package/lib/module/games/block-blast/BlockBlastConstants.js +1 -0
- package/lib/module/games/block-blast/BlockBlastConstants.js.map +1 -0
- package/lib/module/games/block-blast/BlockBlastService.js +1 -0
- package/lib/module/games/block-blast/BlockBlastService.js.map +1 -0
- package/lib/module/games/block-blast/BlockBlastStore.js +1 -0
- package/lib/module/games/block-blast/BlockBlastStore.js.map +1 -0
- package/lib/module/games/block-blast/components/BlockPieceComponent.js +1 -0
- package/lib/module/games/block-blast/components/BlockPieceComponent.js.map +1 -0
- package/lib/module/games/block-blast/components/GameArea.js +1 -0
- package/lib/module/games/block-blast/components/GameArea.js.map +1 -0
- package/lib/module/games/block-blast/components/GameBackground.js +1 -0
- package/lib/module/games/block-blast/components/GameBackground.js.map +1 -0
- package/lib/module/games/block-blast/components/GridComponent.js +1 -0
- package/lib/module/games/block-blast/components/GridComponent.js.map +1 -0
- package/lib/module/games/block-blast/components/ScoreBoard.js +1 -0
- package/lib/module/games/block-blast/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/block-blast/components/index.js +1 -0
- package/lib/module/games/block-blast/components/index.js.map +1 -0
- package/lib/module/games/block-blast/index.js +1 -0
- package/lib/module/games/block-blast/index.js.map +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooter.js +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooter.js.map +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooterConstants.js +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooterConstants.js.map +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooterService.js +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooterService.js.map +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooterStore.js +1 -0
- package/lib/module/games/bubble-shooter/BubbleShooterStore.js.map +1 -0
- package/lib/module/games/bubble-shooter/components/GameArea.js +1 -0
- package/lib/module/games/bubble-shooter/components/GameArea.js.map +1 -0
- package/lib/module/games/bubble-shooter/components/GameBackground.js +1 -0
- package/lib/module/games/bubble-shooter/components/GameBackground.js.map +1 -0
- package/lib/module/games/bubble-shooter/components/ScoreBoard.js +1 -0
- package/lib/module/games/bubble-shooter/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/bubble-shooter/components/index.js +1 -0
- package/lib/module/games/bubble-shooter/components/index.js.map +1 -0
- package/lib/module/games/bubble-shooter/index.js +1 -0
- package/lib/module/games/bubble-shooter/index.js.map +1 -0
- package/lib/module/games/candy-crush/CandyCrush.js +1 -131
- package/lib/module/games/candy-crush/CandyCrush.js.map +1 -1
- package/lib/module/games/candy-crush/CandyCrushConstants.js +1 -125
- package/lib/module/games/candy-crush/CandyCrushConstants.js.map +1 -1
- package/lib/module/games/candy-crush/CandyCrushService.js +1 -370
- package/lib/module/games/candy-crush/CandyCrushStore.js +1 -303
- package/lib/module/games/candy-crush/components/CandyItem.js +1 -191
- package/lib/module/games/candy-crush/components/GameBackground.js +1 -85
- package/lib/module/games/candy-crush/components/GameGrid.js +1 -314
- package/lib/module/games/candy-crush/components/ScoreBoard.js +1 -79
- package/lib/module/games/candy-crush/components/index.js +1 -7
- package/lib/module/games/candy-crush/index.js +1 -6
- package/lib/module/games/car-racing/CarRacing.js +1 -0
- package/lib/module/games/car-racing/CarRacing.js.map +1 -0
- package/lib/module/games/car-racing/CarRacingConstants.js +1 -0
- package/lib/module/games/car-racing/CarRacingConstants.js.map +1 -0
- package/lib/module/games/car-racing/CarRacingService.js +1 -0
- package/lib/module/games/car-racing/CarRacingService.js.map +1 -0
- package/lib/module/games/car-racing/CarRacingStore.js +1 -0
- package/lib/module/games/car-racing/CarRacingStore.js.map +1 -0
- package/lib/module/games/car-racing/components/CarComponent.js +1 -0
- package/lib/module/games/car-racing/components/CarComponent.js.map +1 -0
- package/lib/module/games/car-racing/components/GameBackground.js +1 -0
- package/lib/module/games/car-racing/components/GameBackground.js.map +1 -0
- package/lib/module/games/car-racing/components/ScoreBoard.js +1 -0
- package/lib/module/games/car-racing/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/car-racing/components/index.js +1 -0
- package/lib/module/games/car-racing/components/index.js.map +1 -0
- package/lib/module/games/colors-sort/ColorsSort.js +1 -143
- package/lib/module/games/colors-sort/ColorsSort.js.map +1 -1
- package/lib/module/games/colors-sort/ColorsSortConstants.js +1 -72
- package/lib/module/games/colors-sort/ColorsSortConstants.js.map +1 -1
- package/lib/module/games/colors-sort/ColorsSortService.js +1 -255
- package/lib/module/games/colors-sort/ColorsSortStore.js +1 -257
- package/lib/module/games/colors-sort/ColorsSortStore.js.map +1 -1
- package/lib/module/games/colors-sort/components/ColorContainer.js +1 -140
- package/lib/module/games/colors-sort/components/GameBackground.js +1 -135
- package/lib/module/games/colors-sort/components/ScoreBoard.js +1 -70
- package/lib/module/games/colors-sort/components/index.js +1 -6
- package/lib/module/games/dino-jump/DinoJump.js +1 -209
- package/lib/module/games/dino-jump/DinoJump.js.map +1 -1
- package/lib/module/games/dino-jump/DinoJumpConstants.js +1 -189
- package/lib/module/games/dino-jump/DinoJumpConstants.js.map +1 -1
- package/lib/module/games/dino-jump/DinoJumpService.js +1 -270
- package/lib/module/games/dino-jump/DinoJumpStore.js +1 -381
- package/lib/module/games/dino-jump/components/DinoSprite.js +1 -418
- package/lib/module/games/dino-jump/components/DinoSprite.js.map +1 -1
- package/lib/module/games/dino-jump/components/GameArea.js +1 -68
- package/lib/module/games/dino-jump/components/GameBackground.js +1 -444
- package/lib/module/games/dino-jump/components/ObstacleSprite.js +1 -306
- package/lib/module/games/dino-jump/components/ScoreBoard.js +1 -105
- package/lib/module/games/dino-jump/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/dino-jump/components/StarSprite.js +1 -45
- package/lib/module/games/dino-jump/components/index.js +1 -9
- package/lib/module/games/flappy-bird/FlappyBird.js +1 -126
- package/lib/module/games/flappy-bird/FlappyBird.js.map +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js +1 -90
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js.map +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdStore.js +1 -300
- package/lib/module/games/flappy-bird/components/Bird.js +1 -87
- package/lib/module/games/flappy-bird/components/GameArea.js +1 -87
- package/lib/module/games/flappy-bird/components/GameBackground.js +1 -79
- package/lib/module/games/flappy-bird/components/Pipes.js +1 -172
- package/lib/module/games/flappy-bird/components/ScoreBoard.js +1 -73
- package/lib/module/games/flappy-bird/components/index.js +1 -8
- package/lib/module/games/fruit-merger/FruitMerger.js +1 -120
- package/lib/module/games/fruit-merger/FruitMerger.js.map +1 -1
- package/lib/module/games/fruit-merger/FruitMergerConstants.js +1 -119
- package/lib/module/games/fruit-merger/FruitMergerConstants.js.map +1 -1
- package/lib/module/games/fruit-merger/FruitMergerService.js +1 -13
- package/lib/module/games/fruit-merger/FruitMergerStore.js +1 -315
- package/lib/module/games/fruit-merger/components/FruitItem.js +1 -102
- package/lib/module/games/fruit-merger/components/GameArea.js +1 -103
- package/lib/module/games/fruit-merger/components/GameBackground.js +1 -498
- package/lib/module/games/fruit-merger/components/ScoreBoard.js +1 -58
- package/lib/module/games/fruit-merger/components/index.js +1 -7
- package/lib/module/games/fruit-ninja/FruitNinja.js +1 -134
- package/lib/module/games/fruit-ninja/FruitNinja.js.map +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaConstants.js +1 -148
- package/lib/module/games/fruit-ninja/FruitNinjaConstants.js.map +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaService.js +1 -311
- package/lib/module/games/fruit-ninja/FruitNinjaStore.js +1 -191
- package/lib/module/games/fruit-ninja/FruitNinjaStore.js.map +1 -1
- package/lib/module/games/fruit-ninja/components/FruitComponent.js +1 -99
- package/lib/module/games/fruit-ninja/components/GameArea.js +1 -215
- package/lib/module/games/fruit-ninja/components/GameBackground.js +1 -1267
- package/lib/module/games/fruit-ninja/components/ScoreBoard.js +1 -92
- package/lib/module/games/fruit-ninja/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/fruit-ninja/components/index.js +1 -7
- package/lib/module/games/game-2048/Game2048.js +1 -149
- package/lib/module/games/game-2048/Game2048.js.map +1 -1
- package/lib/module/games/game-2048/Game2048Constants.js +1 -263
- package/lib/module/games/game-2048/Game2048Constants.js.map +1 -1
- package/lib/module/games/game-2048/Game2048Service.js +1 -457
- package/lib/module/games/game-2048/Game2048Store.js +1 -236
- package/lib/module/games/game-2048/components/GameBackground.js +1 -247
- package/lib/module/games/game-2048/components/GameGrid.js +1 -139
- package/lib/module/games/game-2048/components/GameTile.js +1 -72
- package/lib/module/games/game-2048/components/ScoreBoard.js +1 -52
- package/lib/module/games/game-2048/components/index.js +1 -7
- package/lib/module/games/maze-runner/MazeRunner.js +1 -267
- package/lib/module/games/maze-runner/MazeRunner.js.map +1 -1
- package/lib/module/games/maze-runner/MazeRunnerConstants.js +1 -100
- package/lib/module/games/maze-runner/MazeRunnerConstants.js.map +1 -1
- package/lib/module/games/maze-runner/MazeRunnerService.js +1 -586
- package/lib/module/games/maze-runner/components/EnhancedBallComponent.js +1 -150
- package/lib/module/games/maze-runner/components/EnhancedGameArea.js +1 -370
- package/lib/module/games/maze-runner/components/GameBackground.js +1 -175
- package/lib/module/games/maze-runner/components/ScoreBoard.js +1 -61
- package/lib/module/games/maze-runner/components/SkiaPipeComponent.js +1 -209
- package/lib/module/games/maze-runner/components/StaticGameBackground.js +1 -169
- package/lib/module/games/maze-runner/components/WallComponent.js +1 -91
- package/lib/module/games/maze-runner/components/index.js +1 -8
- package/lib/module/games/perfect-circle/PerfectCircle.js +1 -0
- package/lib/module/games/perfect-circle/PerfectCircle.js.map +1 -0
- package/lib/module/games/perfect-circle/PerfectCircleConstants.js +1 -0
- package/lib/module/games/perfect-circle/PerfectCircleConstants.js.map +1 -0
- package/lib/module/games/perfect-circle/PerfectCircleService.js +1 -0
- package/lib/module/games/perfect-circle/PerfectCircleService.js.map +1 -0
- package/lib/module/games/perfect-circle/PerfectCircleStore.js +1 -0
- package/lib/module/games/perfect-circle/PerfectCircleStore.js.map +1 -0
- package/lib/module/games/perfect-circle/components/DrawingCanvas.js +1 -0
- package/lib/module/games/perfect-circle/components/DrawingCanvas.js.map +1 -0
- package/lib/module/games/perfect-circle/components/GameBackground.js +1 -0
- package/lib/module/games/perfect-circle/components/GameBackground.js.map +1 -0
- package/lib/module/games/perfect-circle/components/ScoreBoard.js +1 -0
- package/lib/module/games/perfect-circle/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/perfect-circle/index.js +1 -0
- package/lib/module/games/perfect-circle/index.js.map +1 -0
- package/lib/module/games/popit-fidget/PopitFidget.js +1 -285
- package/lib/module/games/popit-fidget/PopitFidget.js.map +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetConstants.js +1 -113
- package/lib/module/games/popit-fidget/PopitFidgetConstants.js.map +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetService.js +1 -132
- package/lib/module/games/popit-fidget/PopitFidgetStore.js +1 -125
- package/lib/module/games/popit-fidget/components/BubbleComponent.js +1 -198
- package/lib/module/games/popit-fidget/components/FidgetGrid.js +1 -165
- package/lib/module/games/popit-fidget/components/GameBackground.js +1 -177
- package/lib/module/games/popit-fidget/components/ScoreBoard.js +1 -61
- package/lib/module/games/popit-fidget/components/index.js +1 -7
- package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -159
- package/lib/module/games/sliding-numbers/SlidingNumbers.js.map +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js +1 -207
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js.map +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersService.js +1 -248
- package/lib/module/games/sliding-numbers/SlidingNumbersStore.js +1 -274
- package/lib/module/games/sliding-numbers/components/GameBackground.js +1 -259
- package/lib/module/games/sliding-numbers/components/NumbersGrid.js +1 -174
- package/lib/module/games/sliding-numbers/components/NumbersTile.js +1 -116
- package/lib/module/games/sliding-numbers/components/ScoreBoard.js +1 -64
- package/lib/module/games/sliding-numbers/components/index.js +1 -7
- package/lib/module/games/snake/Snake.js +1 -189
- package/lib/module/games/snake/Snake.js.map +1 -1
- package/lib/module/games/snake/SnakeConstants.js +1 -138
- package/lib/module/games/snake/SnakeConstants.js.map +1 -1
- package/lib/module/games/snake/SnakeService.js +1 -148
- package/lib/module/games/snake/SnakeStore.js +1 -182
- package/lib/module/games/snake/SnakeStore.js.map +1 -1
- package/lib/module/games/snake/components/GameBackground.js +1 -221
- package/lib/module/games/snake/components/GameGrid.js +1 -153
- package/lib/module/games/snake/components/ScoreBoard.js +1 -51
- package/lib/module/games/snake/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/snake/components/index.js +1 -6
- package/lib/module/games/snake/index.js +1 -6
- package/lib/module/games/space-fighter/SpaceFighter.js +1 -165
- package/lib/module/games/space-fighter/SpaceFighter.js.map +1 -1
- package/lib/module/games/space-fighter/SpaceFighterConstants.js +1 -108
- package/lib/module/games/space-fighter/SpaceFighterConstants.js.map +1 -1
- package/lib/module/games/space-fighter/SpaceFighterService.js +1 -326
- package/lib/module/games/space-fighter/SpaceFighterStore.js +1 -209
- package/lib/module/games/space-fighter/components/AsteroidComponent.js +1 -113
- package/lib/module/games/space-fighter/components/GameArea.js +1 -289
- package/lib/module/games/space-fighter/components/GameBackground.js +1 -239
- package/lib/module/games/space-fighter/components/ScoreBoard.js +1 -136
- package/lib/module/games/space-fighter/components/Spacecraft3D.js +1 -202
- package/lib/module/games/space-fighter/components/SpacecraftPath.js +1 -52
- package/lib/module/games/space-fighter/components/index.js +1 -9
- package/lib/module/games/whack-a-mole/WhackAMole.js +1 -270
- package/lib/module/games/whack-a-mole/WhackAMole.js.map +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleConstants.js +1 -115
- package/lib/module/games/whack-a-mole/WhackAMoleConstants.js.map +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleService.js +1 -120
- package/lib/module/games/whack-a-mole/WhackAMoleStore.js +1 -172
- package/lib/module/games/whack-a-mole/components/GameBackground.js +1 -477
- package/lib/module/games/whack-a-mole/components/GameGrid.js +1 -97
- package/lib/module/games/whack-a-mole/components/GameHole.js +1 -196
- package/lib/module/games/whack-a-mole/components/MoleCharacter.js +1 -241
- package/lib/module/games/whack-a-mole/components/ScoreBoard.js +1 -67
- package/lib/module/games/whack-a-mole/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/whack-a-mole/components/index.js +1 -8
- package/lib/module/helpers/AnimationFrame.js +1 -120
- package/lib/module/helpers/AnimationTracker.js +1 -89
- package/lib/module/helpers/ErrorHandler.js +1 -269
- package/lib/module/helpers/GameControlButton.js +1 -219
- package/lib/module/helpers/GameOverModal.js +1 -144
- package/lib/module/helpers/GameOverModal.js.map +1 -1
- package/lib/module/helpers/GameSettingsModal.js +1 -287
- package/lib/module/helpers/GameSettingsModal.js.map +1 -1
- package/lib/module/helpers/ParticleBlast.js +1 -134
- package/lib/module/helpers/ScoreBoardContainer.js +1 -34
- package/lib/module/helpers/ScoreBoardContainer.js.map +1 -1
- package/lib/module/helpers/index.js +1 -12
- package/lib/module/index.js +1 -22
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/GamesConstants.js +1 -178
- package/lib/module/services/GamesConstants.js.map +1 -1
- package/lib/module/services/GamesService.js +1 -112
- package/lib/module/services/GamesService.js.map +1 -1
- package/lib/module/services/HapticsService.js +1 -77
- package/lib/module/services/ScoringService.js +1 -0
- package/lib/module/services/ScoringService.js.map +1 -0
- package/lib/module/services/SoundsService.js +1 -302
- package/lib/module/services/SoundsService.js.map +1 -1
- package/lib/module/services/UtilsService.js +1 -32
- package/lib/module/services/UtilsService.js.map +1 -1
- package/lib/typescript/src/games/balloon-blaster/BalloonBlaster.d.ts.map +1 -1
- package/lib/typescript/src/games/balloon-blaster/BalloonBlasterConstants.d.ts +1 -1
- package/lib/typescript/src/games/balloon-blaster/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/games/bike-racing/BikeRacing.d.ts +4 -0
- package/lib/typescript/src/games/bike-racing/BikeRacing.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/BikeRacingConstants.d.ts +76 -0
- package/lib/typescript/src/games/bike-racing/BikeRacingConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/BikeRacingService.d.ts +22 -0
- package/lib/typescript/src/games/bike-racing/BikeRacingService.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/BikeRacingStore.d.ts +72 -0
- package/lib/typescript/src/games/bike-racing/BikeRacingStore.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/components/BikeComponent.d.ts +12 -0
- package/lib/typescript/src/games/bike-racing/components/BikeComponent.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/components/GameBackground.d.ts +9 -0
- package/lib/typescript/src/games/bike-racing/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/components/ScoreBoard.d.ts +7 -0
- package/lib/typescript/src/games/bike-racing/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/components/index.d.ts +4 -0
- package/lib/typescript/src/games/bike-racing/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/bike-racing/index.d.ts +5 -0
- package/lib/typescript/src/games/bike-racing/index.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/BlockBlast.d.ts +4 -0
- package/lib/typescript/src/games/block-blast/BlockBlast.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/BlockBlastConstants.d.ts +82 -0
- package/lib/typescript/src/games/block-blast/BlockBlastConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/BlockBlastService.d.ts +17 -0
- package/lib/typescript/src/games/block-blast/BlockBlastService.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/BlockBlastStore.d.ts +62 -0
- package/lib/typescript/src/games/block-blast/BlockBlastStore.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/components/BlockPieceComponent.d.ts +14 -0
- package/lib/typescript/src/games/block-blast/components/BlockPieceComponent.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/components/GameArea.d.ts +12 -0
- package/lib/typescript/src/games/block-blast/components/GameArea.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/components/GameBackground.d.ts +7 -0
- package/lib/typescript/src/games/block-blast/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/components/GridComponent.d.ts +17 -0
- package/lib/typescript/src/games/block-blast/components/GridComponent.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/components/ScoreBoard.d.ts +7 -0
- package/lib/typescript/src/games/block-blast/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/components/index.d.ts +6 -0
- package/lib/typescript/src/games/block-blast/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/block-blast/index.d.ts +5 -0
- package/lib/typescript/src/games/block-blast/index.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooter.d.ts +4 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooter.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooterConstants.d.ts +61 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooterConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooterService.d.ts +26 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooterService.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooterStore.d.ts +62 -0
- package/lib/typescript/src/games/bubble-shooter/BubbleShooterStore.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/components/GameArea.d.ts +9 -0
- package/lib/typescript/src/games/bubble-shooter/components/GameArea.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/components/GameBackground.d.ts +8 -0
- package/lib/typescript/src/games/bubble-shooter/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/components/ScoreBoard.d.ts +7 -0
- package/lib/typescript/src/games/bubble-shooter/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/components/index.d.ts +4 -0
- package/lib/typescript/src/games/bubble-shooter/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/bubble-shooter/index.d.ts +3 -0
- package/lib/typescript/src/games/bubble-shooter/index.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/CandyCrush.d.ts.map +1 -1
- package/lib/typescript/src/games/candy-crush/CandyCrushConstants.d.ts +7 -7
- package/lib/typescript/src/games/car-racing/CarRacing.d.ts +4 -0
- package/lib/typescript/src/games/car-racing/CarRacing.d.ts.map +1 -0
- package/lib/typescript/src/games/car-racing/CarRacingConstants.d.ts +76 -0
- package/lib/typescript/src/games/car-racing/CarRacingConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/car-racing/CarRacingService.d.ts +22 -0
- package/lib/typescript/src/games/car-racing/CarRacingService.d.ts.map +1 -0
- package/lib/typescript/src/games/car-racing/CarRacingStore.d.ts +72 -0
- package/lib/typescript/src/games/car-racing/CarRacingStore.d.ts.map +1 -0
- package/lib/typescript/src/games/car-racing/components/CarComponent.d.ts +13 -0
- package/lib/typescript/src/games/car-racing/components/CarComponent.d.ts.map +1 -0
- package/lib/typescript/src/games/car-racing/components/GameBackground.d.ts +9 -0
- package/lib/typescript/src/games/car-racing/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/car-racing/components/ScoreBoard.d.ts +7 -0
- package/lib/typescript/src/games/car-racing/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/car-racing/components/index.d.ts +4 -0
- package/lib/typescript/src/games/car-racing/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/colors-sort/ColorsSort.d.ts.map +1 -1
- package/lib/typescript/src/games/colors-sort/ColorsSortStore.d.ts.map +1 -1
- package/lib/typescript/src/games/dino-jump/DinoJump.d.ts.map +1 -1
- package/lib/typescript/src/games/dino-jump/components/DinoSprite.d.ts.map +1 -1
- package/lib/typescript/src/games/flappy-bird/FlappyBird.d.ts.map +1 -1
- package/lib/typescript/src/games/flappy-bird/FlappyBirdConstants.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-merger/FruitMerger.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-merger/FruitMergerConstants.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-ninja/FruitNinja.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-ninja/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/games/game-2048/Game2048.d.ts.map +1 -1
- package/lib/typescript/src/games/maze-runner/MazeRunner.d.ts.map +1 -1
- package/lib/typescript/src/games/perfect-circle/PerfectCircle.d.ts +4 -0
- package/lib/typescript/src/games/perfect-circle/PerfectCircle.d.ts.map +1 -0
- package/lib/typescript/src/games/perfect-circle/PerfectCircleConstants.d.ts +81 -0
- package/lib/typescript/src/games/perfect-circle/PerfectCircleConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/perfect-circle/PerfectCircleService.d.ts +14 -0
- package/lib/typescript/src/games/perfect-circle/PerfectCircleService.d.ts.map +1 -0
- package/lib/typescript/src/games/perfect-circle/PerfectCircleStore.d.ts +40 -0
- package/lib/typescript/src/games/perfect-circle/PerfectCircleStore.d.ts.map +1 -0
- package/lib/typescript/src/games/perfect-circle/components/DrawingCanvas.d.ts +9 -0
- package/lib/typescript/src/games/perfect-circle/components/DrawingCanvas.d.ts.map +1 -0
- package/lib/typescript/src/games/perfect-circle/components/GameBackground.d.ts +8 -0
- package/lib/typescript/src/games/perfect-circle/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/perfect-circle/components/ScoreBoard.d.ts +7 -0
- package/lib/typescript/src/games/perfect-circle/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/perfect-circle/index.d.ts +3 -0
- package/lib/typescript/src/games/perfect-circle/index.d.ts.map +1 -0
- package/lib/typescript/src/games/popit-fidget/PopitFidget.d.ts.map +1 -1
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbers.d.ts.map +1 -1
- package/lib/typescript/src/games/snake/Snake.d.ts.map +1 -1
- package/lib/typescript/src/games/snake/SnakeStore.d.ts +4 -0
- package/lib/typescript/src/games/snake/SnakeStore.d.ts.map +1 -1
- package/lib/typescript/src/games/snake/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/games/space-fighter/SpaceFighter.d.ts.map +1 -1
- package/lib/typescript/src/games/whack-a-mole/WhackAMole.d.ts.map +1 -1
- package/lib/typescript/src/games/whack-a-mole/WhackAMoleConstants.d.ts +1 -1
- package/lib/typescript/src/games/whack-a-mole/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/helpers/GameOverModal.d.ts +3 -0
- package/lib/typescript/src/helpers/GameOverModal.d.ts.map +1 -1
- package/lib/typescript/src/helpers/ScoreBoardContainer.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/services/GamesConstants.d.ts +57 -7
- package/lib/typescript/src/services/GamesConstants.d.ts.map +1 -1
- package/lib/typescript/src/services/GamesService.d.ts +2 -1
- package/lib/typescript/src/services/GamesService.d.ts.map +1 -1
- package/lib/typescript/src/services/ScoringService.d.ts +2 -0
- package/lib/typescript/src/services/ScoringService.d.ts.map +1 -0
- package/lib/typescript/src/services/SoundsService.d.ts +88 -0
- package/lib/typescript/src/services/SoundsService.d.ts.map +1 -1
- package/lib/typescript/src/services/UtilsService.d.ts +12 -1
- package/lib/typescript/src/services/UtilsService.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,209 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { create } from 'zustand';
|
|
4
|
-
import { subscribeWithSelector } from 'zustand/middleware';
|
|
5
|
-
import { Dimensions } from 'react-native';
|
|
6
|
-
import { GAME_CONFIG } from "./SpaceFighterService.js";
|
|
7
|
-
import { immerMiddleware } from "../../services/UtilsService.js";
|
|
8
|
-
const {
|
|
9
|
-
width,
|
|
10
|
-
height
|
|
11
|
-
} = Dimensions.get('window');
|
|
12
|
-
|
|
13
|
-
// Helper function to get spacecraft Y position based on offset
|
|
14
|
-
const getSpacecraftYPosition = (offset = 0) => {
|
|
15
|
-
const yPercent = offset > 0 ? 0.77 : 0.68;
|
|
16
|
-
return height * yPercent;
|
|
17
|
-
};
|
|
18
|
-
// Optimized store with selective subscriptions for low-end devices
|
|
19
|
-
export const useSpaceFighterStore = create()(subscribeWithSelector(immerMiddleware((set, _get) => ({
|
|
20
|
-
// Initial state
|
|
21
|
-
score: 0,
|
|
22
|
-
timeLeft: 60,
|
|
23
|
-
// Fixed 60 seconds regardless of difficulty
|
|
24
|
-
isPlaying: false,
|
|
25
|
-
gameOver: false,
|
|
26
|
-
lives: 3,
|
|
27
|
-
asteroids: [],
|
|
28
|
-
spacecraft: {
|
|
29
|
-
x: width / 2,
|
|
30
|
-
// Center horizontally
|
|
31
|
-
y: getSpacecraftYPosition(0),
|
|
32
|
-
// Dynamic position based on offset
|
|
33
|
-
velocityX: 0,
|
|
34
|
-
velocityY: 0,
|
|
35
|
-
size: GAME_CONFIG.SPACECRAFT_SIZE,
|
|
36
|
-
isControlled: false
|
|
37
|
-
},
|
|
38
|
-
spacecraftPath: [],
|
|
39
|
-
isControllingSpacecraft: false,
|
|
40
|
-
offset: 0,
|
|
41
|
-
// Actions
|
|
42
|
-
setOffset: offset => {
|
|
43
|
-
set(draft => {
|
|
44
|
-
draft.offset = offset;
|
|
45
|
-
// Update spacecraft Y position when offset changes
|
|
46
|
-
draft.spacecraft.y = getSpacecraftYPosition(offset);
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
startGame: _gameDuration => {
|
|
50
|
-
// Always use fixed duration regardless of difficulty or passed duration
|
|
51
|
-
const duration = 60;
|
|
52
|
-
set(draft => {
|
|
53
|
-
draft.score = 0;
|
|
54
|
-
draft.timeLeft = duration;
|
|
55
|
-
draft.isPlaying = true;
|
|
56
|
-
draft.gameOver = false;
|
|
57
|
-
draft.lives = 3;
|
|
58
|
-
draft.asteroids = [];
|
|
59
|
-
draft.spacecraftPath = [];
|
|
60
|
-
draft.isControllingSpacecraft = false;
|
|
61
|
-
// Reset spacecraft to initial position
|
|
62
|
-
draft.spacecraft = {
|
|
63
|
-
x: width / 2,
|
|
64
|
-
// Center horizontally
|
|
65
|
-
y: getSpacecraftYPosition(draft.offset),
|
|
66
|
-
// Dynamic position based on offset
|
|
67
|
-
velocityX: 0,
|
|
68
|
-
velocityY: 0,
|
|
69
|
-
size: GAME_CONFIG.SPACECRAFT_SIZE,
|
|
70
|
-
isControlled: false
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
stopGame: () => {
|
|
75
|
-
set(draft => {
|
|
76
|
-
draft.score = 0;
|
|
77
|
-
draft.timeLeft = 60; // Fixed 60 seconds
|
|
78
|
-
draft.isPlaying = false;
|
|
79
|
-
draft.gameOver = false;
|
|
80
|
-
draft.lives = 3;
|
|
81
|
-
draft.asteroids = [];
|
|
82
|
-
draft.spacecraftPath = [];
|
|
83
|
-
draft.isControllingSpacecraft = false;
|
|
84
|
-
// Reset spacecraft to initial position
|
|
85
|
-
draft.spacecraft = {
|
|
86
|
-
x: width / 2,
|
|
87
|
-
// Center horizontally
|
|
88
|
-
y: getSpacecraftYPosition(draft.offset),
|
|
89
|
-
// Dynamic position based on offset
|
|
90
|
-
velocityX: 0,
|
|
91
|
-
velocityY: 0,
|
|
92
|
-
size: GAME_CONFIG.SPACECRAFT_SIZE,
|
|
93
|
-
isControlled: false
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
resetGame: () => {
|
|
98
|
-
set(draft => {
|
|
99
|
-
draft.score = 0;
|
|
100
|
-
draft.timeLeft = 60; // Fixed 60 seconds
|
|
101
|
-
draft.isPlaying = false;
|
|
102
|
-
draft.gameOver = false;
|
|
103
|
-
draft.lives = 3;
|
|
104
|
-
draft.asteroids = [];
|
|
105
|
-
draft.spacecraftPath = [];
|
|
106
|
-
draft.isControllingSpacecraft = false;
|
|
107
|
-
// Reset spacecraft to initial position
|
|
108
|
-
draft.spacecraft = {
|
|
109
|
-
x: width / 2,
|
|
110
|
-
// Center horizontally
|
|
111
|
-
y: getSpacecraftYPosition(draft.offset),
|
|
112
|
-
// Dynamic position based on offset
|
|
113
|
-
velocityX: 0,
|
|
114
|
-
velocityY: 0,
|
|
115
|
-
size: GAME_CONFIG.SPACECRAFT_SIZE,
|
|
116
|
-
isControlled: false
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
updateScore: points => {
|
|
121
|
-
set(draft => {
|
|
122
|
-
draft.score = draft.score + points;
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
decrementTime: () => {
|
|
126
|
-
set(draft => {
|
|
127
|
-
const newTimeLeft = draft.timeLeft - 1;
|
|
128
|
-
if (newTimeLeft <= 0) {
|
|
129
|
-
draft.timeLeft = 0;
|
|
130
|
-
draft.isPlaying = false;
|
|
131
|
-
draft.gameOver = true;
|
|
132
|
-
} else {
|
|
133
|
-
draft.timeLeft = newTimeLeft;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
addAsteroids: asteroids => {
|
|
138
|
-
set(draft => {
|
|
139
|
-
draft.asteroids.push(...asteroids);
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
removeAsteroid: asteroidId => {
|
|
143
|
-
set(draft => {
|
|
144
|
-
draft.asteroids = draft.asteroids.filter(a => a.id !== asteroidId);
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
updateAsteroid: (asteroidId, updates) => {
|
|
148
|
-
set(draft => {
|
|
149
|
-
// Optimized: Use for-loop instead of find for better performance
|
|
150
|
-
for (let i = 0; i < draft.asteroids.length; i++) {
|
|
151
|
-
if (draft.asteroids[i].id === asteroidId) {
|
|
152
|
-
Object.assign(draft.asteroids[i], updates);
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
},
|
|
158
|
-
updateSpacecraft: spacecraft => {
|
|
159
|
-
set(draft => {
|
|
160
|
-
draft.spacecraft = spacecraft;
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
setSpacecraftPath: path => {
|
|
164
|
-
set(draft => {
|
|
165
|
-
draft.spacecraftPath = path;
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
setIsControllingSpacecraft: isControlling => {
|
|
169
|
-
set(draft => {
|
|
170
|
-
draft.isControllingSpacecraft = isControlling;
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
markAsteroidPassed: pairId => {
|
|
174
|
-
set(draft => {
|
|
175
|
-
// Optimized: Use for-loop instead of forEach for better performance
|
|
176
|
-
for (let i = 0; i < draft.asteroids.length; i++) {
|
|
177
|
-
if (draft.asteroids[i].pairId === pairId) {
|
|
178
|
-
draft.asteroids[i].passed = true;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
draft.score = draft.score + 10; // 10 points per asteroid pair passed
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
|
-
loseLife: () => {
|
|
185
|
-
set(draft => {
|
|
186
|
-
const newLives = draft.lives - 1;
|
|
187
|
-
|
|
188
|
-
// Reset spacecraft to initial position after collision
|
|
189
|
-
draft.spacecraft = {
|
|
190
|
-
x: width / 2,
|
|
191
|
-
// Center horizontally
|
|
192
|
-
y: getSpacecraftYPosition(draft.offset),
|
|
193
|
-
// Dynamic position based on offset
|
|
194
|
-
velocityX: 0,
|
|
195
|
-
velocityY: 0,
|
|
196
|
-
size: GAME_CONFIG.SPACECRAFT_SIZE,
|
|
197
|
-
isControlled: false
|
|
198
|
-
};
|
|
199
|
-
if (newLives <= 0) {
|
|
200
|
-
draft.lives = 0;
|
|
201
|
-
draft.isPlaying = false;
|
|
202
|
-
draft.gameOver = true;
|
|
203
|
-
} else {
|
|
204
|
-
draft.lives = newLives;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}))));
|
|
209
|
-
//# sourceMappingURL=SpaceFighterStore.js.map
|
|
1
|
+
"use strict";import{create}from 'zustand';import{subscribeWithSelector}from 'zustand/middleware';import{Dimensions}from 'react-native';import{GAME_CONFIG}from "./SpaceFighterService.js";import{immerMiddleware}from "../../services/UtilsService.js";const{width,height}= Dimensions.get('window');const getSpacecraftYPosition =(offset = 0)=>{const yPercent = offset > 0 ? 0.77:0.68;return height * yPercent;};export const useSpaceFighterStore = create()(subscribeWithSelector(immerMiddleware((set,_get)=>({score:0,timeLeft:60,isPlaying:false,gameOver:false,lives:3,asteroids:[],spacecraft:{x:width / 2,y:getSpacecraftYPosition(0),velocityX:0,velocityY:0,size:GAME_CONFIG.SPACECRAFT_SIZE,isControlled:false},spacecraftPath:[],isControllingSpacecraft:false,offset:0,setOffset:offset =>{set(draft =>{draft.offset = offset;draft.spacecraft.y = getSpacecraftYPosition(offset);});},startGame:_gameDuration =>{const duration = 60;set(draft =>{draft.score = 0;draft.timeLeft = duration;draft.isPlaying = true;draft.gameOver = false;draft.lives = 3;draft.asteroids = [];draft.spacecraftPath = [];draft.isControllingSpacecraft = false;draft.spacecraft ={x:width / 2,y:getSpacecraftYPosition(draft.offset),velocityX:0,velocityY:0,size:GAME_CONFIG.SPACECRAFT_SIZE,isControlled:false};});},stopGame:()=>{set(draft =>{draft.score = 0;draft.timeLeft = 60;draft.isPlaying = false;draft.gameOver = false;draft.lives = 3;draft.asteroids = [];draft.spacecraftPath = [];draft.isControllingSpacecraft = false;draft.spacecraft ={x:width / 2,y:getSpacecraftYPosition(draft.offset),velocityX:0,velocityY:0,size:GAME_CONFIG.SPACECRAFT_SIZE,isControlled:false};});},resetGame:()=>{set(draft =>{draft.score = 0;draft.timeLeft = 60;draft.isPlaying = false;draft.gameOver = false;draft.lives = 3;draft.asteroids = [];draft.spacecraftPath = [];draft.isControllingSpacecraft = false;draft.spacecraft ={x:width / 2,y:getSpacecraftYPosition(draft.offset),velocityX:0,velocityY:0,size:GAME_CONFIG.SPACECRAFT_SIZE,isControlled:false};});},updateScore:points =>{set(draft =>{draft.score = draft.score + points;});},decrementTime:()=>{set(draft =>{const newTimeLeft = draft.timeLeft - 1;if(newTimeLeft <= 0){draft.timeLeft = 0;draft.isPlaying = false;draft.gameOver = true;}else{draft.timeLeft = newTimeLeft;}});},addAsteroids:asteroids =>{set(draft =>{draft.asteroids.push(...asteroids);});},removeAsteroid:asteroidId =>{set(draft =>{draft.asteroids = draft.asteroids.filter(a => a.id !== asteroidId);});},updateAsteroid:(asteroidId,updates)=>{set(draft =>{for(let i = 0;i < draft.asteroids.length;i++){if(draft.asteroids[i].id === asteroidId){Object.assign(draft.asteroids[i],updates);break;}}});},updateSpacecraft:spacecraft =>{set(draft =>{draft.spacecraft = spacecraft;});},setSpacecraftPath:path =>{set(draft =>{draft.spacecraftPath = path;});},setIsControllingSpacecraft:isControlling =>{set(draft =>{draft.isControllingSpacecraft = isControlling;});},markAsteroidPassed:pairId =>{set(draft =>{for(let i = 0;i < draft.asteroids.length;i++){if(draft.asteroids[i].pairId === pairId){draft.asteroids[i].passed = true;}}draft.score = draft.score + 10;});},loseLife:()=>{set(draft =>{const newLives = draft.lives - 1;draft.spacecraft ={x:width / 2,y:getSpacecraftYPosition(draft.offset),velocityX:0,velocityY:0,size:GAME_CONFIG.SPACECRAFT_SIZE,isControlled:false};if(newLives <= 0){draft.lives = 0;draft.isPlaying = false;draft.gameOver = true;}else{draft.lives = newLives;}});}}))));
|
|
@@ -1,113 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
export const AsteroidComponent = /*#__PURE__*/React.memo(({
|
|
7
|
-
asteroid
|
|
8
|
-
}) => {
|
|
9
|
-
// Use regular View instead of Animated.View to avoid worklet issues
|
|
10
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
11
|
-
style: {
|
|
12
|
-
position: 'absolute',
|
|
13
|
-
left: asteroid.x,
|
|
14
|
-
top: asteroid.y,
|
|
15
|
-
width: asteroid.width,
|
|
16
|
-
height: asteroid.height,
|
|
17
|
-
backgroundColor: '#6B4423',
|
|
18
|
-
// Darker brown for more realistic asteroid
|
|
19
|
-
borderRadius: 15,
|
|
20
|
-
// More rounded for organic look
|
|
21
|
-
shadowColor: '#2F1B14',
|
|
22
|
-
shadowOffset: {
|
|
23
|
-
width: 3,
|
|
24
|
-
height: 4
|
|
25
|
-
},
|
|
26
|
-
shadowOpacity: 0.7,
|
|
27
|
-
shadowRadius: 10,
|
|
28
|
-
// Add some texture with border
|
|
29
|
-
borderWidth: 1,
|
|
30
|
-
borderColor: 'rgba(139, 69, 19, 0.8)'
|
|
31
|
-
},
|
|
32
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
33
|
-
style: {
|
|
34
|
-
position: 'absolute',
|
|
35
|
-
left: 2,
|
|
36
|
-
top: 2,
|
|
37
|
-
width: asteroid.width - 4,
|
|
38
|
-
height: Math.max(0, asteroid.height - 4),
|
|
39
|
-
backgroundColor: 'rgba(160, 82, 45, 0.4)',
|
|
40
|
-
// Lighter brown highlight
|
|
41
|
-
borderRadius: 12
|
|
42
|
-
}
|
|
43
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
44
|
-
style: {
|
|
45
|
-
position: 'absolute',
|
|
46
|
-
left: asteroid.width * 0.25,
|
|
47
|
-
top: asteroid.height * 0.3,
|
|
48
|
-
width: 12,
|
|
49
|
-
height: 8,
|
|
50
|
-
backgroundColor: 'rgba(47, 27, 20, 0.8)',
|
|
51
|
-
// Dark crater
|
|
52
|
-
borderRadius: 6
|
|
53
|
-
}
|
|
54
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
55
|
-
style: {
|
|
56
|
-
position: 'absolute',
|
|
57
|
-
left: asteroid.width * 0.65,
|
|
58
|
-
top: asteroid.height * 0.6,
|
|
59
|
-
width: 8,
|
|
60
|
-
height: 6,
|
|
61
|
-
backgroundColor: 'rgba(47, 27, 20, 0.9)',
|
|
62
|
-
borderRadius: 4
|
|
63
|
-
}
|
|
64
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
65
|
-
style: {
|
|
66
|
-
position: 'absolute',
|
|
67
|
-
left: asteroid.width * 0.15,
|
|
68
|
-
top: asteroid.height * 0.7,
|
|
69
|
-
width: 5,
|
|
70
|
-
height: 4,
|
|
71
|
-
backgroundColor: 'rgba(47, 27, 20, 0.7)',
|
|
72
|
-
borderRadius: 2
|
|
73
|
-
}
|
|
74
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
75
|
-
style: {
|
|
76
|
-
position: 'absolute',
|
|
77
|
-
left: asteroid.width * 0.45,
|
|
78
|
-
top: asteroid.height * 0.2,
|
|
79
|
-
width: 4,
|
|
80
|
-
height: 4,
|
|
81
|
-
backgroundColor: 'rgba(101, 67, 33, 0.8)',
|
|
82
|
-
borderRadius: 2
|
|
83
|
-
}
|
|
84
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
85
|
-
style: {
|
|
86
|
-
position: 'absolute',
|
|
87
|
-
left: asteroid.width * 0.8,
|
|
88
|
-
top: asteroid.height * 0.4,
|
|
89
|
-
width: 3,
|
|
90
|
-
height: 3,
|
|
91
|
-
backgroundColor: 'rgba(139, 69, 19, 0.9)',
|
|
92
|
-
borderRadius: 1.5
|
|
93
|
-
}
|
|
94
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
95
|
-
style: {
|
|
96
|
-
position: 'absolute',
|
|
97
|
-
left: asteroid.width * 0.1,
|
|
98
|
-
top: asteroid.height * 0.1,
|
|
99
|
-
width: asteroid.width * 0.3,
|
|
100
|
-
height: asteroid.height * 0.2,
|
|
101
|
-
backgroundColor: 'rgba(205, 133, 63, 0.3)',
|
|
102
|
-
// Light brown highlight
|
|
103
|
-
borderRadius: 8
|
|
104
|
-
}
|
|
105
|
-
})]
|
|
106
|
-
});
|
|
107
|
-
}, (prevProps, nextProps) => {
|
|
108
|
-
// Custom comparison for better performance
|
|
109
|
-
const prev = prevProps.asteroid;
|
|
110
|
-
const next = nextProps.asteroid;
|
|
111
|
-
return prev.id === next.id && prev.x === next.x && prev.y === next.y && prev.width === next.width && prev.height === next.height;
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=AsteroidComponent.js.map
|
|
1
|
+
"use strict";import React from 'react';import{View}from 'react-native';import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";export const AsteroidComponent = React.memo(({asteroid})=>{return _jsxs(View,{style:{position:'absolute',left:asteroid.x,top:asteroid.y,width:asteroid.width,height:asteroid.height,backgroundColor:'#6B4423',borderRadius:15,shadowColor:'#2F1B14',shadowOffset:{width:3,height:4},shadowOpacity:0.7,shadowRadius:10,borderWidth:1,borderColor:'rgba(139,69,19,0.8)'},children:[_jsx(View,{style:{position:'absolute',left:2,top:2,width:asteroid.width - 4,height:Math.max(0,asteroid.height - 4),backgroundColor:'rgba(160,82,45,0.4)',borderRadius:12}}),_jsx(View,{style:{position:'absolute',left:asteroid.width * 0.25,top:asteroid.height * 0.3,width:12,height:8,backgroundColor:'rgba(47,27,20,0.8)',borderRadius:6}}),_jsx(View,{style:{position:'absolute',left:asteroid.width * 0.65,top:asteroid.height * 0.6,width:8,height:6,backgroundColor:'rgba(47,27,20,0.9)',borderRadius:4}}),_jsx(View,{style:{position:'absolute',left:asteroid.width * 0.15,top:asteroid.height * 0.7,width:5,height:4,backgroundColor:'rgba(47,27,20,0.7)',borderRadius:2}}),_jsx(View,{style:{position:'absolute',left:asteroid.width * 0.45,top:asteroid.height * 0.2,width:4,height:4,backgroundColor:'rgba(101,67,33,0.8)',borderRadius:2}}),_jsx(View,{style:{position:'absolute',left:asteroid.width * 0.8,top:asteroid.height * 0.4,width:3,height:3,backgroundColor:'rgba(139,69,19,0.9)',borderRadius:1.5}}),_jsx(View,{style:{position:'absolute',left:asteroid.width * 0.1,top:asteroid.height * 0.1,width:asteroid.width * 0.3,height:asteroid.height * 0.2,backgroundColor:'rgba(205,133,63,0.3)',borderRadius:8}})]});},(prevProps,nextProps)=>{const prev = prevProps.asteroid;const next = nextProps.asteroid;return prev.id === next.id && prev.x === next.x && prev.y === next.y && prev.width === next.width && prev.height === next.height;});
|
|
@@ -1,289 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useRef, useEffect, useCallback, useState, useMemo } from 'react';
|
|
4
|
-
import { View, Text, StyleSheet, Dimensions } from 'react-native';
|
|
5
|
-
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
6
|
-
import { useSpaceFighterStore } from "../SpaceFighterStore.js";
|
|
7
|
-
import { createSpaceFighterService } from "../SpaceFighterService.js";
|
|
8
|
-
import { playSound, GAME_SOUNDS } from "../../../services/SoundsService.js";
|
|
9
|
-
import { playHaptic, HapticType } from "../../../services/HapticsService.js";
|
|
10
|
-
import { ParticleBlast } from "../../../helpers/index.js";
|
|
11
|
-
import { AsteroidComponent } from "./AsteroidComponent.js";
|
|
12
|
-
import { Spacecraft3D } from "./Spacecraft3D.js";
|
|
13
|
-
import { SpacecraftPath } from "./SpacecraftPath.js";
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const {
|
|
16
|
-
width,
|
|
17
|
-
height
|
|
18
|
-
} = Dimensions.get('window');
|
|
19
|
-
|
|
20
|
-
// Self-contained GameArea component following FruitNinja pattern with performance optimizations
|
|
21
|
-
export const GameArea = /*#__PURE__*/React.memo(() => {
|
|
22
|
-
// Optimized store subscriptions - read only what's needed for rendering
|
|
23
|
-
const asteroids = useSpaceFighterStore(state => state.asteroids);
|
|
24
|
-
const spacecraft = useSpaceFighterStore(state => state.spacecraft);
|
|
25
|
-
const spacecraftPath = useSpaceFighterStore(state => state.spacecraftPath);
|
|
26
|
-
const isControllingSpacecraft = useSpaceFighterStore(state => state.isControllingSpacecraft);
|
|
27
|
-
const isPlaying = useSpaceFighterStore(state => state.isPlaying);
|
|
28
|
-
|
|
29
|
-
// Get store actions independently (these don't cause re-renders)
|
|
30
|
-
const updateSpacecraft = useSpaceFighterStore(state => state.updateSpacecraft);
|
|
31
|
-
const setSpacecraftPath = useSpaceFighterStore(state => state.setSpacecraftPath);
|
|
32
|
-
const setIsControllingSpacecraft = useSpaceFighterStore(state => state.setIsControllingSpacecraft);
|
|
33
|
-
const markAsteroidPassed = useSpaceFighterStore(state => state.markAsteroidPassed);
|
|
34
|
-
const loseLife = useSpaceFighterStore(state => state.loseLife);
|
|
35
|
-
|
|
36
|
-
// Self-contained component - no external settings needed
|
|
37
|
-
|
|
38
|
-
// Game service ref
|
|
39
|
-
const gameService = useRef(createSpaceFighterService(width, height)).current;
|
|
40
|
-
|
|
41
|
-
// Spacecraft control refs
|
|
42
|
-
const currentSpacecraftPath = useRef([]);
|
|
43
|
-
const initialSpacecraftPosition = useRef(null);
|
|
44
|
-
const initialTouchPosition = useRef(null);
|
|
45
|
-
const pendingSpacecraftUpdate = useRef(null);
|
|
46
|
-
const animationFrameId = useRef(null);
|
|
47
|
-
const lastCollisionTime = useRef(0);
|
|
48
|
-
|
|
49
|
-
// State for managing active particle blasts
|
|
50
|
-
const [activeBlasts, setActiveBlasts] = useState([]);
|
|
51
|
-
|
|
52
|
-
// Memoized particle blast colors for performance
|
|
53
|
-
const particleColors = useMemo(() => ['#ff6b6b', '#ff8e53', '#ff6b35'], []);
|
|
54
|
-
|
|
55
|
-
// Sound and haptic feedback functions (using default enabled state)
|
|
56
|
-
const playSuccessSound = useCallback(() => {
|
|
57
|
-
playSound(GAME_SOUNDS.SPACE_FIGHTER.SUCCESS, true);
|
|
58
|
-
playHaptic(HapticType.LIGHT, true);
|
|
59
|
-
}, []);
|
|
60
|
-
const playCollisionSound = useCallback(() => {
|
|
61
|
-
playSound(GAME_SOUNDS.SPACE_FIGHTER.COLLISION, true);
|
|
62
|
-
playHaptic(HapticType.HEAVY, true);
|
|
63
|
-
}, []);
|
|
64
|
-
|
|
65
|
-
// Spacecraft control functions
|
|
66
|
-
const handleSpacecraftControlStart = useCallback((x, y) => {
|
|
67
|
-
const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;
|
|
68
|
-
const controlledSpacecraft = gameService.controlSpacecraft({
|
|
69
|
-
...currentSpacecraft
|
|
70
|
-
}, x, y);
|
|
71
|
-
updateSpacecraft(controlledSpacecraft);
|
|
72
|
-
setIsControllingSpacecraft(true);
|
|
73
|
-
currentSpacecraftPath.current = [{
|
|
74
|
-
x,
|
|
75
|
-
y
|
|
76
|
-
}];
|
|
77
|
-
setSpacecraftPath([{
|
|
78
|
-
x,
|
|
79
|
-
y
|
|
80
|
-
}]);
|
|
81
|
-
}, [gameService, updateSpacecraft, setIsControllingSpacecraft, setSpacecraftPath]);
|
|
82
|
-
const processPendingSpacecraftUpdate = useCallback(() => {
|
|
83
|
-
if (pendingSpacecraftUpdate.current) {
|
|
84
|
-
const {
|
|
85
|
-
x,
|
|
86
|
-
y
|
|
87
|
-
} = pendingSpacecraftUpdate.current;
|
|
88
|
-
const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;
|
|
89
|
-
const controlledSpacecraft = gameService.controlSpacecraft({
|
|
90
|
-
...currentSpacecraft
|
|
91
|
-
}, x, y);
|
|
92
|
-
updateSpacecraft(controlledSpacecraft);
|
|
93
|
-
|
|
94
|
-
// Throttle path updates to reduce re-renders
|
|
95
|
-
currentSpacecraftPath.current.push({
|
|
96
|
-
x,
|
|
97
|
-
y
|
|
98
|
-
});
|
|
99
|
-
if (currentSpacecraftPath.current.length > 8) {
|
|
100
|
-
currentSpacecraftPath.current.shift();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Only update path every 3rd update to reduce re-renders
|
|
104
|
-
if (currentSpacecraftPath.current.length % 3 === 0) {
|
|
105
|
-
setSpacecraftPath([...currentSpacecraftPath.current]);
|
|
106
|
-
}
|
|
107
|
-
pendingSpacecraftUpdate.current = null;
|
|
108
|
-
}
|
|
109
|
-
animationFrameId.current = null;
|
|
110
|
-
}, [gameService, updateSpacecraft, setSpacecraftPath]);
|
|
111
|
-
const handleSpacecraftControlMove = useCallback((x, y) => {
|
|
112
|
-
pendingSpacecraftUpdate.current = {
|
|
113
|
-
x,
|
|
114
|
-
y
|
|
115
|
-
};
|
|
116
|
-
if (animationFrameId.current === null) {
|
|
117
|
-
animationFrameId.current = requestAnimationFrame(processPendingSpacecraftUpdate);
|
|
118
|
-
}
|
|
119
|
-
}, [processPendingSpacecraftUpdate]);
|
|
120
|
-
const handleSpacecraftControlEnd = useCallback(() => {
|
|
121
|
-
if (animationFrameId.current !== null) {
|
|
122
|
-
cancelAnimationFrame(animationFrameId.current);
|
|
123
|
-
animationFrameId.current = null;
|
|
124
|
-
}
|
|
125
|
-
if (pendingSpacecraftUpdate.current) {
|
|
126
|
-
processPendingSpacecraftUpdate();
|
|
127
|
-
}
|
|
128
|
-
const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;
|
|
129
|
-
const releasedSpacecraft = gameService.releaseSpacecraft({
|
|
130
|
-
...currentSpacecraft
|
|
131
|
-
});
|
|
132
|
-
updateSpacecraft(releasedSpacecraft);
|
|
133
|
-
setIsControllingSpacecraft(false);
|
|
134
|
-
setTimeout(() => {
|
|
135
|
-
currentSpacecraftPath.current = [];
|
|
136
|
-
setSpacecraftPath([]);
|
|
137
|
-
}, 300);
|
|
138
|
-
}, [gameService, updateSpacecraft, setIsControllingSpacecraft, setSpacecraftPath, processPendingSpacecraftUpdate]);
|
|
139
|
-
|
|
140
|
-
// Optimized collision detection with reduced store access
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
if (!isPlaying) return;
|
|
143
|
-
const interval = setInterval(() => {
|
|
144
|
-
// Single store access for better performance
|
|
145
|
-
const state = useSpaceFighterStore.getState();
|
|
146
|
-
const currentSpacecraft = state.spacecraft;
|
|
147
|
-
const currentAsteroids = state.asteroids;
|
|
148
|
-
|
|
149
|
-
// Skip if no asteroids to check
|
|
150
|
-
if (currentAsteroids.length === 0) return;
|
|
151
|
-
const collision = gameService.checkCollision(currentSpacecraft, currentAsteroids);
|
|
152
|
-
const now = Date.now();
|
|
153
|
-
if (collision.collision && now - lastCollisionTime.current > 1000) {
|
|
154
|
-
lastCollisionTime.current = now;
|
|
155
|
-
playCollisionSound();
|
|
156
|
-
|
|
157
|
-
// Create particle blast at collision point
|
|
158
|
-
const blastId = `blast-${now}`;
|
|
159
|
-
setActiveBlasts(prev => [...prev, {
|
|
160
|
-
id: blastId,
|
|
161
|
-
x: currentSpacecraft.x,
|
|
162
|
-
y: currentSpacecraft.y
|
|
163
|
-
}]);
|
|
164
|
-
|
|
165
|
-
// Remove blast after animation
|
|
166
|
-
setTimeout(() => {
|
|
167
|
-
setActiveBlasts(prev => prev.filter(blast => blast.id !== blastId));
|
|
168
|
-
}, 800);
|
|
169
|
-
loseLife(); // This now handles spacecraft position reset internally
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Check asteroid passes for scoring
|
|
174
|
-
const passedAsteroids = gameService.checkAsteroidPass(currentSpacecraft, currentAsteroids);
|
|
175
|
-
if (passedAsteroids.length > 0) {
|
|
176
|
-
passedAsteroids.forEach(pairId => {
|
|
177
|
-
markAsteroidPassed(pairId);
|
|
178
|
-
playSuccessSound();
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}, 100); // Slightly increased interval for better performance (was 80ms)
|
|
182
|
-
|
|
183
|
-
return () => clearInterval(interval);
|
|
184
|
-
}, [isPlaying, gameService, playCollisionSound, loseLife, updateSpacecraft, markAsteroidPassed, playSuccessSound]);
|
|
185
|
-
|
|
186
|
-
// Memoized gesture handling for better performance
|
|
187
|
-
const panGesture = useMemo(() => Gesture.Pan().onStart(event => {
|
|
188
|
-
const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;
|
|
189
|
-
initialSpacecraftPosition.current = {
|
|
190
|
-
x: currentSpacecraft.x,
|
|
191
|
-
y: currentSpacecraft.y
|
|
192
|
-
};
|
|
193
|
-
initialTouchPosition.current = {
|
|
194
|
-
x: event.absoluteX,
|
|
195
|
-
y: event.absoluteY
|
|
196
|
-
};
|
|
197
|
-
handleSpacecraftControlStart(currentSpacecraft.x, currentSpacecraft.y);
|
|
198
|
-
}).onUpdate(event => {
|
|
199
|
-
if (!initialSpacecraftPosition.current || !initialTouchPosition.current) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
const dx = event.absoluteX - initialTouchPosition.current.x;
|
|
203
|
-
const newX = initialSpacecraftPosition.current.x + dx;
|
|
204
|
-
const newY = initialSpacecraftPosition.current.y;
|
|
205
|
-
handleSpacecraftControlMove(newX, newY);
|
|
206
|
-
}).onEnd(() => {
|
|
207
|
-
initialTouchPosition.current = null;
|
|
208
|
-
handleSpacecraftControlEnd();
|
|
209
|
-
}).onFinalize(() => {
|
|
210
|
-
initialTouchPosition.current = null;
|
|
211
|
-
handleSpacecraftControlEnd();
|
|
212
|
-
}).runOnJS(true), [handleSpacecraftControlStart, handleSpacecraftControlMove, handleSpacecraftControlEnd]);
|
|
213
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
214
|
-
style: [styles.gameArea],
|
|
215
|
-
children: [/*#__PURE__*/_jsx(SpacecraftPath, {
|
|
216
|
-
path: spacecraftPath
|
|
217
|
-
}), asteroids.map(asteroid => /*#__PURE__*/_jsx(AsteroidComponent, {
|
|
218
|
-
asteroid: asteroid
|
|
219
|
-
}, asteroid.id)), activeBlasts.map(blast => /*#__PURE__*/_jsx(ParticleBlast, {
|
|
220
|
-
x: blast.x,
|
|
221
|
-
y: blast.y,
|
|
222
|
-
colors: particleColors,
|
|
223
|
-
particleCount: 12,
|
|
224
|
-
duration: 800
|
|
225
|
-
}, blast.id)), /*#__PURE__*/_jsx(Spacecraft3D, {
|
|
226
|
-
spacecraft: spacecraft,
|
|
227
|
-
isControlled: isControllingSpacecraft
|
|
228
|
-
}), /*#__PURE__*/_jsx(GestureDetector, {
|
|
229
|
-
gesture: panGesture,
|
|
230
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
231
|
-
style: styles.gestureOverlay
|
|
232
|
-
})
|
|
233
|
-
}), asteroids.length === 0 && /*#__PURE__*/_jsxs(View, {
|
|
234
|
-
style: styles.instructionsContainer,
|
|
235
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
236
|
-
style: styles.instructionsEmoji,
|
|
237
|
-
children: "\uD83D\uDE80"
|
|
238
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
239
|
-
style: styles.instructionsTitle,
|
|
240
|
-
children: "Navigate your spacecraft through the space!"
|
|
241
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
242
|
-
style: styles.instructionsSubtitle,
|
|
243
|
-
children: "Touch and drag to control your spacecraft"
|
|
244
|
-
})]
|
|
245
|
-
})]
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
const styles = StyleSheet.create({
|
|
249
|
-
gameArea: {
|
|
250
|
-
flex: 1,
|
|
251
|
-
position: 'relative'
|
|
252
|
-
},
|
|
253
|
-
gestureOverlay: {
|
|
254
|
-
position: 'absolute',
|
|
255
|
-
top: 0,
|
|
256
|
-
left: 0,
|
|
257
|
-
right: 0,
|
|
258
|
-
bottom: 0,
|
|
259
|
-
backgroundColor: 'transparent',
|
|
260
|
-
zIndex: 10
|
|
261
|
-
},
|
|
262
|
-
instructionsContainer: {
|
|
263
|
-
position: 'absolute',
|
|
264
|
-
top: '33%',
|
|
265
|
-
left: 0,
|
|
266
|
-
right: 0,
|
|
267
|
-
opacity: 0.6,
|
|
268
|
-
alignItems: 'center',
|
|
269
|
-
justifyContent: 'center'
|
|
270
|
-
},
|
|
271
|
-
instructionsEmoji: {
|
|
272
|
-
textAlign: 'center',
|
|
273
|
-
fontSize: 24,
|
|
274
|
-
marginBottom: 12
|
|
275
|
-
},
|
|
276
|
-
instructionsTitle: {
|
|
277
|
-
color: '#ffffff',
|
|
278
|
-
textAlign: 'center',
|
|
279
|
-
fontSize: 18,
|
|
280
|
-
fontWeight: 'bold',
|
|
281
|
-
marginBottom: 8
|
|
282
|
-
},
|
|
283
|
-
instructionsSubtitle: {
|
|
284
|
-
color: '#ffffff',
|
|
285
|
-
textAlign: 'center',
|
|
286
|
-
marginTop: 8
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
//# sourceMappingURL=GameArea.js.map
|
|
1
|
+
"use strict";import React,{useRef,useEffect,useCallback,useState,useMemo}from 'react';import{View,Text,StyleSheet,Dimensions}from 'react-native';import{Gesture,GestureDetector}from 'react-native-gesture-handler';import{useSpaceFighterStore}from "../SpaceFighterStore.js";import{createSpaceFighterService}from "../SpaceFighterService.js";import{playSound,GAME_SOUNDS}from "../../../services/SoundsService.js";import{playHaptic,HapticType}from "../../../services/HapticsService.js";import{ParticleBlast}from "../../../helpers/index.js";import{AsteroidComponent}from "./AsteroidComponent.js";import{Spacecraft3D}from "./Spacecraft3D.js";import{SpacecraftPath}from "./SpacecraftPath.js";import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";const{width,height}= Dimensions.get('window');export const GameArea = React.memo(()=>{const asteroids = useSpaceFighterStore(state => state.asteroids);const spacecraft = useSpaceFighterStore(state => state.spacecraft);const spacecraftPath = useSpaceFighterStore(state => state.spacecraftPath);const isControllingSpacecraft = useSpaceFighterStore(state => state.isControllingSpacecraft);const isPlaying = useSpaceFighterStore(state => state.isPlaying);const updateSpacecraft = useSpaceFighterStore(state => state.updateSpacecraft);const setSpacecraftPath = useSpaceFighterStore(state => state.setSpacecraftPath);const setIsControllingSpacecraft = useSpaceFighterStore(state => state.setIsControllingSpacecraft);const markAsteroidPassed = useSpaceFighterStore(state => state.markAsteroidPassed);const loseLife = useSpaceFighterStore(state => state.loseLife);const gameService = useRef(createSpaceFighterService(width,height)).current;const currentSpacecraftPath = useRef([]);const initialSpacecraftPosition = useRef(null);const initialTouchPosition = useRef(null);const pendingSpacecraftUpdate = useRef(null);const animationFrameId = useRef(null);const lastCollisionTime = useRef(0);const [activeBlasts,setActiveBlasts] = useState([]);const particleColors = useMemo(()=> ['#ff6b6b','#ff8e53','#ff6b35'],[]);const playSuccessSound = useCallback(()=>{playSound(GAME_SOUNDS.SPACE_FIGHTER.SUCCESS,true);playHaptic(HapticType.LIGHT,true);},[]);const playCollisionSound = useCallback(()=>{playSound(GAME_SOUNDS.SPACE_FIGHTER.COLLISION,true);playHaptic(HapticType.HEAVY,true);},[]);const handleSpacecraftControlStart = useCallback((x,y)=>{const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;const controlledSpacecraft = gameService.controlSpacecraft({...currentSpacecraft},x,y);updateSpacecraft(controlledSpacecraft);setIsControllingSpacecraft(true);currentSpacecraftPath.current = [{x,y}];setSpacecraftPath([{x,y}]);},[gameService,updateSpacecraft,setIsControllingSpacecraft,setSpacecraftPath]);const processPendingSpacecraftUpdate = useCallback(()=>{if(pendingSpacecraftUpdate.current){const{x,y}= pendingSpacecraftUpdate.current;const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;const controlledSpacecraft = gameService.controlSpacecraft({...currentSpacecraft},x,y);updateSpacecraft(controlledSpacecraft);currentSpacecraftPath.current.push({x,y});if(currentSpacecraftPath.current.length > 8){currentSpacecraftPath.current.shift();}if(currentSpacecraftPath.current.length % 3 === 0){setSpacecraftPath([...currentSpacecraftPath.current]);}pendingSpacecraftUpdate.current = null;}animationFrameId.current = null;},[gameService,updateSpacecraft,setSpacecraftPath]);const handleSpacecraftControlMove = useCallback((x,y)=>{pendingSpacecraftUpdate.current ={x,y};if(animationFrameId.current === null){animationFrameId.current = requestAnimationFrame(processPendingSpacecraftUpdate);}},[processPendingSpacecraftUpdate]);const handleSpacecraftControlEnd = useCallback(()=>{if(animationFrameId.current !== null){cancelAnimationFrame(animationFrameId.current);animationFrameId.current = null;}if(pendingSpacecraftUpdate.current){processPendingSpacecraftUpdate();}const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;const releasedSpacecraft = gameService.releaseSpacecraft({...currentSpacecraft});updateSpacecraft(releasedSpacecraft);setIsControllingSpacecraft(false);setTimeout(()=>{currentSpacecraftPath.current = [];setSpacecraftPath([]);},300);},[gameService,updateSpacecraft,setIsControllingSpacecraft,setSpacecraftPath,processPendingSpacecraftUpdate]);useEffect(()=>{if(!isPlaying)return;const interval = setInterval(()=>{const state = useSpaceFighterStore.getState();const currentSpacecraft = state.spacecraft;const currentAsteroids = state.asteroids;if(currentAsteroids.length === 0)return;const collision = gameService.checkCollision(currentSpacecraft,currentAsteroids);const now = Date.now();if(collision.collision && now - lastCollisionTime.current > 1000){lastCollisionTime.current = now;playCollisionSound();const blastId = `blast-${now}`;setActiveBlasts(prev => [...prev,{id:blastId,x:currentSpacecraft.x,y:currentSpacecraft.y}]);setTimeout(()=>{setActiveBlasts(prev => prev.filter(blast => blast.id !== blastId));},800);loseLife();return;}const passedAsteroids = gameService.checkAsteroidPass(currentSpacecraft,currentAsteroids);if(passedAsteroids.length > 0){passedAsteroids.forEach(pairId =>{markAsteroidPassed(pairId);playSuccessSound();});}},100);return()=> clearInterval(interval);},[isPlaying,gameService,playCollisionSound,loseLife,updateSpacecraft,markAsteroidPassed,playSuccessSound]);const panGesture = useMemo(()=> Gesture.Pan().onStart(event =>{const currentSpacecraft = useSpaceFighterStore.getState().spacecraft;initialSpacecraftPosition.current ={x:currentSpacecraft.x,y:currentSpacecraft.y};initialTouchPosition.current ={x:event.absoluteX,y:event.absoluteY};handleSpacecraftControlStart(currentSpacecraft.x,currentSpacecraft.y);}).onUpdate(event =>{if(!initialSpacecraftPosition.current || !initialTouchPosition.current){return;}const dx = event.absoluteX - initialTouchPosition.current.x;const newX = initialSpacecraftPosition.current.x + dx;const newY = initialSpacecraftPosition.current.y;handleSpacecraftControlMove(newX,newY);}).onEnd(()=>{initialTouchPosition.current = null;handleSpacecraftControlEnd();}).onFinalize(()=>{initialTouchPosition.current = null;handleSpacecraftControlEnd();}).runOnJS(true),[handleSpacecraftControlStart,handleSpacecraftControlMove,handleSpacecraftControlEnd]);return _jsxs(View,{style:[styles.gameArea],children:[_jsx(SpacecraftPath,{path:spacecraftPath}),asteroids.map(asteroid => _jsx(AsteroidComponent,{asteroid:asteroid},asteroid.id)),activeBlasts.map(blast => _jsx(ParticleBlast,{x:blast.x,y:blast.y,colors:particleColors,particleCount:12,duration:800},blast.id)),_jsx(Spacecraft3D,{spacecraft:spacecraft,isControlled:isControllingSpacecraft}),_jsx(GestureDetector,{gesture:panGesture,children:_jsx(View,{style:styles.gestureOverlay})}),asteroids.length === 0 && _jsxs(View,{style:styles.instructionsContainer,children:[_jsx(Text,{style:styles.instructionsEmoji,children:"\uD83D\uDE80"}),_jsx(Text,{style:styles.instructionsTitle,children:"Navigate your spacecraft through the space!"}),_jsx(Text,{style:styles.instructionsSubtitle,children:"Touch and drag to control your spacecraft"})]})]});});const styles = StyleSheet.create({gameArea:{flex:1,position:'relative'},gestureOverlay:{position:'absolute',top:0,left:0,right:0,bottom:0,backgroundColor:'transparent',zIndex:10},instructionsContainer:{position:'absolute',top:'33%',left:0,right:0,opacity:0.6,alignItems:'center',justifyContent:'center'},instructionsEmoji:{textAlign:'center',fontSize:24,marginBottom:12},instructionsTitle:{color:'#ffffff',textAlign:'center',fontSize:18,fontWeight:'bold',marginBottom:8},instructionsSubtitle:{color:'#ffffff',textAlign:'center',marginTop:8}});
|