pac-man-phaser 1.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.
Files changed (79) hide show
  1. package/README.md +61 -0
  2. package/assets/spritesheet.png +0 -0
  3. package/dist/game/_scenes/game-over-scene.d.ts +9 -0
  4. package/dist/game/_scenes/game-over-scene.d.ts.map +1 -0
  5. package/dist/game/_scenes/game-over-scene.js +59 -0
  6. package/dist/game/_scenes/game-over-scene.js.map +1 -0
  7. package/dist/game/_scenes/pac-man-scene.d.ts +14 -0
  8. package/dist/game/_scenes/pac-man-scene.d.ts.map +1 -0
  9. package/dist/game/_scenes/pac-man-scene.js +148 -0
  10. package/dist/game/_scenes/pac-man-scene.js.map +1 -0
  11. package/dist/game/_scenes/pause-scene.d.ts +5 -0
  12. package/dist/game/_scenes/pause-scene.d.ts.map +1 -0
  13. package/dist/game/_scenes/pause-scene.js +28 -0
  14. package/dist/game/_scenes/pause-scene.js.map +1 -0
  15. package/dist/game/constants.d.ts +19 -0
  16. package/dist/game/constants.d.ts.map +1 -0
  17. package/dist/game/constants.js +27 -0
  18. package/dist/game/constants.js.map +1 -0
  19. package/dist/game/sprites/abstracts/action-item.d.ts +5 -0
  20. package/dist/game/sprites/abstracts/action-item.d.ts.map +1 -0
  21. package/dist/game/sprites/abstracts/action-item.js +4 -0
  22. package/dist/game/sprites/abstracts/action-item.js.map +1 -0
  23. package/dist/game/sprites/abstracts/item.d.ts +6 -0
  24. package/dist/game/sprites/abstracts/item.d.ts.map +1 -0
  25. package/dist/game/sprites/abstracts/item.js +12 -0
  26. package/dist/game/sprites/abstracts/item.js.map +1 -0
  27. package/dist/game/sprites/characters/character.d.ts +20 -0
  28. package/dist/game/sprites/characters/character.d.ts.map +1 -0
  29. package/dist/game/sprites/characters/character.js +125 -0
  30. package/dist/game/sprites/characters/character.js.map +1 -0
  31. package/dist/game/sprites/ghosts/blinky.d.ts +11 -0
  32. package/dist/game/sprites/ghosts/blinky.d.ts.map +1 -0
  33. package/dist/game/sprites/ghosts/blinky.js +26 -0
  34. package/dist/game/sprites/ghosts/blinky.js.map +1 -0
  35. package/dist/game/sprites/ghosts/clyde.d.ts +10 -0
  36. package/dist/game/sprites/ghosts/clyde.d.ts.map +1 -0
  37. package/dist/game/sprites/ghosts/clyde.js +31 -0
  38. package/dist/game/sprites/ghosts/clyde.js.map +1 -0
  39. package/dist/game/sprites/ghosts/ghost.d.ts +48 -0
  40. package/dist/game/sprites/ghosts/ghost.d.ts.map +1 -0
  41. package/dist/game/sprites/ghosts/ghost.js +323 -0
  42. package/dist/game/sprites/ghosts/ghost.js.map +1 -0
  43. package/dist/game/sprites/ghosts/inky.d.ts +11 -0
  44. package/dist/game/sprites/ghosts/inky.d.ts.map +1 -0
  45. package/dist/game/sprites/ghosts/inky.js +50 -0
  46. package/dist/game/sprites/ghosts/inky.js.map +1 -0
  47. package/dist/game/sprites/ghosts/pinky.d.ts +10 -0
  48. package/dist/game/sprites/ghosts/pinky.d.ts.map +1 -0
  49. package/dist/game/sprites/ghosts/pinky.js +42 -0
  50. package/dist/game/sprites/ghosts/pinky.js.map +1 -0
  51. package/dist/game/sprites/pac-man.d.ts +17 -0
  52. package/dist/game/sprites/pac-man.d.ts.map +1 -0
  53. package/dist/game/sprites/pac-man.js +264 -0
  54. package/dist/game/sprites/pac-man.js.map +1 -0
  55. package/dist/game/sprites/pellet.d.ts +7 -0
  56. package/dist/game/sprites/pellet.d.ts.map +1 -0
  57. package/dist/game/sprites/pellet.js +15 -0
  58. package/dist/game/sprites/pellet.js.map +1 -0
  59. package/dist/game/sprites/super-pellet.d.ts +13 -0
  60. package/dist/game/sprites/super-pellet.d.ts.map +1 -0
  61. package/dist/game/sprites/super-pellet.js +67 -0
  62. package/dist/game/sprites/super-pellet.js.map +1 -0
  63. package/dist/game/sprites/wall.d.ts +5 -0
  64. package/dist/game/sprites/wall.d.ts.map +1 -0
  65. package/dist/game/sprites/wall.js +16 -0
  66. package/dist/game/sprites/wall.js.map +1 -0
  67. package/dist/game/ui/score-display.d.ts +7 -0
  68. package/dist/game/ui/score-display.d.ts.map +1 -0
  69. package/dist/game/ui/score-display.js +19 -0
  70. package/dist/game/ui/score-display.js.map +1 -0
  71. package/dist/index.d.ts +3 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +3 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/pac-man.d.ts +2 -0
  76. package/dist/pac-man.d.ts.map +1 -0
  77. package/dist/pac-man.js +19 -0
  78. package/dist/pac-man.js.map +1 -0
  79. package/package.json +73 -0
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Pac-Man Map Generator
2
+
3
+ A lightweight TypeScript utility for generating random Pac-Man maps.
4
+
5
+ ## 📦 Installation
6
+
7
+ ```bash
8
+ npm install pac-man-map-generator
9
+ ```
10
+
11
+
12
+ ## 🚀 Developemnt
13
+
14
+ A full example can be found in this repo, under the example folder, along with a playground for messing with the options.
15
+
16
+ Note: This repo uses NPM Monorepos. For shorthand, installation and viewing can be done from the root by running:
17
+
18
+ ```bash
19
+ npm i -D
20
+ npm run dev
21
+ ```
22
+
23
+ ## ⚙️ API
24
+
25
+ ### `generateMap(options: MapGeneratorOptions): BlockMap`
26
+
27
+ Generates a Pac-Man style map.
28
+
29
+ #### `MapGeneratorOptions`
30
+
31
+ The map generator takes in an optional configuration object. If it is omitted, some default settings will be applied to make a map very similar to a standard pacman map.
32
+
33
+ ```ts
34
+ {
35
+ map: {
36
+ bounds: {
37
+ width: number,
38
+ height: number,
39
+ }
40
+ path?: {
41
+ min?: number;
42
+ max?: number;
43
+ },
44
+ teleporter: {
45
+ min: number;
46
+ max: number;
47
+ },
48
+ },
49
+ mapMaker: {
50
+ manager: {
51
+ min: number;
52
+ max: number;
53
+ },
54
+ builder: {
55
+ minDistanceBeforeTurn: number;
56
+ maxDistanceBeforeTurn: number;
57
+ },
58
+ },
59
+ debug?: boolean
60
+ }
61
+ ```
Binary file
@@ -0,0 +1,9 @@
1
+ type GameOverData = {
2
+ score: number;
3
+ };
4
+ export declare class GameOverScene extends Phaser.Scene {
5
+ constructor();
6
+ create({ score }: GameOverData): void;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=game-over-scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-over-scene.d.ts","sourceRoot":"","sources":["../../../src/game/_scenes/game-over-scene.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,qBAAa,aAAc,SAAQ,MAAM,CAAC,KAAK;;IAK7C,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,YAAY;CA0D/B"}
@@ -0,0 +1,59 @@
1
+ export class GameOverScene extends Phaser.Scene {
2
+ constructor() {
3
+ super({ key: 'GameOverScene' });
4
+ }
5
+ create({ score }) {
6
+ const { width, height } = this.scale;
7
+ this.add
8
+ .text(width / 2, height / 2 - 40, 'Game Over!', {
9
+ fontSize: '32px',
10
+ color: '#fff',
11
+ shadow: {
12
+ offsetX: 2,
13
+ offsetY: 2,
14
+ color: '#000',
15
+ blur: 10,
16
+ fill: true,
17
+ },
18
+ })
19
+ .setOrigin(0.5);
20
+ this.add
21
+ .text(width / 2, height / 2, `Final Score: ${score}`, {
22
+ fontSize: '32px',
23
+ color: '#fff',
24
+ shadow: {
25
+ offsetX: 2,
26
+ offsetY: 2,
27
+ color: '#000',
28
+ blur: 10,
29
+ fill: true,
30
+ },
31
+ })
32
+ .setOrigin(0.5);
33
+ const restart = () => {
34
+ this.scene.stop(); // Stop GameOverScene
35
+ // Get reference to PacManScene and restart it
36
+ const pacManScene = this.scene.get('PacManScene');
37
+ if (pacManScene) {
38
+ pacManScene.scene.restart(); // This creates a fresh instance
39
+ }
40
+ };
41
+ this.add
42
+ .text(width / 2, height / 2 + 40, 'Restart', {
43
+ fontSize: '24px',
44
+ color: '#fff',
45
+ padding: { x: 10, y: 5 },
46
+ shadow: {
47
+ offsetX: 2,
48
+ offsetY: 2,
49
+ color: '#000',
50
+ blur: 10,
51
+ fill: true,
52
+ },
53
+ })
54
+ .setOrigin(0.5)
55
+ .setInteractive({ useHandCursor: true })
56
+ .on('pointerdown', restart);
57
+ }
58
+ }
59
+ //# sourceMappingURL=game-over-scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-over-scene.js","sourceRoot":"","sources":["../../../src/game/_scenes/game-over-scene.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,KAAK;IAC7C;QACE,KAAK,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAA;IACjC,CAAC;IAED,MAAM,CAAC,EAAE,KAAK,EAAgB;QAC5B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAEpC,IAAI,CAAC,GAAG;aACL,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE;YAC9C,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE;gBACN,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,IAAI;aACX;SACF,CAAC;aACD,SAAS,CAAC,GAAG,CAAC,CAAA;QAEjB,IAAI,CAAC,GAAG;aACL,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,gBAAgB,KAAK,EAAE,EAAE;YACpD,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE;gBACN,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,IAAI;aACX;SACF,CAAC;aACD,SAAS,CAAC,GAAG,CAAC,CAAA;QAEjB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA,CAAC,qBAAqB;YAEvC,8CAA8C;YAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;YACjD,IAAI,WAAW,EAAE,CAAC;gBAChB,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,CAAA,CAAC,gCAAgC;YAC9D,CAAC;QACH,CAAC,CAAA;QAED,IAAI,CAAC,GAAG;aACL,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE;YAC3C,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;YACxB,MAAM,EAAE;gBACN,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,IAAI;aACX;SACF,CAAC;aACD,SAAS,CAAC,GAAG,CAAC;aACd,cAAc,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;aACvC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IAC/B,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import { Scene } from 'phaser';
2
+ export declare class PacManScene extends Scene {
3
+ private pacman;
4
+ private ghosts;
5
+ private scoreDisplay;
6
+ private gameOver;
7
+ constructor();
8
+ preload(): void;
9
+ create(): void;
10
+ update(): void;
11
+ private createGraphics;
12
+ }
13
+ export declare function createPacManScene(container: HTMLDivElement): Phaser.Game;
14
+ //# sourceMappingURL=pac-man-scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pac-man-scene.d.ts","sourceRoot":"","sources":["../../../src/game/_scenes/pac-man-scene.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAgB9B,qBAAa,WAAY,SAAQ,KAAK;IACpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAiB;;IAMjC,OAAO;IASP,MAAM;IA2GN,MAAM,IAAI,IAAI;IAWd,OAAO,CAAC,cAAc;CASvB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,cAAc,eAsB1D"}
@@ -0,0 +1,148 @@
1
+ import { Scene } from 'phaser';
2
+ import { Wall } from '../sprites/wall';
3
+ import { generateMap } from 'pac-man-map-generator';
4
+ import { Pellet } from '../sprites/pellet';
5
+ import { Pacman } from '../sprites/pac-man';
6
+ import { ScoreDisplay } from '../ui/score-display';
7
+ import { SuperPellet } from '../sprites/super-pellet';
8
+ import { Item } from '../sprites/abstracts/item';
9
+ import { Ghost, GhostState } from '../sprites/ghosts/ghost';
10
+ import { PauseMenu } from './pause-scene';
11
+ import { Blinky } from '../sprites/ghosts/blinky';
12
+ import { Clyde } from '../sprites/ghosts/clyde';
13
+ import { Inky } from '../sprites/ghosts/inky';
14
+ import { Pinky } from '../sprites/ghosts/pinky';
15
+ import { GameOverScene } from './game-over-scene';
16
+ export class PacManScene extends Scene {
17
+ constructor() {
18
+ super('PacManScene');
19
+ this.ghosts = [];
20
+ this.gameOver = false;
21
+ }
22
+ preload() {
23
+ const spriteSheet = new URL('./../../../assets/spritesheet.png', import.meta.url).href;
24
+ this.load.image('spritesheet', spriteSheet);
25
+ }
26
+ create() {
27
+ this.gameOver = false;
28
+ // Pause functionality
29
+ this.input.keyboard?.on('keydown-P', () => {
30
+ this.scene.pause();
31
+ this.scene.launch('PauseMenu');
32
+ });
33
+ this.events.on('game-over', () => {
34
+ this.gameOver = true;
35
+ this.physics.pause();
36
+ this.scene.launch('GameOverScene', {
37
+ score: this.scoreDisplay.getScore(),
38
+ });
39
+ });
40
+ this.createGraphics();
41
+ const map = generateMap();
42
+ const items = this.physics.add.staticGroup();
43
+ const fourCorners = SuperPellet.getFourCorners(map);
44
+ map.forEach((row, y) => {
45
+ row.forEach((block, x) => {
46
+ if (block?.type === 'wall') {
47
+ new Wall(this, x, y);
48
+ }
49
+ else if (block?.type === 'empty' && (x !== 14 || y !== 19)) {
50
+ // Place super pellets in the four corners
51
+ if (fourCorners.some((corner) => corner.x === x && corner.y === y)) {
52
+ items.add(new SuperPellet(this, x, y));
53
+ return;
54
+ }
55
+ const surroundingBlocks = [
56
+ map[y - 1]?.[x], // Up
57
+ map[y + 1]?.[x], // Down
58
+ map[y]?.[x - 1], // Left
59
+ map[y]?.[x + 1], // Right
60
+ map[y - 1]?.[x - 1], // Up-Left
61
+ map[y - 1]?.[x + 1], // Up-Right
62
+ map[y + 1]?.[x - 1], // Down-Left
63
+ map[y + 1]?.[x + 1], // Down-Right
64
+ ];
65
+ // No pellets in the ghost house or next to it
66
+ if (surroundingBlocks.some((b) => b?.type === 'ghost-house')) {
67
+ return;
68
+ }
69
+ items.add(new Pellet(this, x, y));
70
+ }
71
+ });
72
+ });
73
+ const ghostCollisionGroup = this.physics.add.group([]);
74
+ this.pacman = new Pacman(this, map);
75
+ ghostCollisionGroup.add(this.pacman);
76
+ this.scoreDisplay = new ScoreDisplay(this, 4, 4);
77
+ this.physics.add.overlap(this.pacman, items, (_pacman, item) => {
78
+ if (!(item instanceof Item)) {
79
+ return;
80
+ }
81
+ if (item instanceof SuperPellet) {
82
+ this.ghosts.forEach((ghost) => ghost.scare());
83
+ }
84
+ this.scoreDisplay.addPoints(item.points);
85
+ item.destroy();
86
+ this.pacman.eatPellet(item.coords.x, item.coords.y);
87
+ this.ghosts.forEach((ghost) => ghost.countPellet());
88
+ }, undefined, this);
89
+ //Ghosts
90
+ // Corner order: top-left, top-right, bottom-left, bottom-right
91
+ this.ghosts.push(new Pinky(this, map, this.pacman, fourCorners[0]), new Blinky(this, map, this.pacman, fourCorners[1]), new Clyde(this, map, this.pacman, fourCorners[2]));
92
+ // Inky needs a reference to Blinky to determine its target
93
+ this.ghosts.push(new Inky(this, map, this.pacman, this.ghosts[0], fourCorners[3]));
94
+ this.ghosts.forEach((ghost) => ghostCollisionGroup.add(ghost));
95
+ this.physics.add.overlap(this.pacman, ghostCollisionGroup, (_, o2) => {
96
+ const ghost = o2;
97
+ if (ghost.ghostState === GhostState.FRIGHTENED) {
98
+ this.scoreDisplay.addPoints(200);
99
+ ghost.handleDeath();
100
+ }
101
+ else {
102
+ this.pacman.handleDeath();
103
+ }
104
+ });
105
+ }
106
+ update() {
107
+ if (this.gameOver) {
108
+ return;
109
+ }
110
+ this.pacman.update();
111
+ this.ghosts.forEach((ghost) => {
112
+ if (ghost.ghostState !== GhostState.DEAD)
113
+ ghost.update();
114
+ });
115
+ }
116
+ createGraphics() {
117
+ Pacman.loadTextures(this.textures);
118
+ Pacman.loadAnimations(this.anims);
119
+ Ghost.loadTextures(this.textures);
120
+ Ghost.loadAnimations(this.anims);
121
+ Wall.addWallGraphics(this);
122
+ Pellet.addPelletGraphics(this);
123
+ SuperPellet.addSuperPelletGraphics(this);
124
+ }
125
+ }
126
+ export function createPacManScene(container) {
127
+ const config = {
128
+ type: Phaser.AUTO,
129
+ parent: container,
130
+ backgroundColor: '#5e5f60ff',
131
+ width: 896,
132
+ height: 992,
133
+ physics: {
134
+ default: 'arcade',
135
+ arcade: {
136
+ gravity: { x: 0, y: 0 },
137
+ debug: false,
138
+ },
139
+ },
140
+ scale: {
141
+ mode: Phaser.Scale.FIT,
142
+ autoCenter: Phaser.Scale.CENTER_BOTH,
143
+ },
144
+ scene: [PacManScene, PauseMenu, GameOverScene],
145
+ };
146
+ return new Phaser.Game(config);
147
+ }
148
+ //# sourceMappingURL=pac-man-scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pac-man-scene.js","sourceRoot":"","sources":["../../../src/game/_scenes/pac-man-scene.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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1 @@
1
+ {"version":3,"file":"pause-scene.d.ts","sourceRoot":"","sources":["../../../src/game/_scenes/pause-scene.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,MAAM,CAAC,KAAK;;IAKzC,MAAM;CA0BP"}
@@ -0,0 +1,28 @@
1
+ export class PauseMenu extends Phaser.Scene {
2
+ constructor() {
3
+ super({ key: 'PauseMenu' });
4
+ }
5
+ create() {
6
+ const { width, height } = this.scale;
7
+ this.add
8
+ .text(width / 2, height / 2 - 40, 'Game Paused', {
9
+ fontSize: '32px',
10
+ color: '#fff',
11
+ })
12
+ .setOrigin(0.5);
13
+ const resumeButton = this.add
14
+ .text(width / 2, height / 2, 'Resume', {
15
+ fontSize: '24px',
16
+ color: '#0f0',
17
+ })
18
+ .setOrigin(0.5)
19
+ .setInteractive();
20
+ const resume = () => {
21
+ this.scene.stop(); // close pause menu
22
+ this.scene.resume('PacManScene'); // resume game
23
+ };
24
+ resumeButton.on('pointerdown', resume);
25
+ this.input.keyboard?.on('keydown-P', resume);
26
+ }
27
+ }
28
+ //# sourceMappingURL=pause-scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pause-scene.js","sourceRoot":"","sources":["../../../src/game/_scenes/pause-scene.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,KAAK;IACzC;QACE,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAA;IAC7B,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAEpC,IAAI,CAAC,GAAG;aACL,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE;YAC/C,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,MAAM;SACd,CAAC;aACD,SAAS,CAAC,GAAG,CAAC,CAAA;QAEjB,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG;aAC1B,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,QAAQ,EAAE;YACrC,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,MAAM;SACd,CAAC;aACD,SAAS,CAAC,GAAG,CAAC;aACd,cAAc,EAAE,CAAA;QAEnB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA,CAAC,mBAAmB;YACrC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA,CAAC,cAAc;QACjD,CAAC,CAAA;QAED,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;QACtC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;IAC9C,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ export declare const directions: {
2
+ LEFT: number;
3
+ RIGHT: number;
4
+ UP: number;
5
+ DOWN: number;
6
+ };
7
+ export declare const directionsArray: {
8
+ x: number;
9
+ y: number;
10
+ dir: number;
11
+ }[];
12
+ export declare const BASE_SPEED = 120;
13
+ export declare const PAC_MAN_SPEED = 120;
14
+ export declare const PAC_MAN_SPEED_SCATTER: number;
15
+ export declare const PAC_MAN_SPEED_EATING: number;
16
+ export declare const PAC_MAN_SPEED_TUNNEL: number;
17
+ export declare const GHOST_SPEED: number;
18
+ export declare const GHOST_SPEED_FRIGHTENED: number;
19
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/game/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;CAKtB,CAAA;AAED,eAAO,MAAM,eAAe;;;;GAK3B,CAAA;AAGD,eAAO,MAAM,UAAU,MAAM,CAAA;AAG7B,eAAO,MAAM,aAAa,MAAa,CAAA;AAGvC,eAAO,MAAM,qBAAqB,QAAoB,CAAA;AAGtD,eAAO,MAAM,oBAAoB,QAAmB,CAAA;AAGpD,eAAO,MAAM,oBAAoB,QAAmB,CAAA;AAGpD,eAAO,MAAM,WAAW,QAAsB,CAAA;AAG9C,eAAO,MAAM,sBAAsB,QAAqB,CAAA"}
@@ -0,0 +1,27 @@
1
+ export const directions = {
2
+ LEFT: 0,
3
+ RIGHT: 1,
4
+ UP: 2,
5
+ DOWN: 3,
6
+ };
7
+ export const directionsArray = [
8
+ { x: 0, y: -1, dir: directions.UP },
9
+ { x: 0, y: 1, dir: directions.DOWN },
10
+ { x: -1, y: 0, dir: directions.LEFT },
11
+ { x: 1, y: 0, dir: directions.RIGHT },
12
+ ];
13
+ // 2px per second base speed
14
+ export const BASE_SPEED = 120;
15
+ // 100% speed for pac-man
16
+ export const PAC_MAN_SPEED = BASE_SPEED;
17
+ // 125% speed for pac-man in scatter mode
18
+ export const PAC_MAN_SPEED_SCATTER = BASE_SPEED * 1.25;
19
+ // 90% while eating
20
+ export const PAC_MAN_SPEED_EATING = BASE_SPEED * 0.9;
21
+ // 50% speed when going through tunnels
22
+ export const PAC_MAN_SPEED_TUNNEL = BASE_SPEED * 0.5;
23
+ // 93.75% speed for ghosts
24
+ export const GHOST_SPEED = BASE_SPEED * 0.9375;
25
+ // 62.5% speed for frightened ghosts
26
+ export const GHOST_SPEED_FRIGHTENED = BASE_SPEED * 0.625;
27
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/game/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,EAAE,EAAE,CAAC;IACL,IAAI,EAAE,CAAC;CACR,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE;IACnC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE;IACpC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE;IACrC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE;CACtC,CAAA;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;AAE7B,yBAAyB;AACzB,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAA;AAEvC,yCAAyC;AACzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,GAAG,IAAI,CAAA;AAEtD,mBAAmB;AACnB,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,GAAG,GAAG,CAAA;AAEpD,uCAAuC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,GAAG,GAAG,CAAA;AAEpD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,CAAA;AAE9C,oCAAoC;AACpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,GAAG,KAAK,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Item } from './item';
2
+ export declare abstract class ActionItem extends Item {
3
+ abstract onCollect(): void;
4
+ }
5
+ //# sourceMappingURL=action-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-item.d.ts","sourceRoot":"","sources":["../../../../src/game/sprites/abstracts/action-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,8BAAsB,UAAW,SAAQ,IAAI;IAC3C,QAAQ,CAAC,SAAS,IAAI,IAAI;CAC3B"}
@@ -0,0 +1,4 @@
1
+ import { Item } from './item';
2
+ export class ActionItem extends Item {
3
+ }
4
+ //# sourceMappingURL=action-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-item.js","sourceRoot":"","sources":["../../../../src/game/sprites/abstracts/action-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,OAAgB,UAAW,SAAQ,IAAI;CAE5C"}
@@ -0,0 +1,6 @@
1
+ export declare abstract class Item extends Phaser.Physics.Arcade.Sprite {
2
+ abstract readonly points: number;
3
+ readonly coords: Phaser.Types.Math.Vector2Like;
4
+ constructor(scene: Phaser.Scene, x: number, y: number, sizeOffset: number, texture: string);
5
+ }
6
+ //# sourceMappingURL=item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../src/game/sprites/abstracts/item.ts"],"names":[],"mappings":"AAAA,8BAAsB,IAAK,SAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM;IAC7D,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IAEhC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAA;gBAG5C,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM;CAWlB"}
@@ -0,0 +1,12 @@
1
+ export class Item extends Phaser.Physics.Arcade.Sprite {
2
+ constructor(scene, x, y, sizeOffset, texture) {
3
+ const adjustedX = x * 32 + sizeOffset;
4
+ const adjustedY = y * 32 + sizeOffset;
5
+ super(scene, adjustedX, adjustedY, texture);
6
+ this.coords = { x, y };
7
+ // Add to scene
8
+ this.setOrigin(0, 0); // Top-left origin
9
+ scene.add.existing(this);
10
+ }
11
+ }
12
+ //# sourceMappingURL=item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../src/game/sprites/abstracts/item.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,IAAK,SAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM;IAK7D,YACE,KAAmB,EACnB,CAAS,EACT,CAAS,EACT,UAAkB,EAClB,OAAe;QAEf,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,UAAU,CAAA;QACrC,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,UAAU,CAAA;QACrC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAC3C,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QAEtB,eAAe;QACf,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAC,kBAAkB;QACvC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { PacManMap } from 'pac-man-map-generator';
2
+ export declare abstract class Character extends Phaser.Physics.Arcade.Sprite {
3
+ position: Phaser.Types.Math.Vector2Like;
4
+ gridPosition: Phaser.Types.Math.Vector2Like;
5
+ direction: number;
6
+ protected readonly gameMap: PacManMap;
7
+ protected abstract readonly speed: number;
8
+ protected textureMap: Record<number, string>;
9
+ constructor(scene: Phaser.Scene, gameMap: PacManMap, x: number, y: number, textureMap: Record<number, string>, texture: string, startingFrame?: string);
10
+ update(): void;
11
+ protected canMove(cell: {
12
+ x: number;
13
+ y: number;
14
+ }, direction: number): boolean;
15
+ protected changeDirection(direction: number): void;
16
+ protected getOppositeDirection(direction: number): number;
17
+ protected abstract onCenter(cell: Phaser.Types.Math.Vector2Like): void;
18
+ abstract handleDeath(): void;
19
+ }
20
+ //# sourceMappingURL=character.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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'../../constants';
2
+ export class Character extends Phaser.Physics.Arcade.Sprite {
3
+ constructor(scene, gameMap, x, y, textureMap, texture, startingFrame) {
4
+ super(scene, x, y, texture, startingFrame);
5
+ this.position = { x: 0, y: 0 };
6
+ this.gridPosition = { x: 0, y: 0 };
7
+ this.direction = -1;
8
+ this.gameMap = gameMap;
9
+ this.position = { x, y };
10
+ this.gridPosition = { x: Math.floor(x / 32), y: Math.floor(y / 32) };
11
+ this.textureMap = textureMap;
12
+ scene.add.existing(this);
13
+ scene.physics.add.existing(this);
14
+ this.setCollideWorldBounds(false);
15
+ }
16
+ update() {
17
+ const cell = {
18
+ x: Math.floor(this.x / 32),
19
+ y: Math.floor(this.y / 32),
20
+ };
21
+ const center = {
22
+ x: cell.x * 32 + 16,
23
+ y: cell.y * 32 + 16,
24
+ };
25
+ const tolerance = 4;
26
+ const inCenterX = Math.abs(this.x - center.x) < tolerance;
27
+ const inCenterY = Math.abs(this.y - center.y) < tolerance;
28
+ // Snap to center if not already there
29
+ if ((this.direction === directions.RIGHT ||
30
+ this.direction === directions.LEFT) &&
31
+ !inCenterY) {
32
+ this.setPosition(this.x, this.position.y);
33
+ }
34
+ if ((this.direction === directions.UP ||
35
+ this.direction === directions.DOWN) &&
36
+ !inCenterX) {
37
+ this.setPosition(this.position.x, this.y);
38
+ }
39
+ // At cell center
40
+ if (inCenterX && inCenterY) {
41
+ this.position = center;
42
+ this.gridPosition = cell;
43
+ // Teleporting logic
44
+ if (cell.x < -1) {
45
+ this.setPosition(32 * 28, this.y);
46
+ }
47
+ else if (cell.x > 27) {
48
+ this.setPosition(-32, this.y);
49
+ }
50
+ if (!this.gameMap[cell.y]?.[cell.x] ||
51
+ this.gameMap[cell.y]?.[cell.x]?.type === 'teleporter') {
52
+ // Do nothing else if on a teleporter
53
+ return;
54
+ }
55
+ this.onCenter(cell);
56
+ }
57
+ }
58
+ canMove(cell, direction) {
59
+ const targetCell = { x: cell.x, y: cell.y };
60
+ switch (direction) {
61
+ case directions.LEFT:
62
+ targetCell.x -= 1;
63
+ break;
64
+ case directions.RIGHT:
65
+ targetCell.x += 1;
66
+ break;
67
+ case directions.UP:
68
+ targetCell.y -= 1;
69
+ break;
70
+ case directions.DOWN:
71
+ targetCell.y += 1;
72
+ break;
73
+ default:
74
+ return false;
75
+ }
76
+ // Always allow teleporting through left/right edges
77
+ if (targetCell.x < 0 || targetCell.x > 27) {
78
+ return true;
79
+ }
80
+ const type = this.gameMap[targetCell.y]?.[targetCell.x]?.type;
81
+ return type === 'empty' || type === 'teleporter';
82
+ }
83
+ changeDirection(direction) {
84
+ this.direction = direction;
85
+ switch (direction) {
86
+ case directions.LEFT:
87
+ this.setVelocity(-this.speed, 0);
88
+ break;
89
+ case directions.RIGHT:
90
+ this.setVelocity(this.speed, 0);
91
+ break;
92
+ case directions.UP:
93
+ this.setVelocity(0, -this.speed);
94
+ break;
95
+ case directions.DOWN:
96
+ this.setVelocity(0, this.speed);
97
+ break;
98
+ }
99
+ const tex = this.textureMap[direction];
100
+ if (tex) {
101
+ this.anims.stop();
102
+ if (tex.startsWith('frame:')) {
103
+ this.setFrame(tex.replace('frame:', ''));
104
+ }
105
+ else {
106
+ this.anims.play(tex);
107
+ }
108
+ }
109
+ }
110
+ getOppositeDirection(direction) {
111
+ switch (direction) {
112
+ case directions.LEFT:
113
+ return directions.RIGHT;
114
+ case directions.RIGHT:
115
+ return directions.LEFT;
116
+ case directions.UP:
117
+ return directions.DOWN;
118
+ case directions.DOWN:
119
+ return directions.UP;
120
+ default:
121
+ return -1;
122
+ }
123
+ }
124
+ }
125
+ //# sourceMappingURL=character.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"character.js","sourceRoot":"","sources":["../../../../src/game/sprites/characters/character.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,OAAgB,SAAU,SAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM;IASlE,YACE,KAAmB,E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xB,KAAK,UAAU,CAAC,EAAE;gBAChB,OAAO,UAAU,CAAC,IAAI,CAAA;YACxB,KAAK,UAAU,CAAC,IAAI;gBAClB,OAAO,UAAU,CAAC,EAAE,CAAA;YACtB;gBACE,OAAO,CAAC,CAAC,CAAA;QACb,CAAC;IACH,CAAC;CAIF"}
@@ -0,0 +1,11 @@
1
+ import { PacManMap } from 'pac-man-map-generator';
2
+ import { Ghost } from './ghost';
3
+ import { Character } from '../characters/character';
4
+ export declare class Blinky extends Ghost {
5
+ protected readonly pelletCountToLeaveHouse = 0;
6
+ protected readonly timerToLeaveHouse = 0;
7
+ randomId: string;
8
+ constructor(scene: Phaser.Scene, gameMap: PacManMap, pacman: Character, scatterTarget: Phaser.Types.Math.Vector2Like);
9
+ onCenter(): void;
10
+ }
11
+ //# sourceMappingURL=blinky.d.ts.map