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.
Files changed (212) hide show
  1. package/README.md +80 -368
  2. package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -167
  3. package/lib/module/games/balloon-blaster/BalloonBlaster.js.map +1 -1
  4. package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js +1 -182
  5. package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js.map +1 -1
  6. package/lib/module/games/balloon-blaster/BalloonBlasterService.js +1 -318
  7. package/lib/module/games/balloon-blaster/BalloonBlasterStore.js +1 -183
  8. package/lib/module/games/balloon-blaster/components/BalloonComponent.js +1 -237
  9. package/lib/module/games/balloon-blaster/components/GameArea.js +1 -156
  10. package/lib/module/games/balloon-blaster/components/GameBackground.js +1 -476
  11. package/lib/module/games/balloon-blaster/components/ScoreBoard.js +1 -112
  12. package/lib/module/games/balloon-blaster/components/ScoreBoard.js.map +1 -1
  13. package/lib/module/games/balloon-blaster/components/index.js +1 -7
  14. package/lib/module/games/candy-crush/CandyCrush.js +1 -131
  15. package/lib/module/games/candy-crush/CandyCrush.js.map +1 -1
  16. package/lib/module/games/candy-crush/CandyCrushConstants.js +1 -125
  17. package/lib/module/games/candy-crush/CandyCrushConstants.js.map +1 -1
  18. package/lib/module/games/candy-crush/CandyCrushService.js +1 -370
  19. package/lib/module/games/candy-crush/CandyCrushStore.js +1 -303
  20. package/lib/module/games/candy-crush/components/CandyItem.js +1 -191
  21. package/lib/module/games/candy-crush/components/GameBackground.js +1 -85
  22. package/lib/module/games/candy-crush/components/GameGrid.js +1 -314
  23. package/lib/module/games/candy-crush/components/ScoreBoard.js +1 -79
  24. package/lib/module/games/candy-crush/components/index.js +1 -7
  25. package/lib/module/games/candy-crush/index.js +1 -6
  26. package/lib/module/games/colors-sort/ColorsSort.js +1 -143
  27. package/lib/module/games/colors-sort/ColorsSort.js.map +1 -1
  28. package/lib/module/games/colors-sort/ColorsSortConstants.js +1 -72
  29. package/lib/module/games/colors-sort/ColorsSortConstants.js.map +1 -1
  30. package/lib/module/games/colors-sort/ColorsSortService.js +1 -255
  31. package/lib/module/games/colors-sort/ColorsSortStore.js +1 -257
  32. package/lib/module/games/colors-sort/ColorsSortStore.js.map +1 -1
  33. package/lib/module/games/colors-sort/components/ColorContainer.js +1 -140
  34. package/lib/module/games/colors-sort/components/GameBackground.js +1 -135
  35. package/lib/module/games/colors-sort/components/ScoreBoard.js +1 -70
  36. package/lib/module/games/colors-sort/components/index.js +1 -6
  37. package/lib/module/games/dino-jump/DinoJump.js +1 -209
  38. package/lib/module/games/dino-jump/DinoJump.js.map +1 -1
  39. package/lib/module/games/dino-jump/DinoJumpConstants.js +1 -189
  40. package/lib/module/games/dino-jump/DinoJumpConstants.js.map +1 -1
  41. package/lib/module/games/dino-jump/DinoJumpService.js +1 -270
  42. package/lib/module/games/dino-jump/DinoJumpStore.js +1 -381
  43. package/lib/module/games/dino-jump/components/DinoSprite.js +1 -418
  44. package/lib/module/games/dino-jump/components/DinoSprite.js.map +1 -1
  45. package/lib/module/games/dino-jump/components/GameArea.js +1 -68
  46. package/lib/module/games/dino-jump/components/GameBackground.js +1 -444
  47. package/lib/module/games/dino-jump/components/ObstacleSprite.js +1 -306
  48. package/lib/module/games/dino-jump/components/ScoreBoard.js +1 -105
  49. package/lib/module/games/dino-jump/components/ScoreBoard.js.map +1 -1
  50. package/lib/module/games/dino-jump/components/StarSprite.js +1 -45
  51. package/lib/module/games/dino-jump/components/index.js +1 -9
  52. package/lib/module/games/flappy-bird/FlappyBird.js +1 -126
  53. package/lib/module/games/flappy-bird/FlappyBird.js.map +1 -1
  54. package/lib/module/games/flappy-bird/FlappyBirdConstants.js +1 -90
  55. package/lib/module/games/flappy-bird/FlappyBirdConstants.js.map +1 -1
  56. package/lib/module/games/flappy-bird/FlappyBirdStore.js +1 -300
  57. package/lib/module/games/flappy-bird/components/Bird.js +1 -87
  58. package/lib/module/games/flappy-bird/components/GameArea.js +1 -87
  59. package/lib/module/games/flappy-bird/components/GameBackground.js +1 -79
  60. package/lib/module/games/flappy-bird/components/Pipes.js +1 -172
  61. package/lib/module/games/flappy-bird/components/ScoreBoard.js +1 -73
  62. package/lib/module/games/flappy-bird/components/index.js +1 -8
  63. package/lib/module/games/fruit-merger/FruitMerger.js +1 -120
  64. package/lib/module/games/fruit-merger/FruitMerger.js.map +1 -1
  65. package/lib/module/games/fruit-merger/FruitMergerConstants.js +1 -119
  66. package/lib/module/games/fruit-merger/FruitMergerConstants.js.map +1 -1
  67. package/lib/module/games/fruit-merger/FruitMergerService.js +1 -13
  68. package/lib/module/games/fruit-merger/FruitMergerStore.js +1 -315
  69. package/lib/module/games/fruit-merger/components/FruitItem.js +1 -102
  70. package/lib/module/games/fruit-merger/components/GameArea.js +1 -103
  71. package/lib/module/games/fruit-merger/components/GameBackground.js +1 -498
  72. package/lib/module/games/fruit-merger/components/ScoreBoard.js +1 -58
  73. package/lib/module/games/fruit-merger/components/index.js +1 -7
  74. package/lib/module/games/fruit-ninja/FruitNinja.js +1 -134
  75. package/lib/module/games/fruit-ninja/FruitNinja.js.map +1 -1
  76. package/lib/module/games/fruit-ninja/FruitNinjaConstants.js +1 -148
  77. package/lib/module/games/fruit-ninja/FruitNinjaConstants.js.map +1 -1
  78. package/lib/module/games/fruit-ninja/FruitNinjaService.js +1 -311
  79. package/lib/module/games/fruit-ninja/FruitNinjaStore.js +1 -191
  80. package/lib/module/games/fruit-ninja/FruitNinjaStore.js.map +1 -1
  81. package/lib/module/games/fruit-ninja/components/FruitComponent.js +1 -99
  82. package/lib/module/games/fruit-ninja/components/GameArea.js +1 -215
  83. package/lib/module/games/fruit-ninja/components/GameBackground.js +1 -1267
  84. package/lib/module/games/fruit-ninja/components/ScoreBoard.js +1 -92
  85. package/lib/module/games/fruit-ninja/components/ScoreBoard.js.map +1 -1
  86. package/lib/module/games/fruit-ninja/components/index.js +1 -7
  87. package/lib/module/games/game-2048/Game2048.js +1 -149
  88. package/lib/module/games/game-2048/Game2048.js.map +1 -1
  89. package/lib/module/games/game-2048/Game2048Constants.js +1 -263
  90. package/lib/module/games/game-2048/Game2048Constants.js.map +1 -1
  91. package/lib/module/games/game-2048/Game2048Service.js +1 -457
  92. package/lib/module/games/game-2048/Game2048Store.js +1 -236
  93. package/lib/module/games/game-2048/components/GameBackground.js +1 -247
  94. package/lib/module/games/game-2048/components/GameGrid.js +1 -139
  95. package/lib/module/games/game-2048/components/GameTile.js +1 -72
  96. package/lib/module/games/game-2048/components/ScoreBoard.js +1 -52
  97. package/lib/module/games/game-2048/components/index.js +1 -7
  98. package/lib/module/games/maze-runner/MazeRunner.js +1 -267
  99. package/lib/module/games/maze-runner/MazeRunner.js.map +1 -1
  100. package/lib/module/games/maze-runner/MazeRunnerConstants.js +1 -100
  101. package/lib/module/games/maze-runner/MazeRunnerConstants.js.map +1 -1
  102. package/lib/module/games/maze-runner/MazeRunnerService.js +1 -586
  103. package/lib/module/games/maze-runner/components/EnhancedBallComponent.js +1 -150
  104. package/lib/module/games/maze-runner/components/EnhancedGameArea.js +1 -370
  105. package/lib/module/games/maze-runner/components/GameBackground.js +1 -175
  106. package/lib/module/games/maze-runner/components/ScoreBoard.js +1 -61
  107. package/lib/module/games/maze-runner/components/SkiaPipeComponent.js +1 -209
  108. package/lib/module/games/maze-runner/components/StaticGameBackground.js +1 -169
  109. package/lib/module/games/maze-runner/components/WallComponent.js +1 -91
  110. package/lib/module/games/maze-runner/components/index.js +1 -8
  111. package/lib/module/games/popit-fidget/PopitFidget.js +1 -285
  112. package/lib/module/games/popit-fidget/PopitFidget.js.map +1 -1
  113. package/lib/module/games/popit-fidget/PopitFidgetConstants.js +1 -113
  114. package/lib/module/games/popit-fidget/PopitFidgetConstants.js.map +1 -1
  115. package/lib/module/games/popit-fidget/PopitFidgetService.js +1 -132
  116. package/lib/module/games/popit-fidget/PopitFidgetStore.js +1 -125
  117. package/lib/module/games/popit-fidget/components/BubbleComponent.js +1 -198
  118. package/lib/module/games/popit-fidget/components/FidgetGrid.js +1 -165
  119. package/lib/module/games/popit-fidget/components/GameBackground.js +1 -177
  120. package/lib/module/games/popit-fidget/components/ScoreBoard.js +1 -61
  121. package/lib/module/games/popit-fidget/components/index.js +1 -7
  122. package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -159
  123. package/lib/module/games/sliding-numbers/SlidingNumbers.js.map +1 -1
  124. package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js +1 -207
  125. package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js.map +1 -1
  126. package/lib/module/games/sliding-numbers/SlidingNumbersService.js +1 -248
  127. package/lib/module/games/sliding-numbers/SlidingNumbersStore.js +1 -274
  128. package/lib/module/games/sliding-numbers/components/GameBackground.js +1 -259
  129. package/lib/module/games/sliding-numbers/components/NumbersGrid.js +1 -174
  130. package/lib/module/games/sliding-numbers/components/NumbersTile.js +1 -116
  131. package/lib/module/games/sliding-numbers/components/ScoreBoard.js +1 -64
  132. package/lib/module/games/sliding-numbers/components/index.js +1 -7
  133. package/lib/module/games/snake/Snake.js +1 -189
  134. package/lib/module/games/snake/Snake.js.map +1 -1
  135. package/lib/module/games/snake/SnakeConstants.js +1 -138
  136. package/lib/module/games/snake/SnakeConstants.js.map +1 -1
  137. package/lib/module/games/snake/SnakeService.js +1 -148
  138. package/lib/module/games/snake/SnakeStore.js +1 -182
  139. package/lib/module/games/snake/components/GameBackground.js +1 -221
  140. package/lib/module/games/snake/components/GameGrid.js +1 -153
  141. package/lib/module/games/snake/components/ScoreBoard.js +1 -51
  142. package/lib/module/games/snake/components/index.js +1 -6
  143. package/lib/module/games/snake/index.js +1 -6
  144. package/lib/module/games/space-fighter/SpaceFighter.js +1 -165
  145. package/lib/module/games/space-fighter/SpaceFighter.js.map +1 -1
  146. package/lib/module/games/space-fighter/SpaceFighterConstants.js +1 -108
  147. package/lib/module/games/space-fighter/SpaceFighterConstants.js.map +1 -1
  148. package/lib/module/games/space-fighter/SpaceFighterService.js +1 -326
  149. package/lib/module/games/space-fighter/SpaceFighterStore.js +1 -209
  150. package/lib/module/games/space-fighter/components/AsteroidComponent.js +1 -113
  151. package/lib/module/games/space-fighter/components/GameArea.js +1 -289
  152. package/lib/module/games/space-fighter/components/GameBackground.js +1 -239
  153. package/lib/module/games/space-fighter/components/ScoreBoard.js +1 -136
  154. package/lib/module/games/space-fighter/components/Spacecraft3D.js +1 -202
  155. package/lib/module/games/space-fighter/components/SpacecraftPath.js +1 -52
  156. package/lib/module/games/space-fighter/components/index.js +1 -9
  157. package/lib/module/games/whack-a-mole/WhackAMole.js +1 -270
  158. package/lib/module/games/whack-a-mole/WhackAMole.js.map +1 -1
  159. package/lib/module/games/whack-a-mole/WhackAMoleConstants.js +1 -115
  160. package/lib/module/games/whack-a-mole/WhackAMoleConstants.js.map +1 -1
  161. package/lib/module/games/whack-a-mole/WhackAMoleService.js +1 -120
  162. package/lib/module/games/whack-a-mole/WhackAMoleStore.js +1 -172
  163. package/lib/module/games/whack-a-mole/components/GameBackground.js +1 -477
  164. package/lib/module/games/whack-a-mole/components/GameGrid.js +1 -97
  165. package/lib/module/games/whack-a-mole/components/GameHole.js +1 -196
  166. package/lib/module/games/whack-a-mole/components/MoleCharacter.js +1 -241
  167. package/lib/module/games/whack-a-mole/components/ScoreBoard.js +1 -67
  168. package/lib/module/games/whack-a-mole/components/ScoreBoard.js.map +1 -1
  169. package/lib/module/games/whack-a-mole/components/index.js +1 -8
  170. package/lib/module/helpers/AnimationFrame.js +1 -120
  171. package/lib/module/helpers/AnimationTracker.js +1 -89
  172. package/lib/module/helpers/ErrorHandler.js +1 -269
  173. package/lib/module/helpers/GameControlButton.js +1 -219
  174. package/lib/module/helpers/GameOverModal.js +1 -144
  175. package/lib/module/helpers/GameOverModal.js.map +1 -1
  176. package/lib/module/helpers/GameSettingsModal.js +1 -287
  177. package/lib/module/helpers/ParticleBlast.js +1 -134
  178. package/lib/module/helpers/ScoreBoardContainer.js +1 -34
  179. package/lib/module/helpers/index.js +1 -12
  180. package/lib/module/index.js +1 -22
  181. package/lib/module/services/GamesConstants.js +1 -178
  182. package/lib/module/services/GamesService.js +1 -112
  183. package/lib/module/services/GamesService.js.map +1 -1
  184. package/lib/module/services/HapticsService.js +1 -77
  185. package/lib/module/services/SoundsService.js +1 -302
  186. package/lib/module/services/UtilsService.js +1 -32
  187. package/lib/typescript/src/games/balloon-blaster/BalloonBlaster.d.ts.map +1 -1
  188. package/lib/typescript/src/games/balloon-blaster/BalloonBlasterConstants.d.ts +1 -1
  189. package/lib/typescript/src/games/balloon-blaster/components/ScoreBoard.d.ts.map +1 -1
  190. package/lib/typescript/src/games/candy-crush/CandyCrushConstants.d.ts +7 -7
  191. package/lib/typescript/src/games/colors-sort/ColorsSort.d.ts.map +1 -1
  192. package/lib/typescript/src/games/colors-sort/ColorsSortStore.d.ts.map +1 -1
  193. package/lib/typescript/src/games/dino-jump/DinoJump.d.ts.map +1 -1
  194. package/lib/typescript/src/games/dino-jump/components/DinoSprite.d.ts.map +1 -1
  195. package/lib/typescript/src/games/flappy-bird/FlappyBird.d.ts.map +1 -1
  196. package/lib/typescript/src/games/flappy-bird/FlappyBirdConstants.d.ts.map +1 -1
  197. package/lib/typescript/src/games/fruit-merger/FruitMerger.d.ts.map +1 -1
  198. package/lib/typescript/src/games/fruit-merger/FruitMergerConstants.d.ts.map +1 -1
  199. package/lib/typescript/src/games/fruit-ninja/FruitNinja.d.ts.map +1 -1
  200. package/lib/typescript/src/games/fruit-ninja/components/ScoreBoard.d.ts.map +1 -1
  201. package/lib/typescript/src/games/game-2048/Game2048.d.ts.map +1 -1
  202. package/lib/typescript/src/games/maze-runner/MazeRunner.d.ts.map +1 -1
  203. package/lib/typescript/src/games/popit-fidget/PopitFidget.d.ts.map +1 -1
  204. package/lib/typescript/src/games/sliding-numbers/SlidingNumbers.d.ts.map +1 -1
  205. package/lib/typescript/src/games/space-fighter/SpaceFighter.d.ts.map +1 -1
  206. package/lib/typescript/src/games/whack-a-mole/WhackAMole.d.ts.map +1 -1
  207. package/lib/typescript/src/games/whack-a-mole/WhackAMoleConstants.d.ts +1 -1
  208. package/lib/typescript/src/games/whack-a-mole/components/ScoreBoard.d.ts.map +1 -1
  209. package/lib/typescript/src/helpers/GameOverModal.d.ts +3 -0
  210. package/lib/typescript/src/helpers/GameOverModal.d.ts.map +1 -1
  211. package/lib/typescript/src/services/GamesConstants.d.ts +7 -7
  212. package/package.json +2 -2
@@ -1,477 +1 @@
1
- "use strict";
2
-
3
- import React from 'react';
4
- import { View, Dimensions } from 'react-native';
5
- import { Canvas, LinearGradient, Rect, Circle, Path, Skia, vec, Group, Shadow } 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
- export const GameBackground = /*#__PURE__*/React.memo(({
12
- children,
13
- offset = 0
14
- }) => {
15
- // Adjust sun and cloud positions based on offset
16
- const sunY = height * 0.15 + offset * 0.9;
17
- const cloud1Y = height * 0.24 + offset * 0.8;
18
- const cloud2Y = height * 0.27 + offset * 0.8;
19
- const cloud3Y = height * 0.19 + offset * 0.8;
20
-
21
- // Create grass path - ground height area (dynamic based on offset)
22
- const buttonAreaHeight = offset > 0 ? 150 : 250; // Height for ground area
23
- const grassStartY = height - buttonAreaHeight;
24
- const createGrassPath = (startX, segments = 8) => {
25
- const path = Skia.Path.Make();
26
- const segmentWidth = width / segments;
27
- path.moveTo(startX, grassStartY);
28
- for (let i = 0; i < segments; i++) {
29
- const x = startX + i * segmentWidth;
30
- const y = grassStartY + Math.sin(i * 0.5) * 8; // Reduced wave amplitude
31
- const controlX = x + segmentWidth / 2;
32
- const controlY = y + Math.cos(i * 0.3) * 6; // Reduced wave amplitude
33
-
34
- path.quadTo(controlX, controlY, x + segmentWidth, y);
35
- }
36
- path.lineTo(width, height);
37
- path.lineTo(startX, height);
38
- path.close();
39
- return path;
40
- };
41
- const grassPath = createGrassPath(0);
42
- return /*#__PURE__*/_jsxs(View, {
43
- style: {
44
- flex: 1
45
- },
46
- children: [/*#__PURE__*/_jsxs(Canvas, {
47
- style: {
48
- position: 'absolute',
49
- width,
50
- height
51
- },
52
- children: [/*#__PURE__*/_jsx(Rect, {
53
- x: 0,
54
- y: 0,
55
- width: width,
56
- height: grassStartY,
57
- children: /*#__PURE__*/_jsx(LinearGradient, {
58
- start: vec(0, 0),
59
- end: vec(0, grassStartY),
60
- colors: ['#87CEEB', '#98D8E8', '#B0E0E6']
61
- })
62
- }), /*#__PURE__*/_jsxs(Group, {
63
- children: [/*#__PURE__*/_jsxs(Circle, {
64
- cx: width * 0.8,
65
- cy: sunY,
66
- r: 40,
67
- children: [/*#__PURE__*/_jsx(LinearGradient, {
68
- start: vec(-40, -40),
69
- end: vec(40, 40),
70
- colors: ['#FFFF99', '#FFD700', '#FFA500', '#FF8C00']
71
- }), /*#__PURE__*/_jsx(Shadow, {
72
- dx: 0,
73
- dy: 0,
74
- blur: 30,
75
- color: "#FFD700"
76
- })]
77
- }), /*#__PURE__*/_jsx(Circle, {
78
- cx: width * 0.8 - 8,
79
- cy: sunY - 8,
80
- r: 15,
81
- children: /*#__PURE__*/_jsx(LinearGradient, {
82
- start: vec(-15, -15),
83
- end: vec(15, 15),
84
- colors: ['#FFFFFF', '#FFFF99']
85
- })
86
- }), Array.from({
87
- length: 16
88
- }, (_, index) => {
89
- const angle = 360 / 16 * index;
90
- const radian = angle * Math.PI / 180;
91
- const isLongRay = index % 2 === 0;
92
- const rayLength = isLongRay ? 25 : 15;
93
- const rayWidth = isLongRay ? 4 : 2;
94
- const startDistance = 45;
95
- const startX = width * 0.8 + Math.cos(radian) * startDistance;
96
- const startY = sunY + Math.sin(radian) * startDistance;
97
- const endX = width * 0.8 + Math.cos(radian) * (startDistance + rayLength);
98
- const endY = sunY + Math.sin(radian) * (startDistance + rayLength);
99
- const rayPath = Skia.Path.Make();
100
- rayPath.moveTo(startX, startY);
101
- rayPath.lineTo(endX, endY);
102
- return /*#__PURE__*/_jsx(Path, {
103
- path: rayPath,
104
- style: "stroke",
105
- strokeWidth: rayWidth,
106
- color: "#FFD700",
107
- opacity: 0.7
108
- }, index);
109
- }), /*#__PURE__*/_jsx(Circle, {
110
- cx: width * 0.8,
111
- cy: sunY,
112
- r: 60,
113
- opacity: 0.1,
114
- children: /*#__PURE__*/_jsx(LinearGradient, {
115
- start: vec(-60, -60),
116
- end: vec(60, 60),
117
- colors: ['#FFD700', 'transparent']
118
- })
119
- })]
120
- }), /*#__PURE__*/_jsxs(Group, {
121
- children: [/*#__PURE__*/_jsxs(Group, {
122
- children: [/*#__PURE__*/_jsx(Circle, {
123
- cx: width * 0.12,
124
- cy: cloud1Y,
125
- r: 16,
126
- color: "#F0F8FF",
127
- opacity: 0.35,
128
- children: /*#__PURE__*/_jsx(Shadow, {
129
- dx: 1,
130
- dy: 2,
131
- blur: 12,
132
- color: "rgba(0,0,0,0.05)"
133
- })
134
- }), /*#__PURE__*/_jsx(Circle, {
135
- cx: width * 0.18,
136
- cy: cloud1Y - (height * 0.24 - height * 0.21),
137
- r: 22,
138
- color: "#FFFFFF",
139
- opacity: 0.45,
140
- children: /*#__PURE__*/_jsx(Shadow, {
141
- dx: 1,
142
- dy: 2,
143
- blur: 12,
144
- color: "rgba(0,0,0,0.05)"
145
- })
146
- }), /*#__PURE__*/_jsx(Circle, {
147
- cx: width * 0.25,
148
- cy: cloud1Y - (height * 0.24 - height * 0.19),
149
- r: 26,
150
- color: "#F8F8FF",
151
- opacity: 0.55,
152
- children: /*#__PURE__*/_jsx(Shadow, {
153
- dx: 2,
154
- dy: 3,
155
- blur: 12,
156
- color: "rgba(0,0,0,0.06)"
157
- })
158
- }), /*#__PURE__*/_jsx(Circle, {
159
- cx: width * 0.32,
160
- cy: cloud1Y - (height * 0.24 - height * 0.21),
161
- r: 20,
162
- color: "#FFFFFF",
163
- opacity: 0.50,
164
- children: /*#__PURE__*/_jsx(Shadow, {
165
- dx: 1,
166
- dy: 2,
167
- blur: 12,
168
- color: "rgba(0,0,0,0.05)"
169
- })
170
- }), /*#__PURE__*/_jsx(Circle, {
171
- cx: width * 0.37,
172
- cy: cloud1Y,
173
- r: 14,
174
- color: "#F0F8FF",
175
- opacity: 0.40,
176
- children: /*#__PURE__*/_jsx(Shadow, {
177
- dx: 1,
178
- dy: 2,
179
- blur: 12,
180
- color: "rgba(0,0,0,0.04)"
181
- })
182
- }), /*#__PURE__*/_jsx(Circle, {
183
- cx: width * 0.15,
184
- cy: cloud1Y + (height * 0.26 - height * 0.24),
185
- r: 8,
186
- color: "#F8F8FF",
187
- opacity: 0.25
188
- }), /*#__PURE__*/_jsx(Circle, {
189
- cx: width * 0.35,
190
- cy: cloud1Y - (height * 0.24 - height * 0.18),
191
- r: 6,
192
- color: "#FFFFFF",
193
- opacity: 0.30
194
- }), /*#__PURE__*/_jsx(Circle, {
195
- cx: width * 0.40,
196
- cy: cloud1Y - (height * 0.24 - height * 0.22),
197
- r: 5,
198
- color: "#F0F8FF",
199
- opacity: 0.20
200
- }), /*#__PURE__*/_jsx(Circle, {
201
- cx: width * 0.22,
202
- cy: cloud1Y - (height * 0.24 - height * 0.18),
203
- r: 7,
204
- color: "#FFFFFF",
205
- opacity: 0.35
206
- }), /*#__PURE__*/_jsx(Circle, {
207
- cx: width * 0.28,
208
- cy: cloud1Y - (height * 0.24 - height * 0.20),
209
- r: 5,
210
- color: "#FFFFFF",
211
- opacity: 0.25
212
- })]
213
- }), /*#__PURE__*/_jsxs(Group, {
214
- children: [/*#__PURE__*/_jsx(Circle, {
215
- cx: width * 0.62,
216
- cy: cloud2Y,
217
- r: 15,
218
- color: "#F0F8FF",
219
- opacity: 0.40,
220
- children: /*#__PURE__*/_jsx(Shadow, {
221
- dx: 1,
222
- dy: 2,
223
- blur: 10,
224
- color: "rgba(0,0,0,0.04)"
225
- })
226
- }), /*#__PURE__*/_jsx(Circle, {
227
- cx: width * 0.69,
228
- cy: cloud2Y - (height * 0.27 - height * 0.24),
229
- r: 19,
230
- color: "#FFFFFF",
231
- opacity: 0.50,
232
- children: /*#__PURE__*/_jsx(Shadow, {
233
- dx: 1,
234
- dy: 2,
235
- blur: 10,
236
- color: "rgba(0,0,0,0.05)"
237
- })
238
- }), /*#__PURE__*/_jsx(Circle, {
239
- cx: width * 0.76,
240
- cy: cloud2Y - (height * 0.27 - height * 0.26),
241
- r: 13,
242
- color: "#F8F8FF",
243
- opacity: 0.45,
244
- children: /*#__PURE__*/_jsx(Shadow, {
245
- dx: 1,
246
- dy: 2,
247
- blur: 10,
248
- color: "rgba(0,0,0,0.04)"
249
- })
250
- }), /*#__PURE__*/_jsx(Circle, {
251
- cx: width * 0.81,
252
- cy: cloud2Y + (height * 0.28 - height * 0.27),
253
- r: 9,
254
- color: "#F0F8FF",
255
- opacity: 0.35,
256
- children: /*#__PURE__*/_jsx(Shadow, {
257
- dx: 1,
258
- dy: 1,
259
- blur: 8,
260
- color: "rgba(0,0,0,0.03)"
261
- })
262
- }), /*#__PURE__*/_jsx(Circle, {
263
- cx: width * 0.65,
264
- cy: cloud2Y + (height * 0.29 - height * 0.27),
265
- r: 6,
266
- color: "#F8F8FF",
267
- opacity: 0.20
268
- }), /*#__PURE__*/_jsx(Circle, {
269
- cx: width * 0.78,
270
- cy: cloud2Y - (height * 0.27 - height * 0.23),
271
- r: 4,
272
- color: "#FFFFFF",
273
- opacity: 0.25
274
- }), /*#__PURE__*/_jsx(Circle, {
275
- cx: width * 0.67,
276
- cy: cloud2Y - (height * 0.27 - height * 0.23),
277
- r: 5,
278
- color: "#FFFFFF",
279
- opacity: 0.30
280
- })]
281
- }), /*#__PURE__*/_jsxs(Group, {
282
- children: [/*#__PURE__*/_jsx(Circle, {
283
- cx: width * 0.84,
284
- cy: cloud3Y,
285
- r: 10,
286
- color: "#F0F8FF",
287
- opacity: 0.35,
288
- children: /*#__PURE__*/_jsx(Shadow, {
289
- dx: 0,
290
- dy: 1,
291
- blur: 6,
292
- color: "rgba(0,0,0,0.03)"
293
- })
294
- }), /*#__PURE__*/_jsx(Circle, {
295
- cx: width * 0.89,
296
- cy: cloud3Y - (height * 0.19 - height * 0.17),
297
- r: 12,
298
- color: "#FFFFFF",
299
- opacity: 0.40,
300
- children: /*#__PURE__*/_jsx(Shadow, {
301
- dx: 0,
302
- dy: 1,
303
- blur: 6,
304
- color: "rgba(0,0,0,0.03)"
305
- })
306
- }), /*#__PURE__*/_jsx(Circle, {
307
- cx: width * 0.93,
308
- cy: cloud3Y,
309
- r: 8,
310
- color: "#F8F8FF",
311
- opacity: 0.30,
312
- children: /*#__PURE__*/_jsx(Shadow, {
313
- dx: 0,
314
- dy: 1,
315
- blur: 6,
316
- color: "rgba(0,0,0,0.02)"
317
- })
318
- }), /*#__PURE__*/_jsx(Circle, {
319
- cx: width * 0.96,
320
- cy: cloud3Y - (height * 0.19 - height * 0.18),
321
- r: 4,
322
- color: "#F0F8FF",
323
- opacity: 0.15
324
- }), /*#__PURE__*/_jsx(Circle, {
325
- cx: width * 0.86,
326
- cy: cloud3Y + (height * 0.21 - height * 0.19),
327
- r: 3,
328
- color: "#FFFFFF",
329
- opacity: 0.20
330
- })]
331
- }), /*#__PURE__*/_jsxs(Group, {
332
- children: [/*#__PURE__*/_jsx(Circle, {
333
- cx: width * 0.45,
334
- cy: height * 0.15,
335
- r: 8,
336
- color: "#F8F8FF",
337
- opacity: 0.25,
338
- children: /*#__PURE__*/_jsx(Shadow, {
339
- dx: 0,
340
- dy: 1,
341
- blur: 4,
342
- color: "rgba(0,0,0,0.02)"
343
- })
344
- }), /*#__PURE__*/_jsx(Circle, {
345
- cx: width * 0.50,
346
- cy: height * 0.13,
347
- r: 10,
348
- color: "#FFFFFF",
349
- opacity: 0.30,
350
- children: /*#__PURE__*/_jsx(Shadow, {
351
- dx: 0,
352
- dy: 1,
353
- blur: 4,
354
- color: "rgba(0,0,0,0.02)"
355
- })
356
- }), /*#__PURE__*/_jsx(Circle, {
357
- cx: width * 0.54,
358
- cy: height * 0.15,
359
- r: 6,
360
- color: "#F0F8FF",
361
- opacity: 0.20,
362
- children: /*#__PURE__*/_jsx(Shadow, {
363
- dx: 0,
364
- dy: 1,
365
- blur: 4,
366
- color: "rgba(0,0,0,0.01)"
367
- })
368
- })]
369
- })]
370
- }), /*#__PURE__*/_jsx(Rect, {
371
- x: 0,
372
- y: grassStartY,
373
- width: width,
374
- height: buttonAreaHeight,
375
- children: /*#__PURE__*/_jsx(LinearGradient, {
376
- start: vec(0, grassStartY),
377
- end: vec(0, height),
378
- colors: ['#8B4513', '#A0522D', '#654321']
379
- })
380
- }), /*#__PURE__*/_jsxs(Path, {
381
- path: grassPath,
382
- children: [/*#__PURE__*/_jsx(LinearGradient, {
383
- start: vec(0, grassStartY - 20),
384
- end: vec(0, grassStartY + 20),
385
- colors: ['#32CD32', '#228B22', '#006400']
386
- }), /*#__PURE__*/_jsx(Shadow, {
387
- dx: 0,
388
- dy: -2,
389
- blur: 4,
390
- color: "rgba(0,0,0,0.2)"
391
- })]
392
- }), Array.from({
393
- length: 50
394
- }, (_, i) => {
395
- const x = width / 50 * i + Math.random() * 15;
396
- const grassHeight = 12 + Math.random() * 18;
397
- const grassType = Math.random();
398
- const bladePath = Skia.Path.Make();
399
- bladePath.moveTo(x, grassStartY);
400
- if (grassType < 0.4) {
401
- // Tall thin grass with slight curve - STATIC
402
- bladePath.quadTo(x + 1, grassStartY - grassHeight * 0.6, x + Math.random() * 2 - 1, grassStartY - grassHeight);
403
- return /*#__PURE__*/_jsx(Path, {
404
- path: bladePath,
405
- style: "stroke",
406
- strokeWidth: 1.5,
407
- color: "#16a34a",
408
- opacity: 0.8 + Math.random() * 0.2
409
- }, `grass-${i}`);
410
- } else if (grassType < 0.7) {
411
- // Medium curved grass - STATIC
412
- bladePath.quadTo(x + 2, grassStartY - grassHeight * 0.4, x + 3, grassStartY - grassHeight);
413
- return /*#__PURE__*/_jsx(Path, {
414
- path: bladePath,
415
- style: "stroke",
416
- strokeWidth: 2,
417
- color: "#15803d",
418
- opacity: 0.7 + Math.random() * 0.3
419
- }, `grass-${i}`);
420
- } else {
421
- // Short wide grass with multiple segments - STATIC
422
- const midHeight = grassHeight * 0.5;
423
- bladePath.quadTo(x + 1, grassStartY - midHeight, x + 2, grassStartY - grassHeight);
424
- return /*#__PURE__*/_jsxs(Group, {
425
- children: [/*#__PURE__*/_jsx(Path, {
426
- path: bladePath,
427
- style: "stroke",
428
- strokeWidth: 2.5,
429
- color: "#166534",
430
- opacity: 0.6 + Math.random() * 0.4
431
- }), Math.random() < 0.3 && /*#__PURE__*/_jsx(Circle, {
432
- cx: x + 2,
433
- cy: grassStartY - grassHeight,
434
- r: 0.8,
435
- color: "#22c55e",
436
- opacity: 0.8
437
- })]
438
- }, `grass-group-${i}`);
439
- }
440
- }), Array.from({
441
- length: 30
442
- }, (_, i) => {
443
- const x = Math.random() * width;
444
- const y = grassStartY - 10 + Math.random() * 20; // Position around grass line
445
- const grassClusterHeight = 8 + Math.random() * 6;
446
- const clusterPath = Skia.Path.Make();
447
- clusterPath.moveTo(x, y);
448
- clusterPath.lineTo(x + Math.random() * 2 - 1, y - grassClusterHeight);
449
- clusterPath.moveTo(x + 2, y);
450
- clusterPath.lineTo(x + 2 + Math.random() * 2 - 1, y - grassClusterHeight * 0.8);
451
- clusterPath.moveTo(x + 4, y);
452
- clusterPath.lineTo(x + 4 + Math.random() * 2 - 1, y - grassClusterHeight * 0.6);
453
- return /*#__PURE__*/_jsx(Path, {
454
- path: clusterPath,
455
- style: "stroke",
456
- strokeWidth: 1,
457
- color: "#22c55e",
458
- opacity: 0.4
459
- }, `cluster-${i}`);
460
- }), Array.from({
461
- length: 15
462
- }, (_, i) => {
463
- const x = Math.random() * width;
464
- const y = grassStartY + 20 + Math.random() * (buttonAreaHeight - 40); // Keep within button area
465
- const size = 2 + Math.random() * 3;
466
- return /*#__PURE__*/_jsx(Circle, {
467
- cx: x,
468
- cy: y,
469
- r: size,
470
- color: "#8B4513",
471
- opacity: 0.6
472
- }, i);
473
- })]
474
- }), children]
475
- });
476
- });
477
- //# sourceMappingURL=GameBackground.js.map
1
+ "use strict";import React from 'react';import{View,Dimensions}from 'react-native';import{Canvas,LinearGradient,Rect,Circle,Path,Skia,vec,Group,Shadow}from '@shopify/react-native-skia';import{jsx as _jsx,jsxs as _jsxs}from "react/jsx-runtime";const{width,height}= Dimensions.get('window');export const GameBackground = React.memo(({children,offset = 0})=>{const sunY = height * 0.15 + offset * 0.9;const cloud1Y = height * 0.24 + offset * 0.8;const cloud2Y = height * 0.27 + offset * 0.8;const cloud3Y = height * 0.19 + offset * 0.8;const buttonAreaHeight = offset > 0 ? 150:250;const grassStartY = height - buttonAreaHeight;const createGrassPath =(startX,segments = 8)=>{const path = Skia.Path.Make();const segmentWidth = width / segments;path.moveTo(startX,grassStartY);for(let i = 0;i < segments;i++){const x = startX + i * segmentWidth;const y = grassStartY + Math.sin(i * 0.5)* 8;const controlX = x + segmentWidth / 2;const controlY = y + Math.cos(i * 0.3)* 6;path.quadTo(controlX,controlY,x + segmentWidth,y);}path.lineTo(width,height);path.lineTo(startX,height);path.close();return path;};const grassPath = createGrassPath(0);return _jsxs(View,{style:{flex:1},children:[_jsxs(Canvas,{style:{position:'absolute',width,height},children:[_jsx(Rect,{x:0,y:0,width:width,height:grassStartY,children:_jsx(LinearGradient,{start:vec(0,0),end:vec(0,grassStartY),colors:['#87CEEB','#98D8E8','#B0E0E6']})}),_jsxs(Group,{children:[_jsxs(Circle,{cx:width * 0.8,cy:sunY,r:40,children:[_jsx(LinearGradient,{start:vec(-40,-40),end:vec(40,40),colors:['#FFFF99','#FFD700','#FFA500','#FF8C00']}),_jsx(Shadow,{dx:0,dy:0,blur:30,color:"#FFD700"})]}),_jsx(Circle,{cx:width * 0.8 - 8,cy:sunY - 8,r:15,children:_jsx(LinearGradient,{start:vec(-15,-15),end:vec(15,15),colors:['#FFFFFF','#FFFF99']})}),Array.from({length:16},(_,index)=>{const angle = 360 / 16 * index;const radian = angle * Math.PI / 180;const isLongRay = index % 2 === 0;const rayLength = isLongRay ? 25:15;const rayWidth = isLongRay ? 4:2;const startDistance = 45;const startX = width * 0.8 + Math.cos(radian)* startDistance;const startY = sunY + Math.sin(radian)* startDistance;const endX = width * 0.8 + Math.cos(radian)*(startDistance + rayLength);const endY = sunY + Math.sin(radian)*(startDistance + rayLength);const rayPath = Skia.Path.Make();rayPath.moveTo(startX,startY);rayPath.lineTo(endX,endY);return _jsx(Path,{path:rayPath,style:"stroke",strokeWidth:rayWidth,color:"#FFD700",opacity:0.7},index);}),_jsx(Circle,{cx:width * 0.8,cy:sunY,r:60,opacity:0.1,children:_jsx(LinearGradient,{start:vec(-60,-60),end:vec(60,60),colors:['#FFD700','transparent']})})]}),_jsxs(Group,{children:[_jsxs(Group,{children:[_jsx(Circle,{cx:width * 0.12,cy:cloud1Y,r:16,color:"#F0F8FF",opacity:0.35,children:_jsx(Shadow,{dx:1,dy:2,blur:12,color:"rgba(0,0,0,0.05)"})}),_jsx(Circle,{cx:width * 0.18,cy:cloud1Y -(height * 0.24 - height * 0.21),r:22,color:"#FFFFFF",opacity:0.45,children:_jsx(Shadow,{dx:1,dy:2,blur:12,color:"rgba(0,0,0,0.05)"})}),_jsx(Circle,{cx:width * 0.25,cy:cloud1Y -(height * 0.24 - height * 0.19),r:26,color:"#F8F8FF",opacity:0.55,children:_jsx(Shadow,{dx:2,dy:3,blur:12,color:"rgba(0,0,0,0.06)"})}),_jsx(Circle,{cx:width * 0.32,cy:cloud1Y -(height * 0.24 - height * 0.21),r:20,color:"#FFFFFF",opacity:0.50,children:_jsx(Shadow,{dx:1,dy:2,blur:12,color:"rgba(0,0,0,0.05)"})}),_jsx(Circle,{cx:width * 0.37,cy:cloud1Y,r:14,color:"#F0F8FF",opacity:0.40,children:_jsx(Shadow,{dx:1,dy:2,blur:12,color:"rgba(0,0,0,0.04)"})}),_jsx(Circle,{cx:width * 0.15,cy:cloud1Y +(height * 0.26 - height * 0.24),r:8,color:"#F8F8FF",opacity:0.25}),_jsx(Circle,{cx:width * 0.35,cy:cloud1Y -(height * 0.24 - height * 0.18),r:6,color:"#FFFFFF",opacity:0.30}),_jsx(Circle,{cx:width * 0.40,cy:cloud1Y -(height * 0.24 - height * 0.22),r:5,color:"#F0F8FF",opacity:0.20}),_jsx(Circle,{cx:width * 0.22,cy:cloud1Y -(height * 0.24 - height * 0.18),r:7,color:"#FFFFFF",opacity:0.35}),_jsx(Circle,{cx:width * 0.28,cy:cloud1Y -(height * 0.24 - height * 0.20),r:5,color:"#FFFFFF",opacity:0.25})]}),_jsxs(Group,{children:[_jsx(Circle,{cx:width * 0.62,cy:cloud2Y,r:15,color:"#F0F8FF",opacity:0.40,children:_jsx(Shadow,{dx:1,dy:2,blur:10,color:"rgba(0,0,0,0.04)"})}),_jsx(Circle,{cx:width * 0.69,cy:cloud2Y -(height * 0.27 - height * 0.24),r:19,color:"#FFFFFF",opacity:0.50,children:_jsx(Shadow,{dx:1,dy:2,blur:10,color:"rgba(0,0,0,0.05)"})}),_jsx(Circle,{cx:width * 0.76,cy:cloud2Y -(height * 0.27 - height * 0.26),r:13,color:"#F8F8FF",opacity:0.45,children:_jsx(Shadow,{dx:1,dy:2,blur:10,color:"rgba(0,0,0,0.04)"})}),_jsx(Circle,{cx:width * 0.81,cy:cloud2Y +(height * 0.28 - height * 0.27),r:9,color:"#F0F8FF",opacity:0.35,children:_jsx(Shadow,{dx:1,dy:1,blur:8,color:"rgba(0,0,0,0.03)"})}),_jsx(Circle,{cx:width * 0.65,cy:cloud2Y +(height * 0.29 - height * 0.27),r:6,color:"#F8F8FF",opacity:0.20}),_jsx(Circle,{cx:width * 0.78,cy:cloud2Y -(height * 0.27 - height * 0.23),r:4,color:"#FFFFFF",opacity:0.25}),_jsx(Circle,{cx:width * 0.67,cy:cloud2Y -(height * 0.27 - height * 0.23),r:5,color:"#FFFFFF",opacity:0.30})]}),_jsxs(Group,{children:[_jsx(Circle,{cx:width * 0.84,cy:cloud3Y,r:10,color:"#F0F8FF",opacity:0.35,children:_jsx(Shadow,{dx:0,dy:1,blur:6,color:"rgba(0,0,0,0.03)"})}),_jsx(Circle,{cx:width * 0.89,cy:cloud3Y -(height * 0.19 - height * 0.17),r:12,color:"#FFFFFF",opacity:0.40,children:_jsx(Shadow,{dx:0,dy:1,blur:6,color:"rgba(0,0,0,0.03)"})}),_jsx(Circle,{cx:width * 0.93,cy:cloud3Y,r:8,color:"#F8F8FF",opacity:0.30,children:_jsx(Shadow,{dx:0,dy:1,blur:6,color:"rgba(0,0,0,0.02)"})}),_jsx(Circle,{cx:width * 0.96,cy:cloud3Y -(height * 0.19 - height * 0.18),r:4,color:"#F0F8FF",opacity:0.15}),_jsx(Circle,{cx:width * 0.86,cy:cloud3Y +(height * 0.21 - height * 0.19),r:3,color:"#FFFFFF",opacity:0.20})]}),_jsxs(Group,{children:[_jsx(Circle,{cx:width * 0.45,cy:height * 0.15,r:8,color:"#F8F8FF",opacity:0.25,children:_jsx(Shadow,{dx:0,dy:1,blur:4,color:"rgba(0,0,0,0.02)"})}),_jsx(Circle,{cx:width * 0.50,cy:height * 0.13,r:10,color:"#FFFFFF",opacity:0.30,children:_jsx(Shadow,{dx:0,dy:1,blur:4,color:"rgba(0,0,0,0.02)"})}),_jsx(Circle,{cx:width * 0.54,cy:height * 0.15,r:6,color:"#F0F8FF",opacity:0.20,children:_jsx(Shadow,{dx:0,dy:1,blur:4,color:"rgba(0,0,0,0.01)"})})]})]}),_jsx(Rect,{x:0,y:grassStartY,width:width,height:buttonAreaHeight,children:_jsx(LinearGradient,{start:vec(0,grassStartY),end:vec(0,height),colors:['#8B4513','#A0522D','#654321']})}),_jsxs(Path,{path:grassPath,children:[_jsx(LinearGradient,{start:vec(0,grassStartY - 20),end:vec(0,grassStartY + 20),colors:['#32CD32','#228B22','#006400']}),_jsx(Shadow,{dx:0,dy:-2,blur:4,color:"rgba(0,0,0,0.2)"})]}),Array.from({length:50},(_,i)=>{const x = width / 50 * i + Math.random()* 15;const grassHeight = 12 + Math.random()* 18;const grassType = Math.random();const bladePath = Skia.Path.Make();bladePath.moveTo(x,grassStartY);if(grassType < 0.4){bladePath.quadTo(x + 1,grassStartY - grassHeight * 0.6,x + Math.random()* 2 - 1,grassStartY - grassHeight);return _jsx(Path,{path:bladePath,style:"stroke",strokeWidth:1.5,color:"#16a34a",opacity:0.8 + Math.random()* 0.2},`grass-${i}`);}else if(grassType < 0.7){bladePath.quadTo(x + 2,grassStartY - grassHeight * 0.4,x + 3,grassStartY - grassHeight);return _jsx(Path,{path:bladePath,style:"stroke",strokeWidth:2,color:"#15803d",opacity:0.7 + Math.random()* 0.3},`grass-${i}`);}else{const midHeight = grassHeight * 0.5;bladePath.quadTo(x + 1,grassStartY - midHeight,x + 2,grassStartY - grassHeight);return _jsxs(Group,{children:[_jsx(Path,{path:bladePath,style:"stroke",strokeWidth:2.5,color:"#166534",opacity:0.6 + Math.random()* 0.4}),Math.random()< 0.3 && _jsx(Circle,{cx:x + 2,cy:grassStartY - grassHeight,r:0.8,color:"#22c55e",opacity:0.8})]},`grass-group-${i}`);}}),Array.from({length:30},(_,i)=>{const x = Math.random()* width;const y = grassStartY - 10 + Math.random()* 20;const grassClusterHeight = 8 + Math.random()* 6;const clusterPath = Skia.Path.Make();clusterPath.moveTo(x,y);clusterPath.lineTo(x + Math.random()* 2 - 1,y - grassClusterHeight);clusterPath.moveTo(x + 2,y);clusterPath.lineTo(x + 2 + Math.random()* 2 - 1,y - grassClusterHeight * 0.8);clusterPath.moveTo(x + 4,y);clusterPath.lineTo(x + 4 + Math.random()* 2 - 1,y - grassClusterHeight * 0.6);return _jsx(Path,{path:clusterPath,style:"stroke",strokeWidth:1,color:"#22c55e",opacity:0.4},`cluster-${i}`);}),Array.from({length:15},(_,i)=>{const x = Math.random()* width;const y = grassStartY + 20 + Math.random()*(buttonAreaHeight - 40);const size = 2 + Math.random()* 3;return _jsx(Circle,{cx:x,cy:y,r:size,color:"#8B4513",opacity:0.6},i);})]}),children]});});
@@ -1,97 +1 @@
1
- "use strict";
2
-
3
- import React, { useMemo } from 'react';
4
- import { View, StyleSheet, Dimensions } from 'react-native';
5
- import { GAME_CONFIG } from "../WhackAMoleService.js";
6
- import { GameHole } from "./GameHole.js";
7
-
8
- // Highly optimized GameHole that only re-renders when its specific hole changes
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- const MemoizedGameHole = /*#__PURE__*/React.memo(GameHole, (prevProps, nextProps) => {
11
- // Only re-render if this specific hole's state changes
12
- return prevProps.hole.id === nextProps.hole.id && prevProps.hole.isActive === nextProps.hole.isActive && prevProps.moleAnimation === nextProps.moleAnimation && prevProps.hitAnimation === nextProps.hitAnimation && prevProps.onPress === nextProps.onPress && prevProps.holeSize === nextProps.holeSize;
13
- });
14
- export const GameGrid = /*#__PURE__*/React.memo(({
15
- holes,
16
- moleAnimations,
17
- hitAnimations,
18
- onHolePress,
19
- gridSize = 3
20
- }) => {
21
- // Calculate responsive dimensions with maximum width for tablets
22
- const responsiveDimensions = useMemo(() => {
23
- const {
24
- width: screenWidth
25
- } = Dimensions.get('window');
26
-
27
- // Maximum container width for tablets (600px max)
28
- const maxContainerWidth = Math.min(screenWidth * 0.9, 600);
29
-
30
- // Calculate hole size based on grid size and container width
31
- const availableWidth = maxContainerWidth - gridSize * 8; // Account for gaps
32
- const maxHoleSize = availableWidth / gridSize;
33
-
34
- // Use smaller of calculated size or original size, with minimum of 60px
35
- const holeSize = Math.max(Math.min(maxHoleSize, GAME_CONFIG.HOLE_SIZE), 60);
36
- return {
37
- containerWidth: maxContainerWidth,
38
- holeSize,
39
- gridWidth: gridSize * (holeSize + 8) // Account for gaps
40
- };
41
- }, [gridSize]);
42
-
43
- // Memoize style calculations to prevent re-computation on every render
44
- const gridStyle = useMemo(() => ({
45
- width: responsiveDimensions.gridWidth,
46
- maxWidth: responsiveDimensions.containerWidth
47
- }), [responsiveDimensions]);
48
- const paddingStyle = useMemo(() => gridSize === 4 ? styles.smallPadding : styles.largePadding, [gridSize]);
49
- const gapStyle = useMemo(() => gridSize === 4 ? styles.smallGap : styles.largeGap, [gridSize]);
50
- return /*#__PURE__*/_jsx(View, {
51
- style: [styles.gameArea, paddingStyle],
52
- children: /*#__PURE__*/_jsx(View, {
53
- style: [styles.gameGrid, gapStyle, gridStyle],
54
- children: holes.map((hole, index) => {
55
- const moleAnimation = moleAnimations[index];
56
- const hitAnimation = hitAnimations[index];
57
- if (!moleAnimation || !hitAnimation) {
58
- return null;
59
- }
60
- return /*#__PURE__*/_jsx(MemoizedGameHole, {
61
- hole: hole,
62
- moleAnimation: moleAnimation,
63
- hitAnimation: hitAnimation,
64
- onPress: onHolePress,
65
- holeSize: responsiveDimensions.holeSize
66
- }, hole.id);
67
- })
68
- })
69
- });
70
- });
71
- const styles = StyleSheet.create({
72
- gameArea: {
73
- flex: 1,
74
- justifyContent: 'center',
75
- alignItems: 'center'
76
- },
77
- smallPadding: {
78
- paddingHorizontal: 16,
79
- paddingVertical: 20
80
- },
81
- largePadding: {
82
- paddingVertical: 20
83
- },
84
- gameGrid: {
85
- flexDirection: 'row',
86
- flexWrap: 'wrap',
87
- justifyContent: 'center',
88
- alignItems: 'center'
89
- },
90
- smallGap: {
91
- gap: 4
92
- },
93
- largeGap: {
94
- gap: 8
95
- }
96
- });
97
- //# sourceMappingURL=GameGrid.js.map
1
+ "use strict";import React,{useMemo}from 'react';import{View,StyleSheet,Dimensions}from 'react-native';import{GAME_CONFIG}from "../WhackAMoleService.js";import{GameHole}from "./GameHole.js";import{jsx as _jsx}from "react/jsx-runtime";const MemoizedGameHole = React.memo(GameHole,(prevProps,nextProps)=>{return prevProps.hole.id === nextProps.hole.id && prevProps.hole.isActive === nextProps.hole.isActive && prevProps.moleAnimation === nextProps.moleAnimation && prevProps.hitAnimation === nextProps.hitAnimation && prevProps.onPress === nextProps.onPress && prevProps.holeSize === nextProps.holeSize;});export const GameGrid = React.memo(({holes,moleAnimations,hitAnimations,onHolePress,gridSize = 3})=>{const responsiveDimensions = useMemo(()=>{const{width:screenWidth}= Dimensions.get('window');const maxContainerWidth = Math.min(screenWidth * 0.9,600);const availableWidth = maxContainerWidth - gridSize * 8;const maxHoleSize = availableWidth / gridSize;const holeSize = Math.max(Math.min(maxHoleSize,GAME_CONFIG.HOLE_SIZE),60);return{containerWidth:maxContainerWidth,holeSize,gridWidth:gridSize *(holeSize + 8)};},[gridSize]);const gridStyle = useMemo(()=>({width:responsiveDimensions.gridWidth,maxWidth:responsiveDimensions.containerWidth}),[responsiveDimensions]);const paddingStyle = useMemo(()=> gridSize === 4 ? styles.smallPadding:styles.largePadding,[gridSize]);const gapStyle = useMemo(()=> gridSize === 4 ? styles.smallGap:styles.largeGap,[gridSize]);return _jsx(View,{style:[styles.gameArea,paddingStyle],children:_jsx(View,{style:[styles.gameGrid,gapStyle,gridStyle],children:holes.map((hole,index)=>{const moleAnimation = moleAnimations[index];const hitAnimation = hitAnimations[index];if(!moleAnimation || !hitAnimation){return null;}return _jsx(MemoizedGameHole,{hole:hole,moleAnimation:moleAnimation,hitAnimation:hitAnimation,onPress:onHolePress,holeSize:responsiveDimensions.holeSize},hole.id);})})});});const styles = StyleSheet.create({gameArea:{flex:1,justifyContent:'center',alignItems:'center'},smallPadding:{paddingHorizontal:16,paddingVertical:20},largePadding:{paddingVertical:20},gameGrid:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',alignItems:'center'},smallGap:{gap:4},largeGap:{gap:8}});