retro-pong-game 2.0.0 → 3.0.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 +10 -10
- package/dist/pong-game.es.js +1275 -1030
- package/dist/pong-game.umd.js +70 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A retro-style Pong game that runs in any browser. Drop it onto your website with
|
|
|
4
4
|
|
|
5
5
|
**[Live demo](https://chriscreativecode.com/retro-pong-game/)**
|
|
6
6
|
|
|
7
|
-

|
|
7
|
+

|
|
8
8
|
|
|
9
9
|
- Animated starfield or nebular background
|
|
10
10
|
- Particle effects on paddle hits
|
|
@@ -37,7 +37,7 @@ The game appends a `<canvas>` inside this element automatically.
|
|
|
37
37
|
|
|
38
38
|
### 2. Import and create the game
|
|
39
39
|
|
|
40
|
-
**
|
|
40
|
+
**New to this package?** Start with `isAdmin: true` to configure everything visually first:
|
|
41
41
|
|
|
42
42
|
```js
|
|
43
43
|
import { PongGame } from 'retro-pong-game';
|
|
@@ -56,7 +56,7 @@ const game = new PongGame(
|
|
|
56
56
|
);
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
If you already know your config, pass it directly:
|
|
60
60
|
|
|
61
61
|
```js
|
|
62
62
|
const game = new PongGame(
|
|
@@ -74,9 +74,9 @@ const game = new PongGame(
|
|
|
74
74
|
);
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
### 3. Clean up
|
|
77
|
+
### 3. Clean up
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
Call `destroy()` before removing the element from the page:
|
|
80
80
|
|
|
81
81
|
```js
|
|
82
82
|
game.destroy();
|
|
@@ -244,19 +244,19 @@ The config is deep-merged in this order (later layers win):
|
|
|
244
244
|
|---|---|---|---|
|
|
245
245
|
| `autoSize` | `boolean` | `false` | Size the canvas to fill its container element at startup |
|
|
246
246
|
| `autoResize` | `boolean` | `false` | Automatically resize the canvas when the container changes size (uses `ResizeObserver`) |
|
|
247
|
-
| `canvasWidth` | `number` | `400` | Canvas width in px
|
|
248
|
-
| `canvasHeight` | `number` | `300` | Canvas height in px
|
|
247
|
+
| `canvasWidth` | `number` | `400` | Canvas width in px (ignored when `autoSize` is true) |
|
|
248
|
+
| `canvasHeight` | `number` | `300` | Canvas height in px (ignored when `autoSize` is true) |
|
|
249
249
|
| `paddleWidth` | `number` | `70` | Paddle width in px |
|
|
250
250
|
| `paddleHeight` | `number` | `10` | Paddle height in px |
|
|
251
251
|
| `ballDiameter` | `number` | `7` | Ball diameter in px |
|
|
252
252
|
| `ballSpeed` | `number` | `3` | Starting ball speed (px per frame) |
|
|
253
253
|
| `paddleMoveStep` | `number` | `4` | Paddle speed while an arrow key is held (px per frame) |
|
|
254
|
-
| `difficultyLevel` | `number` | `1` | Starting AI difficulty
|
|
254
|
+
| `difficultyLevel` | `number` | `1` | Starting AI difficulty; higher = faster and more precise AI |
|
|
255
255
|
| `particleBounce` | `boolean` | `true` | Particle burst when the ball hits a paddle |
|
|
256
256
|
| `hasSound` | `boolean` | `false` | Enable sound effects |
|
|
257
257
|
| `showSettings` | `boolean` | `true` | Show the gear icon that opens the in-game settings panel. Set to `false` to lock the settings from players |
|
|
258
258
|
| `isAdmin` | `boolean` | `false` | Unlock difficulty and timing controls in the settings panel, plus a JSON export of the current config (see [Admin mode](#admin-mode)) |
|
|
259
|
-
| `onSoundToggle` | `(enabled: boolean) => void` |
|
|
259
|
+
| `onSoundToggle` | `(enabled: boolean) => void` | - | Called when the player toggles the sound icon |
|
|
260
260
|
| `timer` | [`TimerConfig`](#timerconfig) | see below | Countdown timer settings |
|
|
261
261
|
| `colors` | [`ColorConfig`](#colorconfig) | see below | Colors for game elements |
|
|
262
262
|
| `animatedBackground` | [`AnimatedBackgroundConfig`](#animatedbackgroundconfig) | see below | Background animation |
|
|
@@ -375,7 +375,7 @@ The game includes a built-in settings panel (gear icon in the corner of the canv
|
|
|
375
375
|
To reset all saved settings back to defaults:
|
|
376
376
|
|
|
377
377
|
```js
|
|
378
|
-
localStorage.removeItem('chriscreativecode.com');
|
|
378
|
+
localStorage.removeItem('chriscreativecode.com-retro-pong-game');
|
|
379
379
|
```
|
|
380
380
|
|
|
381
381
|
---
|