react-native-games 1.0.0 → 1.2.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 +80 -368
- 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/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/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/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/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/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/ParticleBlast.js +1 -134
- package/lib/module/helpers/ScoreBoardContainer.js +1 -34
- package/lib/module/helpers/index.js +1 -12
- package/lib/module/index.js +1 -22
- package/lib/module/services/GamesConstants.js +1 -178
- 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/SoundsService.js +1 -302
- package/lib/module/services/UtilsService.js +1 -32
- 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/candy-crush/CandyCrushConstants.d.ts +7 -7
- 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/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/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/services/GamesConstants.d.ts +7 -7
- package/package.json +2 -2
|
@@ -1,259 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { View, Dimensions } from 'react-native';
|
|
5
|
-
import { Canvas, LinearGradient, Rect, vec, Circle, RoundedRect } from '@shopify/react-native-skia';
|
|
6
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
const {
|
|
8
|
-
width,
|
|
9
|
-
height
|
|
10
|
-
} = Dimensions.get('window');
|
|
11
|
-
|
|
12
|
-
// Puzzle-themed vibrant colors inspired by colorful number tiles
|
|
13
|
-
const PUZZLE_COLORS = ['#E91E63',
|
|
14
|
-
// Vibrant pink
|
|
15
|
-
'#F44336',
|
|
16
|
-
// Bright red
|
|
17
|
-
'#FF5722',
|
|
18
|
-
// Deep orange
|
|
19
|
-
'#FF9800',
|
|
20
|
-
// Orange
|
|
21
|
-
'#FFC107',
|
|
22
|
-
// Amber/yellow
|
|
23
|
-
'#CDDC39',
|
|
24
|
-
// Lime
|
|
25
|
-
'#4CAF50',
|
|
26
|
-
// Green
|
|
27
|
-
'#009688',
|
|
28
|
-
// Teal
|
|
29
|
-
'#00BCD4',
|
|
30
|
-
// Cyan
|
|
31
|
-
'#2196F3',
|
|
32
|
-
// Blue
|
|
33
|
-
'#3F51B5',
|
|
34
|
-
// Indigo
|
|
35
|
-
'#9C27B0' // Purple
|
|
36
|
-
];
|
|
37
|
-
export const GameBackground = /*#__PURE__*/React.memo(({
|
|
38
|
-
children
|
|
39
|
-
}) => {
|
|
40
|
-
// Generate static colorful floating puzzle tiles
|
|
41
|
-
const generateFloatingTiles = React.useMemo(() => {
|
|
42
|
-
const elements = [];
|
|
43
|
-
const tileCount = 25;
|
|
44
|
-
for (let i = 0; i < tileCount; i++) {
|
|
45
|
-
const baseX = width / tileCount * i;
|
|
46
|
-
const baseY = height / tileCount * i;
|
|
47
|
-
|
|
48
|
-
// Add subtle random offset for natural look
|
|
49
|
-
const x = baseX + Math.sin(i * 0.5) * 50 + Math.random() * 100;
|
|
50
|
-
const y = baseY + Math.cos(i * 0.7) * 60 + Math.random() * 120;
|
|
51
|
-
const tileSize = 20 + Math.random() * 20;
|
|
52
|
-
const colorIndex = i % PUZZLE_COLORS.length;
|
|
53
|
-
const opacity = 0.3 + Math.sin(i) * 0.15;
|
|
54
|
-
|
|
55
|
-
// Puzzle tile with varied shapes to suggest numbers
|
|
56
|
-
const tileX = Math.max(tileSize / 2, Math.min(width - tileSize, x));
|
|
57
|
-
const tileY = Math.max(tileSize / 2, Math.min(height - tileSize, y));
|
|
58
|
-
|
|
59
|
-
// Create different tile patterns to suggest different numbers
|
|
60
|
-
if (i % 4 === 0) {
|
|
61
|
-
// Square tiles (like number blocks)
|
|
62
|
-
elements.push(/*#__PURE__*/_jsx(RoundedRect, {
|
|
63
|
-
x: tileX,
|
|
64
|
-
y: tileY,
|
|
65
|
-
width: tileSize,
|
|
66
|
-
height: tileSize,
|
|
67
|
-
r: tileSize * 0.2,
|
|
68
|
-
color: `${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2, '0')}`
|
|
69
|
-
}, `square-tile-${i}`));
|
|
70
|
-
} else if (i % 4 === 1) {
|
|
71
|
-
// Rectangular tiles (like number 1)
|
|
72
|
-
elements.push(/*#__PURE__*/_jsx(RoundedRect, {
|
|
73
|
-
x: tileX,
|
|
74
|
-
y: tileY,
|
|
75
|
-
width: tileSize * 0.6,
|
|
76
|
-
height: tileSize,
|
|
77
|
-
r: tileSize * 0.15,
|
|
78
|
-
color: `${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2, '0')}`
|
|
79
|
-
}, `rect-tile-${i}`));
|
|
80
|
-
} else if (i % 4 === 2) {
|
|
81
|
-
// Wide tiles (like number 8)
|
|
82
|
-
elements.push(/*#__PURE__*/_jsx(RoundedRect, {
|
|
83
|
-
x: tileX,
|
|
84
|
-
y: tileY,
|
|
85
|
-
width: tileSize * 1.2,
|
|
86
|
-
height: tileSize * 0.8,
|
|
87
|
-
r: tileSize * 0.1,
|
|
88
|
-
color: `${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2, '0')}`
|
|
89
|
-
}, `wide-tile-${i}`));
|
|
90
|
-
} else {
|
|
91
|
-
// Circular tiles
|
|
92
|
-
elements.push(/*#__PURE__*/_jsx(Circle, {
|
|
93
|
-
cx: tileX + tileSize / 2,
|
|
94
|
-
cy: tileY + tileSize / 2,
|
|
95
|
-
r: tileSize / 2,
|
|
96
|
-
color: `${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2, '0')}`
|
|
97
|
-
}, `circle-tile-${i}`));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return elements;
|
|
101
|
-
}, [width, height]);
|
|
102
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
103
|
-
style: {
|
|
104
|
-
flex: 1
|
|
105
|
-
},
|
|
106
|
-
children: [/*#__PURE__*/_jsxs(Canvas, {
|
|
107
|
-
style: {
|
|
108
|
-
position: 'absolute',
|
|
109
|
-
top: 0,
|
|
110
|
-
left: 0,
|
|
111
|
-
right: 0,
|
|
112
|
-
bottom: 0,
|
|
113
|
-
width,
|
|
114
|
-
height
|
|
115
|
-
},
|
|
116
|
-
children: [/*#__PURE__*/_jsx(Rect, {
|
|
117
|
-
x: 0,
|
|
118
|
-
y: 0,
|
|
119
|
-
width: width,
|
|
120
|
-
height: height,
|
|
121
|
-
children: /*#__PURE__*/_jsx(LinearGradient, {
|
|
122
|
-
start: vec(0, 0),
|
|
123
|
-
end: vec(width, height),
|
|
124
|
-
colors: [`${PUZZLE_COLORS[0]}30`,
|
|
125
|
-
// Vibrant pink
|
|
126
|
-
`${PUZZLE_COLORS[3]}25`,
|
|
127
|
-
// Orange
|
|
128
|
-
`${PUZZLE_COLORS[6]}30`,
|
|
129
|
-
// Green
|
|
130
|
-
`${PUZZLE_COLORS[9]}25`,
|
|
131
|
-
// Blue
|
|
132
|
-
`${PUZZLE_COLORS[11]}30` // Purple
|
|
133
|
-
]
|
|
134
|
-
})
|
|
135
|
-
}), /*#__PURE__*/_jsx(Rect, {
|
|
136
|
-
x: 0,
|
|
137
|
-
y: 0,
|
|
138
|
-
width: width,
|
|
139
|
-
height: height,
|
|
140
|
-
children: /*#__PURE__*/_jsx(LinearGradient, {
|
|
141
|
-
start: vec(0, 0),
|
|
142
|
-
end: vec(width / 2, height / 2),
|
|
143
|
-
colors: [`${PUZZLE_COLORS[1]}20`,
|
|
144
|
-
// Bright red
|
|
145
|
-
'transparent', `${PUZZLE_COLORS[4]}20`,
|
|
146
|
-
// Yellow
|
|
147
|
-
'transparent', `${PUZZLE_COLORS[7]}20`,
|
|
148
|
-
// Teal
|
|
149
|
-
'transparent']
|
|
150
|
-
})
|
|
151
|
-
}), /*#__PURE__*/_jsx(Rect, {
|
|
152
|
-
x: 0,
|
|
153
|
-
y: 0,
|
|
154
|
-
width: width,
|
|
155
|
-
height: height,
|
|
156
|
-
children: /*#__PURE__*/_jsx(LinearGradient, {
|
|
157
|
-
start: vec(width, 0),
|
|
158
|
-
end: vec(0, height),
|
|
159
|
-
colors: [`${PUZZLE_COLORS[2]}15`,
|
|
160
|
-
// Deep orange
|
|
161
|
-
'transparent', `${PUZZLE_COLORS[5]}15`,
|
|
162
|
-
// Lime
|
|
163
|
-
'transparent', `${PUZZLE_COLORS[8]}15`,
|
|
164
|
-
// Cyan
|
|
165
|
-
'transparent']
|
|
166
|
-
})
|
|
167
|
-
}), generateFloatingTiles, /*#__PURE__*/_jsx(RoundedRect, {
|
|
168
|
-
x: width * 0.08,
|
|
169
|
-
y: height * 0.12,
|
|
170
|
-
width: 50,
|
|
171
|
-
height: 50,
|
|
172
|
-
r: 8,
|
|
173
|
-
color: `${PUZZLE_COLORS[0]}50` // Vibrant pink
|
|
174
|
-
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
175
|
-
x: width * 0.85,
|
|
176
|
-
y: height * 0.82,
|
|
177
|
-
width: 45,
|
|
178
|
-
height: 45,
|
|
179
|
-
r: 7,
|
|
180
|
-
color: `${PUZZLE_COLORS[3]}50` // Orange
|
|
181
|
-
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
182
|
-
x: width * 0.82,
|
|
183
|
-
y: height * 0.18,
|
|
184
|
-
width: 40,
|
|
185
|
-
height: 40,
|
|
186
|
-
r: 6,
|
|
187
|
-
color: `${PUZZLE_COLORS[6]}50` // Green
|
|
188
|
-
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
189
|
-
x: width * 0.12,
|
|
190
|
-
y: height * 0.75,
|
|
191
|
-
width: 55,
|
|
192
|
-
height: 55,
|
|
193
|
-
r: 9,
|
|
194
|
-
color: `${PUZZLE_COLORS[9]}50` // Blue
|
|
195
|
-
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
196
|
-
x: width * 0.47,
|
|
197
|
-
y: height * 0.08,
|
|
198
|
-
width: 35,
|
|
199
|
-
height: 35,
|
|
200
|
-
r: 5,
|
|
201
|
-
color: `${PUZZLE_COLORS[11]}50` // Purple
|
|
202
|
-
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
203
|
-
x: width * 0.15,
|
|
204
|
-
y: height * 0.47,
|
|
205
|
-
width: 42,
|
|
206
|
-
height: 42,
|
|
207
|
-
r: 6,
|
|
208
|
-
color: `${PUZZLE_COLORS[5]}50` // Lime
|
|
209
|
-
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
210
|
-
x: width * 0.75,
|
|
211
|
-
y: height * 0.57,
|
|
212
|
-
width: 38,
|
|
213
|
-
height: 38,
|
|
214
|
-
r: 6,
|
|
215
|
-
color: `${PUZZLE_COLORS[8]}50` // Cyan
|
|
216
|
-
}), /*#__PURE__*/_jsx(RoundedRect, {
|
|
217
|
-
x: width * 0.57,
|
|
218
|
-
y: height * 0.87,
|
|
219
|
-
width: 32,
|
|
220
|
-
height: 32,
|
|
221
|
-
r: 5,
|
|
222
|
-
color: `${PUZZLE_COLORS[1]}50` // Red
|
|
223
|
-
}), /*#__PURE__*/_jsx(Circle, {
|
|
224
|
-
cx: width * 0.25,
|
|
225
|
-
cy: height * 0.25,
|
|
226
|
-
r: 18,
|
|
227
|
-
color: `${PUZZLE_COLORS[4]}45` // Yellow
|
|
228
|
-
}), /*#__PURE__*/_jsx(Circle, {
|
|
229
|
-
cx: width * 0.65,
|
|
230
|
-
cy: height * 0.35,
|
|
231
|
-
r: 22,
|
|
232
|
-
color: `${PUZZLE_COLORS[7]}45` // Teal
|
|
233
|
-
}), /*#__PURE__*/_jsx(Circle, {
|
|
234
|
-
cx: width * 0.35,
|
|
235
|
-
cy: height * 0.65,
|
|
236
|
-
r: 16,
|
|
237
|
-
color: `${PUZZLE_COLORS[10]}45` // Indigo
|
|
238
|
-
}), Array.from({
|
|
239
|
-
length: Math.floor(width / 60)
|
|
240
|
-
}, (_, i) => /*#__PURE__*/_jsx(Rect, {
|
|
241
|
-
x: i * 60,
|
|
242
|
-
y: 0,
|
|
243
|
-
width: 1,
|
|
244
|
-
height: height,
|
|
245
|
-
color: "rgba(255, 255, 255, 0.05)"
|
|
246
|
-
}, `grid-v-${i}`)), Array.from({
|
|
247
|
-
length: Math.floor(height / 60)
|
|
248
|
-
}, (_, i) => /*#__PURE__*/_jsx(Rect, {
|
|
249
|
-
x: 0,
|
|
250
|
-
y: i * 60,
|
|
251
|
-
width: width,
|
|
252
|
-
height: 1,
|
|
253
|
-
color: "rgba(255, 255, 255, 0.05)"
|
|
254
|
-
}, `grid-h-${i}`))]
|
|
255
|
-
}), children]
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
GameBackground.displayName = 'GameBackground';
|
|
259
|
-
//# sourceMappingURL=GameBackground.js.map
|
|
1
|
+
"use strict";import React from 'react';import{View,Dimensions}from 'react-native';import{Canvas,LinearGradient,Rect,vec,Circle,RoundedRect}from '@shopify/react-native-skia';import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";const{width,height}= Dimensions.get('window');const PUZZLE_COLORS = ['#E91E63','#F44336','#FF5722','#FF9800','#FFC107','#CDDC39','#4CAF50','#009688','#00BCD4','#2196F3','#3F51B5','#9C27B0' ];export const GameBackground = React.memo(({children})=>{const generateFloatingTiles = React.useMemo(()=>{const elements = [];const tileCount = 25;for(let i = 0;i < tileCount;i++){const baseX = width / tileCount * i;const baseY = height / tileCount * i;const x = baseX + Math.sin(i * 0.5)* 50 + Math.random()* 100;const y = baseY + Math.cos(i * 0.7)* 60 + Math.random()* 120;const tileSize = 20 + Math.random()* 20;const colorIndex = i % PUZZLE_COLORS.length;const opacity = 0.3 + Math.sin(i)* 0.15;const tileX = Math.max(tileSize / 2,Math.min(width - tileSize,x));const tileY = Math.max(tileSize / 2,Math.min(height - tileSize,y));if(i % 4 === 0){elements.push(_jsx(RoundedRect,{x:tileX,y:tileY,width:tileSize,height:tileSize,r:tileSize * 0.2,color:`${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2,'0')}`},`square-tile-${i}`));}else if(i % 4 === 1){elements.push(_jsx(RoundedRect,{x:tileX,y:tileY,width:tileSize * 0.6,height:tileSize,r:tileSize * 0.15,color:`${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2,'0')}`},`rect-tile-${i}`));}else if(i % 4 === 2){elements.push(_jsx(RoundedRect,{x:tileX,y:tileY,width:tileSize * 1.2,height:tileSize * 0.8,r:tileSize * 0.1,color:`${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2,'0')}`},`wide-tile-${i}`));}else{elements.push(_jsx(Circle,{cx:tileX + tileSize / 2,cy:tileY + tileSize / 2,r:tileSize / 2,color:`${PUZZLE_COLORS[colorIndex]}${Math.floor(opacity * 255).toString(16).padStart(2,'0')}`},`circle-tile-${i}`));}}return elements;},[width,height]);return _jsxs(View,{style:{flex:1},children:[_jsxs(Canvas,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,width,height},children:[_jsx(Rect,{x:0,y:0,width:width,height:height,children:_jsx(LinearGradient,{start:vec(0,0),end:vec(width,height),colors:[`${PUZZLE_COLORS[0]}30`,`${PUZZLE_COLORS[3]}25`,`${PUZZLE_COLORS[6]}30`,`${PUZZLE_COLORS[9]}25`,`${PUZZLE_COLORS[11]}30` ]})}),_jsx(Rect,{x:0,y:0,width:width,height:height,children:_jsx(LinearGradient,{start:vec(0,0),end:vec(width / 2,height / 2),colors:[`${PUZZLE_COLORS[1]}20`,'transparent',`${PUZZLE_COLORS[4]}20`,'transparent',`${PUZZLE_COLORS[7]}20`,'transparent']})}),_jsx(Rect,{x:0,y:0,width:width,height:height,children:_jsx(LinearGradient,{start:vec(width,0),end:vec(0,height),colors:[`${PUZZLE_COLORS[2]}15`,'transparent',`${PUZZLE_COLORS[5]}15`,'transparent',`${PUZZLE_COLORS[8]}15`,'transparent']})}),generateFloatingTiles,_jsx(RoundedRect,{x:width * 0.08,y:height * 0.12,width:50,height:50,r:8,color:`${PUZZLE_COLORS[0]}50`}),_jsx(RoundedRect,{x:width * 0.85,y:height * 0.82,width:45,height:45,r:7,color:`${PUZZLE_COLORS[3]}50`}),_jsx(RoundedRect,{x:width * 0.82,y:height * 0.18,width:40,height:40,r:6,color:`${PUZZLE_COLORS[6]}50`}),_jsx(RoundedRect,{x:width * 0.12,y:height * 0.75,width:55,height:55,r:9,color:`${PUZZLE_COLORS[9]}50`}),_jsx(RoundedRect,{x:width * 0.47,y:height * 0.08,width:35,height:35,r:5,color:`${PUZZLE_COLORS[11]}50`}),_jsx(RoundedRect,{x:width * 0.15,y:height * 0.47,width:42,height:42,r:6,color:`${PUZZLE_COLORS[5]}50`}),_jsx(RoundedRect,{x:width * 0.75,y:height * 0.57,width:38,height:38,r:6,color:`${PUZZLE_COLORS[8]}50`}),_jsx(RoundedRect,{x:width * 0.57,y:height * 0.87,width:32,height:32,r:5,color:`${PUZZLE_COLORS[1]}50`}),_jsx(Circle,{cx:width * 0.25,cy:height * 0.25,r:18,color:`${PUZZLE_COLORS[4]}45`}),_jsx(Circle,{cx:width * 0.65,cy:height * 0.35,r:22,color:`${PUZZLE_COLORS[7]}45`}),_jsx(Circle,{cx:width * 0.35,cy:height * 0.65,r:16,color:`${PUZZLE_COLORS[10]}45`}),Array.from({length:Math.floor(width / 60)},(_,i)=> _jsx(Rect,{x:i * 60,y:0,width:1,height:height,color:"rgba(255,255,255,0.05)"},`grid-v-${i}`)),Array.from({length:Math.floor(height / 60)},(_,i)=> _jsx(Rect,{x:0,y:i * 60,width:width,height:1,color:"rgba(255,255,255,0.05)"},`grid-h-${i}`))]}),children]});});GameBackground.displayName = 'GameBackground';
|
|
@@ -1,174 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import { View, StyleSheet, Dimensions } from 'react-native';
|
|
5
|
-
import Animated, { useAnimatedStyle, withSpring, useSharedValue, withSequence } from 'react-native-reanimated';
|
|
6
|
-
import { NumbersTile } from "./NumbersTile.js";
|
|
7
|
-
import { useTiles, useGridSize, useEmptyPosition, useSlidingNumbersStore } from "../SlidingNumbersStore.js";
|
|
8
|
-
import { SLIDING_NUMBERS_GAME_CONFIG, SLIDING_NUMBERS_ANIMATION_CONFIG } from "../SlidingNumbersConstants.js";
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
export const NumbersGrid = /*#__PURE__*/React.memo(({
|
|
11
|
-
difficulty
|
|
12
|
-
}) => {
|
|
13
|
-
const tiles = useTiles();
|
|
14
|
-
const gridSize = useGridSize();
|
|
15
|
-
const emptyPosition = useEmptyPosition();
|
|
16
|
-
const isPlaying = useSlidingNumbersStore(state => state.isPlaying);
|
|
17
|
-
const isCompleted = useSlidingNumbersStore(state => state.isCompleted);
|
|
18
|
-
const moveTile = useSlidingNumbersStore(state => state.moveTile);
|
|
19
|
-
const checkCompletion = useSlidingNumbersStore(state => state.checkCompletion);
|
|
20
|
-
const completionScale = useSharedValue(1);
|
|
21
|
-
|
|
22
|
-
// Calculate grid dimensions
|
|
23
|
-
const gridDimensions = useMemo(() => {
|
|
24
|
-
const gap = SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP;
|
|
25
|
-
const padding = (gap + 8) * 2; // padding from grid container
|
|
26
|
-
|
|
27
|
-
// Calculate available space for the grid content
|
|
28
|
-
const {
|
|
29
|
-
width: screenWidth
|
|
30
|
-
} = Dimensions.get('window');
|
|
31
|
-
const maxAvailableWidth = screenWidth - padding - 40; // Leave margin for screen edges
|
|
32
|
-
|
|
33
|
-
// Calculate optimal tile size based on grid size
|
|
34
|
-
const availableForTiles = maxAvailableWidth - gap * (gridSize - 1);
|
|
35
|
-
const optimalTileSize = Math.floor(availableForTiles / gridSize);
|
|
36
|
-
|
|
37
|
-
// Ensure minimum tile size for usability
|
|
38
|
-
const minTileSize = 45;
|
|
39
|
-
const maxTileSize = 80;
|
|
40
|
-
const tileSize = Math.max(minTileSize, Math.min(maxTileSize, optimalTileSize));
|
|
41
|
-
|
|
42
|
-
// Calculate actual content size: tiles + gaps between them
|
|
43
|
-
const tilesWidth = tileSize * gridSize;
|
|
44
|
-
const gapsWidth = gap * (gridSize - 1);
|
|
45
|
-
const contentSize = tilesWidth + gapsWidth;
|
|
46
|
-
const totalSize = contentSize + padding;
|
|
47
|
-
return {
|
|
48
|
-
width: totalSize,
|
|
49
|
-
height: totalSize,
|
|
50
|
-
contentWidth: contentSize,
|
|
51
|
-
contentHeight: contentSize,
|
|
52
|
-
tileSize,
|
|
53
|
-
gap
|
|
54
|
-
};
|
|
55
|
-
}, [gridSize]);
|
|
56
|
-
|
|
57
|
-
// Create grid layout
|
|
58
|
-
const gridLayout = useMemo(() => {
|
|
59
|
-
const layout = [];
|
|
60
|
-
|
|
61
|
-
// Initialize empty grid
|
|
62
|
-
for (let row = 0; row < gridSize; row++) {
|
|
63
|
-
layout[row] = [];
|
|
64
|
-
for (let col = 0; col < gridSize; col++) {
|
|
65
|
-
const rowArray = layout[row];
|
|
66
|
-
if (rowArray) {
|
|
67
|
-
rowArray[col] = null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Place tiles in their current positions
|
|
73
|
-
tiles.forEach(tile => {
|
|
74
|
-
const {
|
|
75
|
-
row,
|
|
76
|
-
col
|
|
77
|
-
} = tile.position;
|
|
78
|
-
if (row >= 0 && row < gridSize && col >= 0 && col < gridSize && layout[row]) {
|
|
79
|
-
layout[row][col] = tile;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return layout;
|
|
83
|
-
}, [tiles, gridSize]);
|
|
84
|
-
|
|
85
|
-
// Memoized tile press handler with useCallback
|
|
86
|
-
const handleTilePress = React.useCallback(tileId => {
|
|
87
|
-
if (!isPlaying || isCompleted) return;
|
|
88
|
-
const success = moveTile(tileId);
|
|
89
|
-
if (success) {
|
|
90
|
-
// Check completion after successful move
|
|
91
|
-
checkCompletion(difficulty);
|
|
92
|
-
}
|
|
93
|
-
}, [isPlaying, isCompleted, moveTile, checkCompletion, difficulty]);
|
|
94
|
-
|
|
95
|
-
// Memoized tile movability checker with useCallback
|
|
96
|
-
const isTileMovable = React.useCallback(tile => {
|
|
97
|
-
if (!tile || tile.value === 0 || !isPlaying || isCompleted) return false;
|
|
98
|
-
const emptyPos = emptyPosition;
|
|
99
|
-
const rowDiff = Math.abs(tile.position.row - emptyPos.row);
|
|
100
|
-
const colDiff = Math.abs(tile.position.col - emptyPos.col);
|
|
101
|
-
return rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;
|
|
102
|
-
}, [emptyPosition, isPlaying, isCompleted]);
|
|
103
|
-
|
|
104
|
-
// Animated style for completion celebration
|
|
105
|
-
const animatedGridStyle = useAnimatedStyle(() => ({
|
|
106
|
-
transform: [{
|
|
107
|
-
scale: completionScale.value
|
|
108
|
-
}]
|
|
109
|
-
}));
|
|
110
|
-
|
|
111
|
-
// Trigger completion animation
|
|
112
|
-
React.useEffect(() => {
|
|
113
|
-
if (isCompleted) {
|
|
114
|
-
completionScale.value = withSequence(withSpring(1.1, SLIDING_NUMBERS_ANIMATION_CONFIG.COMPLETION_CELEBRATION), withSpring(1, SLIDING_NUMBERS_ANIMATION_CONFIG.COMPLETION_CELEBRATION));
|
|
115
|
-
}
|
|
116
|
-
}, [isCompleted]);
|
|
117
|
-
|
|
118
|
-
// Memoize grid container style
|
|
119
|
-
const gridContainerStyle = useMemo(() => [styles.gridContainer, {
|
|
120
|
-
width: gridDimensions.width,
|
|
121
|
-
height: gridDimensions.height
|
|
122
|
-
}, animatedGridStyle], [gridDimensions.width, gridDimensions.height, animatedGridStyle]);
|
|
123
|
-
|
|
124
|
-
// Memoize tile slot style factory
|
|
125
|
-
const getTileSlotStyle = React.useCallback(tileSize => [styles.tileSlot, {
|
|
126
|
-
width: tileSize,
|
|
127
|
-
height: tileSize
|
|
128
|
-
}], []);
|
|
129
|
-
return /*#__PURE__*/_jsx(Animated.View, {
|
|
130
|
-
style: gridContainerStyle,
|
|
131
|
-
children: gridLayout.map((row, rowIndex) => /*#__PURE__*/_jsx(View, {
|
|
132
|
-
style: styles.row,
|
|
133
|
-
children: row.map((tile, colIndex) => /*#__PURE__*/_jsx(View, {
|
|
134
|
-
style: getTileSlotStyle(gridDimensions.tileSize),
|
|
135
|
-
children: tile && tile.value !== 0 && /*#__PURE__*/_jsx(NumbersTile, {
|
|
136
|
-
tile: tile,
|
|
137
|
-
onPress: handleTilePress,
|
|
138
|
-
isMovable: isTileMovable(tile),
|
|
139
|
-
tileSize: gridDimensions.tileSize
|
|
140
|
-
})
|
|
141
|
-
}, `${rowIndex}-${colIndex}`))
|
|
142
|
-
}, rowIndex))
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
const styles = StyleSheet.create({
|
|
146
|
-
gridContainer: {
|
|
147
|
-
backgroundColor: '#FFFFFF',
|
|
148
|
-
borderRadius: 20,
|
|
149
|
-
padding: SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP + 8,
|
|
150
|
-
// Clean shadow like the physical puzzle frame
|
|
151
|
-
shadowColor: '#000',
|
|
152
|
-
shadowOffset: {
|
|
153
|
-
width: 0,
|
|
154
|
-
height: 4
|
|
155
|
-
},
|
|
156
|
-
shadowOpacity: 0.1,
|
|
157
|
-
shadowRadius: 8,
|
|
158
|
-
elevation: 8,
|
|
159
|
-
// Ensure the container fits its content properly
|
|
160
|
-
alignSelf: 'center'
|
|
161
|
-
},
|
|
162
|
-
row: {
|
|
163
|
-
flexDirection: 'row',
|
|
164
|
-
justifyContent: 'center',
|
|
165
|
-
alignItems: 'center'
|
|
166
|
-
},
|
|
167
|
-
tileSlot: {
|
|
168
|
-
justifyContent: 'center',
|
|
169
|
-
alignItems: 'center',
|
|
170
|
-
margin: SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP / 2
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
NumbersGrid.displayName = 'NumbersGrid';
|
|
174
|
-
//# sourceMappingURL=NumbersGrid.js.map
|
|
1
|
+
"use strict";import React,{useMemo}from 'react';import{View,StyleSheet,Dimensions}from 'react-native';import Animated,{useAnimatedStyle,withSpring,useSharedValue,withSequence}from 'react-native-reanimated';import{NumbersTile}from "./NumbersTile.js";import{useTiles,useGridSize,useEmptyPosition,useSlidingNumbersStore}from "../SlidingNumbersStore.js";import{SLIDING_NUMBERS_GAME_CONFIG,SLIDING_NUMBERS_ANIMATION_CONFIG}from "../SlidingNumbersConstants.js";import{jsx as _jsx}from "react/jsx-runtime";export const NumbersGrid = React.memo(({difficulty})=>{const tiles = useTiles();const gridSize = useGridSize();const emptyPosition = useEmptyPosition();const isPlaying = useSlidingNumbersStore(state => state.isPlaying);const isCompleted = useSlidingNumbersStore(state => state.isCompleted);const moveTile = useSlidingNumbersStore(state => state.moveTile);const checkCompletion = useSlidingNumbersStore(state => state.checkCompletion);const completionScale = useSharedValue(1);const gridDimensions = useMemo(()=>{const gap = SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP;const padding =(gap + 8)* 2;const{width:screenWidth}= Dimensions.get('window');const maxAvailableWidth = screenWidth - padding - 40;const availableForTiles = maxAvailableWidth - gap *(gridSize - 1);const optimalTileSize = Math.floor(availableForTiles / gridSize);const minTileSize = 45;const maxTileSize = 80;const tileSize = Math.max(minTileSize,Math.min(maxTileSize,optimalTileSize));const tilesWidth = tileSize * gridSize;const gapsWidth = gap *(gridSize - 1);const contentSize = tilesWidth + gapsWidth;const totalSize = contentSize + padding;return{width:totalSize,height:totalSize,contentWidth:contentSize,contentHeight:contentSize,tileSize,gap};},[gridSize]);const gridLayout = useMemo(()=>{const layout = [];for(let row = 0;row < gridSize;row++){layout[row] = [];for(let col = 0;col < gridSize;col++){const rowArray = layout[row];if(rowArray){rowArray[col] = null;}}}tiles.forEach(tile =>{const{row,col}= tile.position;if(row >= 0 && row < gridSize && col >= 0 && col < gridSize && layout[row]){layout[row][col] = tile;}});return layout;},[tiles,gridSize]);const handleTilePress = React.useCallback(tileId =>{if(!isPlaying || isCompleted)return;const success = moveTile(tileId);if(success){checkCompletion(difficulty);}},[isPlaying,isCompleted,moveTile,checkCompletion,difficulty]);const isTileMovable = React.useCallback(tile =>{if(!tile || tile.value === 0 || !isPlaying || isCompleted)return false;const emptyPos = emptyPosition;const rowDiff = Math.abs(tile.position.row - emptyPos.row);const colDiff = Math.abs(tile.position.col - emptyPos.col);return rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;},[emptyPosition,isPlaying,isCompleted]);const animatedGridStyle = useAnimatedStyle(()=>({transform:[{scale:completionScale.value}]}));React.useEffect(()=>{if(isCompleted){completionScale.value = withSequence(withSpring(1.1,SLIDING_NUMBERS_ANIMATION_CONFIG.COMPLETION_CELEBRATION),withSpring(1,SLIDING_NUMBERS_ANIMATION_CONFIG.COMPLETION_CELEBRATION));}},[isCompleted]);const gridContainerStyle = useMemo(()=> [styles.gridContainer,{width:gridDimensions.width,height:gridDimensions.height},animatedGridStyle],[gridDimensions.width,gridDimensions.height,animatedGridStyle]);const getTileSlotStyle = React.useCallback(tileSize => [styles.tileSlot,{width:tileSize,height:tileSize}],[]);return _jsx(Animated.View,{style:gridContainerStyle,children:gridLayout.map((row,rowIndex)=> _jsx(View,{style:styles.row,children:row.map((tile,colIndex)=> _jsx(View,{style:getTileSlotStyle(gridDimensions.tileSize),children:tile && tile.value !== 0 && _jsx(NumbersTile,{tile:tile,onPress:handleTilePress,isMovable:isTileMovable(tile),tileSize:gridDimensions.tileSize})},`${rowIndex}-${colIndex}`))},rowIndex))});});const styles = StyleSheet.create({gridContainer:{backgroundColor:'#FFFFFF',borderRadius:20,padding:SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP + 8,shadowColor:'#000',shadowOffset:{width:0,height:4},shadowOpacity:0.1,shadowRadius:8,elevation:8,alignSelf:'center'},row:{flexDirection:'row',justifyContent:'center',alignItems:'center'},tileSlot:{justifyContent:'center',alignItems:'center',margin:SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP / 2}});NumbersGrid.displayName = 'NumbersGrid';
|
|
@@ -1,116 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { StyleSheet, TouchableOpacity, Text } from 'react-native';
|
|
5
|
-
import Animated, { useSharedValue, useAnimatedStyle, withSpring, runOnJS } from 'react-native-reanimated';
|
|
6
|
-
import { SLIDING_NUMBERS_COLORS, SLIDING_NUMBERS_GAME_CONFIG, SLIDING_NUMBERS_ANIMATION_CONFIG, NUMBER_WORDS } from "../SlidingNumbersConstants.js";
|
|
7
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
|
|
9
|
-
export const NumbersTile = /*#__PURE__*/React.memo(({
|
|
10
|
-
tile,
|
|
11
|
-
onPress,
|
|
12
|
-
isMovable,
|
|
13
|
-
tileSize
|
|
14
|
-
}) => {
|
|
15
|
-
const scale = useSharedValue(1);
|
|
16
|
-
const opacity = useSharedValue(tile.value === 0 ? 0 : 1);
|
|
17
|
-
const handlePress = React.useCallback(() => {
|
|
18
|
-
if (tile.value !== 0 && isMovable) {
|
|
19
|
-
// Animate press feedback
|
|
20
|
-
scale.value = withSpring(0.95, SLIDING_NUMBERS_ANIMATION_CONFIG.TILE_PRESS, () => {
|
|
21
|
-
scale.value = withSpring(1, SLIDING_NUMBERS_ANIMATION_CONFIG.TILE_PRESS);
|
|
22
|
-
});
|
|
23
|
-
runOnJS(onPress)(tile.id);
|
|
24
|
-
}
|
|
25
|
-
}, [tile.value, tile.id, isMovable, onPress, scale]);
|
|
26
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
27
|
-
transform: [{
|
|
28
|
-
scale: scale.value
|
|
29
|
-
}],
|
|
30
|
-
opacity: opacity.value
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
// Don't render empty tile
|
|
34
|
-
if (tile.value === 0) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Memoized tile color and word
|
|
39
|
-
const {
|
|
40
|
-
tileColor,
|
|
41
|
-
numberWord
|
|
42
|
-
} = React.useMemo(() => {
|
|
43
|
-
const colorIndex = (tile.value - 1) % SLIDING_NUMBERS_COLORS.TILE_COLORS.length;
|
|
44
|
-
const color = SLIDING_NUMBERS_COLORS.TILE_COLORS[colorIndex] || SLIDING_NUMBERS_COLORS.TILE_COLORS[0];
|
|
45
|
-
const word = NUMBER_WORDS[tile.value] || '';
|
|
46
|
-
return {
|
|
47
|
-
tileColor: color,
|
|
48
|
-
numberWord: word
|
|
49
|
-
};
|
|
50
|
-
}, [tile.value]);
|
|
51
|
-
|
|
52
|
-
// Memoized font sizes
|
|
53
|
-
const {
|
|
54
|
-
numberFontSize,
|
|
55
|
-
wordFontSize
|
|
56
|
-
} = React.useMemo(() => ({
|
|
57
|
-
numberFontSize: Math.max(16, tileSize * 0.4),
|
|
58
|
-
wordFontSize: Math.max(8, tileSize * 0.15)
|
|
59
|
-
}), [tileSize]);
|
|
60
|
-
return /*#__PURE__*/_jsxs(AnimatedTouchableOpacity, {
|
|
61
|
-
style: [styles.tile, {
|
|
62
|
-
width: tileSize,
|
|
63
|
-
height: tileSize,
|
|
64
|
-
backgroundColor: tileColor,
|
|
65
|
-
borderColor: tile.isCorrect ? 'transparent' : '#FF4444',
|
|
66
|
-
borderWidth: tile.isCorrect ? 0 : 2
|
|
67
|
-
}, animatedStyle],
|
|
68
|
-
onPress: handlePress,
|
|
69
|
-
activeOpacity: 0.8,
|
|
70
|
-
disabled: !isMovable || tile.value === 0,
|
|
71
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
72
|
-
style: [styles.number, {
|
|
73
|
-
fontSize: numberFontSize
|
|
74
|
-
}],
|
|
75
|
-
children: tile.value
|
|
76
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
77
|
-
style: [styles.word, {
|
|
78
|
-
fontSize: wordFontSize
|
|
79
|
-
}],
|
|
80
|
-
children: numberWord
|
|
81
|
-
})]
|
|
82
|
-
});
|
|
83
|
-
}, (prevProps, nextProps) => {
|
|
84
|
-
// Custom comparison for better memoization
|
|
85
|
-
return prevProps.tile.id === nextProps.tile.id && prevProps.tile.value === nextProps.tile.value && prevProps.tile.isCorrect === nextProps.tile.isCorrect && prevProps.tile.position.row === nextProps.tile.position.row && prevProps.tile.position.col === nextProps.tile.position.col && prevProps.isMovable === nextProps.isMovable && prevProps.tileSize === nextProps.tileSize;
|
|
86
|
-
});
|
|
87
|
-
const styles = StyleSheet.create({
|
|
88
|
-
tile: {
|
|
89
|
-
margin: SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP / 2,
|
|
90
|
-
justifyContent: 'center',
|
|
91
|
-
alignItems: 'center',
|
|
92
|
-
borderRadius: 16,
|
|
93
|
-
// Soft shadow like in the image
|
|
94
|
-
shadowColor: '#000',
|
|
95
|
-
shadowOffset: {
|
|
96
|
-
width: 0,
|
|
97
|
-
height: 3
|
|
98
|
-
},
|
|
99
|
-
shadowOpacity: 0.15,
|
|
100
|
-
shadowRadius: 6,
|
|
101
|
-
elevation: 6
|
|
102
|
-
},
|
|
103
|
-
number: {
|
|
104
|
-
fontWeight: 'bold',
|
|
105
|
-
color: '#000000',
|
|
106
|
-
textAlign: 'center',
|
|
107
|
-
marginBottom: 2
|
|
108
|
-
},
|
|
109
|
-
word: {
|
|
110
|
-
fontWeight: 'normal',
|
|
111
|
-
color: '#000000',
|
|
112
|
-
textAlign: 'center'
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
NumbersTile.displayName = 'NumbersTile';
|
|
116
|
-
//# sourceMappingURL=NumbersTile.js.map
|
|
1
|
+
"use strict";import React from 'react';import{StyleSheet,TouchableOpacity,Text}from 'react-native';import Animated,{useSharedValue,useAnimatedStyle,withSpring,runOnJS}from 'react-native-reanimated';import{SLIDING_NUMBERS_COLORS,SLIDING_NUMBERS_GAME_CONFIG,SLIDING_NUMBERS_ANIMATION_CONFIG,NUMBER_WORDS}from "../SlidingNumbersConstants.js";import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);export const NumbersTile = React.memo(({tile,onPress,isMovable,tileSize})=>{const scale = useSharedValue(1);const opacity = useSharedValue(tile.value === 0 ? 0:1);const handlePress = React.useCallback(()=>{if(tile.value !== 0 && isMovable){scale.value = withSpring(0.95,SLIDING_NUMBERS_ANIMATION_CONFIG.TILE_PRESS,()=>{scale.value = withSpring(1,SLIDING_NUMBERS_ANIMATION_CONFIG.TILE_PRESS);});runOnJS(onPress)(tile.id);}},[tile.value,tile.id,isMovable,onPress,scale]);const animatedStyle = useAnimatedStyle(()=>({transform:[{scale:scale.value}],opacity:opacity.value}));if(tile.value === 0){return null;}const{tileColor,numberWord}= React.useMemo(()=>{const colorIndex =(tile.value - 1)% SLIDING_NUMBERS_COLORS.TILE_COLORS.length;const color = SLIDING_NUMBERS_COLORS.TILE_COLORS[colorIndex] || SLIDING_NUMBERS_COLORS.TILE_COLORS[0];const word = NUMBER_WORDS[tile.value] || '';return{tileColor:color,numberWord:word};},[tile.value]);const{numberFontSize,wordFontSize}= React.useMemo(()=>({numberFontSize:Math.max(16,tileSize * 0.4),wordFontSize:Math.max(8,tileSize * 0.15)}),[tileSize]);return _jsxs(AnimatedTouchableOpacity,{style:[styles.tile,{width:tileSize,height:tileSize,backgroundColor:tileColor,borderColor:tile.isCorrect ? 'transparent':'#FF4444',borderWidth:tile.isCorrect ? 0:2},animatedStyle],onPress:handlePress,activeOpacity:0.8,disabled:!isMovable || tile.value === 0,children:[_jsx(Text,{style:[styles.number,{fontSize:numberFontSize}],children:tile.value}),_jsx(Text,{style:[styles.word,{fontSize:wordFontSize}],children:numberWord})]});},(prevProps,nextProps)=>{return prevProps.tile.id === nextProps.tile.id && prevProps.tile.value === nextProps.tile.value && prevProps.tile.isCorrect === nextProps.tile.isCorrect && prevProps.tile.position.row === nextProps.tile.position.row && prevProps.tile.position.col === nextProps.tile.position.col && prevProps.isMovable === nextProps.isMovable && prevProps.tileSize === nextProps.tileSize;});const styles = StyleSheet.create({tile:{margin:SLIDING_NUMBERS_GAME_CONFIG.TILE_GAP / 2,justifyContent:'center',alignItems:'center',borderRadius:16,shadowColor:'#000',shadowOffset:{width:0,height:3},shadowOpacity:0.15,shadowRadius:6,elevation:6},number:{fontWeight:'bold',color:'#000000',textAlign:'center',marginBottom:2},word:{fontWeight:'normal',color:'#000000',textAlign:'center'}});NumbersTile.displayName = 'NumbersTile';
|
|
@@ -1,64 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import { View, Text, StyleSheet } from 'react-native';
|
|
5
|
-
import { useTimeElapsed } from "../SlidingNumbersStore.js";
|
|
6
|
-
import { SlidingNumbersService } from "../SlidingNumbersService.js";
|
|
7
|
-
import { ScoreBoardContainer } from "../../../helpers/index.js";
|
|
8
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
export const ScoreBoard = /*#__PURE__*/React.memo(({
|
|
10
|
-
offset = 0
|
|
11
|
-
}) => {
|
|
12
|
-
const gameService = useMemo(() => new SlidingNumbersService(), []);
|
|
13
|
-
const timeElapsed = useTimeElapsed();
|
|
14
|
-
const formattedTime = useMemo(() => gameService.formatTime(timeElapsed), [gameService, timeElapsed]);
|
|
15
|
-
return /*#__PURE__*/_jsx(ScoreBoardContainer, {
|
|
16
|
-
offset: offset,
|
|
17
|
-
backgroundColor: "rgba(245, 245, 220, 0.6)",
|
|
18
|
-
borderColor: "rgba(255, 255, 255, 0.3)",
|
|
19
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
20
|
-
style: styles.scoreBoard,
|
|
21
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
22
|
-
style: styles.scoreSection,
|
|
23
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
24
|
-
style: styles.scoreLabel,
|
|
25
|
-
children: "Time Elapsed"
|
|
26
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
27
|
-
style: [styles.timeValue, {
|
|
28
|
-
color: '#3b82f6'
|
|
29
|
-
}],
|
|
30
|
-
children: formattedTime
|
|
31
|
-
})]
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
const styles = StyleSheet.create({
|
|
37
|
-
scoreBoard: {
|
|
38
|
-
flexDirection: 'row',
|
|
39
|
-
justifyContent: 'space-between',
|
|
40
|
-
alignItems: 'center'
|
|
41
|
-
},
|
|
42
|
-
scoreSection: {
|
|
43
|
-
alignItems: 'center',
|
|
44
|
-
flex: 1
|
|
45
|
-
},
|
|
46
|
-
scoreLabel: {
|
|
47
|
-
fontSize: 18,
|
|
48
|
-
fontWeight: 'bold',
|
|
49
|
-
color: '#4a5568',
|
|
50
|
-
// Dark gray for better contrast
|
|
51
|
-
marginBottom: 4
|
|
52
|
-
},
|
|
53
|
-
timeValue: {
|
|
54
|
-
fontSize: 30,
|
|
55
|
-
fontWeight: 'bold'
|
|
56
|
-
},
|
|
57
|
-
hintText: {
|
|
58
|
-
fontSize: 18,
|
|
59
|
-
fontWeight: '600',
|
|
60
|
-
color: '#10b981' // Green color for motivation
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
ScoreBoard.displayName = 'ScoreBoard';
|
|
64
|
-
//# sourceMappingURL=ScoreBoard.js.map
|
|
1
|
+
"use strict";import React,{useMemo}from 'react';import{View,Text,StyleSheet}from 'react-native';import{useTimeElapsed}from "../SlidingNumbersStore.js";import{SlidingNumbersService}from "../SlidingNumbersService.js";import{ScoreBoardContainer}from "../../../helpers/index.js";import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";export const ScoreBoard = React.memo(({offset = 0})=>{const gameService = useMemo(()=> new SlidingNumbersService(),[]);const timeElapsed = useTimeElapsed();const formattedTime = useMemo(()=> gameService.formatTime(timeElapsed),[gameService,timeElapsed]);return _jsx(ScoreBoardContainer,{offset:offset,backgroundColor:"rgba(245,245,220,0.6)",borderColor:"rgba(255,255,255,0.3)",children:_jsx(View,{style:styles.scoreBoard,children:_jsxs(View,{style:styles.scoreSection,children:[_jsx(Text,{style:styles.scoreLabel,children:"Time Elapsed"}),_jsx(Text,{style:[styles.timeValue,{color:'#3b82f6'}],children:formattedTime})]})})});});const styles = StyleSheet.create({scoreBoard:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},scoreSection:{alignItems:'center',flex:1},scoreLabel:{fontSize:16,fontWeight:'bold',color:'#4a5568',marginBottom:4},timeValue:{fontSize:25,fontWeight:'bold'},hintText:{fontSize:18,fontWeight:'600',color:'#10b981'}});ScoreBoard.displayName = 'ScoreBoard';
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
export { NumbersTile } from "./NumbersTile.js";
|
|
4
|
-
export { NumbersGrid } from "./NumbersGrid.js";
|
|
5
|
-
export { ScoreBoard } from "./ScoreBoard.js";
|
|
6
|
-
export { GameBackground } from "./GameBackground.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";export{NumbersTile}from "./NumbersTile.js";export{NumbersGrid}from "./NumbersGrid.js";export{ScoreBoard}from "./ScoreBoard.js";export{GameBackground}from "./GameBackground.js";
|