summaryrefslogtreecommitdiffstats
path: root/pacman-google/src/js/pacman10-hp.2.js
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-google/src/js/pacman10-hp.2.js')
-rw-r--r--pacman-google/src/js/pacman10-hp.2.js3162
1 files changed, 3162 insertions, 0 deletions
diff --git a/pacman-google/src/js/pacman10-hp.2.js b/pacman-google/src/js/pacman10-hp.2.js
new file mode 100644
index 0000000..ba93880
--- /dev/null
+++ b/pacman-google/src/js/pacman10-hp.2.js
@@ -0,0 +1,3162 @@
1google.pacman ||
2function () {
3 var a = true,
4 e = false,
5 g = {},
6 i = [1, 4, 2, 8],
7 l = {
8 0: {
9 axis: 0,
10 increment: 0
11 },
12 1: {
13 axis: 0,
14 increment: -1
15 },
16 2: {
17 axis: 0,
18 increment: +1
19 },
20 4: {
21 axis: 1,
22 increment: -1
23 },
24 8: {
25 axis: 1,
26 increment: +1
27 }
28 },
29 m = [0, 7, 17, 32],
30 n = [{
31 x: 5,
32 y: 1,
33 w: 56
34 },
35 {
36 x: 5,
37 y: 4,
38 w: 5
39 },
40 {
41 x: 5,
42 y: 1,
43 h: 4
44 },
45 {
46 x: 9,
47 y: 1,
48 h: 12
49 },
50 {
51 x: 5,
52 y: 12,
53 h: 4
54 },
55 {
56 x: 10,
57 y: 12,
58 h: 4
59 },
60 {
61 x: 5,
62 y: 15,
63 w: 16
64 },
65 {
66 x: 5,
67 y: 12,
68 w: 31
69 },
70 {
71 x: 60,
72 y: 1,
73 h: 4
74 },
75 {
76 x: 54,
77 y: 1,
78 h: 4
79 },
80 {
81 x: 19,
82 y: 1,
83 h: 12
84 },
85 {
86 x: 19,
87 y: 4,
88 w: 26
89 },
90 {
91 x: 13,
92 y: 5,
93 w: 7
94 },
95 {
96 x: 13,
97 y: 5,
98 h: 4
99 },
100 {
101 x: 13,
102 y: 8,
103 w: 3
104 },
105 {
106 x: 56,
107 y: 4,
108 h: 9
109 },
110 {
111 x: 48,
112 y: 4,
113 w: 13
114 },
115 {
116 x: 48,
117 y: 1,
118 h: 12
119 },
120 {
121 x: 60,
122 y: 12,
123 h: 4
124 },
125 {
126 x: 44,
127 y: 15,
128 w: 17
129 },
130 {
131 x: 54,
132 y: 12,
133 h: 4
134 },
135 {
136 x: 44,
137 y: 12,
138 w: 17
139 },
140 {
141 x: 44,
142 y: 1,
143 h: 15
144 },
145 {
146 x: 41,
147 y: 13,
148 w: 4
149 },
150 {
151 x: 41,
152 y: 13,
153 h: 3
154 },
155 {
156 x: 38,
157 y: 13,
158 h: 3
159 },
160 {
161 x: 38,
162 y: 15,
163 w: 4
164 },
165 {
166 x: 35,
167 y: 10,
168 w: 10
169 },
170 {
171 x: 35,
172 y: 1,
173 h: 15
174 },
175 {
176 x: 35,
177 y: 13,
178 w: 4
179 },
180 {
181 x: 21,
182 y: 12,
183 h: 4
184 },
185 {
186 x: 24,
187 y: 12,
188 h: 4
189 },
190 {
191 x: 24,
192 y: 15,
193 w: 12
194 },
195 {
196 x: 27,
197 y: 4,
198 h: 9
199 },
200 {
201 x: 52,
202 y: 9,
203 w: 5
204 },
205 {
206 x: 56,
207 y: 8,
208 w: 10,
209 type: 1
210 },
211 {
212 x: 1,
213 y: 8,
214 w: 9,
215 type: 1
216 }],
217 o = [{
218 x: 1,
219 y: 8,
220 w: 8
221 },
222 {
223 x: 57,
224 y: 8,
225 w: 9
226 },
227 {
228 x: 44,
229 y: 2,
230 h: 10
231 },
232 {
233 x: 35,
234 y: 5,
235 h: 7
236 },
237 {
238 x: 36,
239 y: 4,
240 w: 8
241 },
242 {
243 x: 36,
244 y: 10,
245 w: 8
246 },
247 {
248 x: 39,
249 y: 15,
250 w: 2
251 }],
252 p = [{
253 x: 5,
254 y: 15
255 },
256 {
257 x: 5,
258 y: 3
259 },
260 {
261 x: 15,
262 y: 8
263 },
264 {
265 x: 60,
266 y: 3
267 },
268 {
269 x: 60,
270 y: 15
271 }],
272 q = [{
273 x: 2,
274 y: 8
275 },
276 {
277 x: 63,
278 y: 8
279 }],
280 r = {
281 1: [{
282 x: 39.5,
283 y: 15,
284 dir: 4
285 },
286 {
287 x: 39.5,
288 y: 4,
289 dir: 4,
290 scatterX: 57,
291 scatterY: -4
292 },
293 {
294 x: 39.5,
295 y: 7,
296 dir: 2,
297 scatterX: 0,
298 scatterY: -4
299 },
300 {
301 x: 37.625,
302 y: 7,
303 dir: 1,
304 scatterX: 57,
305 scatterY: 20
306 },
307 {
308 x: 41.375,
309 y: 7,
310 dir: 1,
311 scatterX: 0,
312 scatterY: 20
313 }],
314 2: [{
315 x: 40.25,
316 y: 15,
317 dir: 8
318 },
319 {
320 x: 38.75,
321 y: 15,
322 dir: 4
323 },
324 {
325 x: 39.5,
326 y: 4,
327 dir: 4,
328 scatterX: 57,
329 scatterY: -4
330 },
331 {
332 x: 39.5,
333 y: 7,
334 dir: 2,
335 scatterX: 0,
336 scatterY: -4
337 },
338 {
339 x: 37.625,
340 y: 7,
341 dir: 1,
342 scatterX: 57,
343 scatterY: 20
344 },
345 {
346 x: 41.375,
347 y: 7,
348 dir: 1,
349 scatterX: 0,
350 scatterY: 20
351 }]
352 },
353 s = [32, 312],
354 v = [80, 312],
355 w = {
356 0: 0.16,
357 1: 0.23,
358 2: 1,
359 3: 1,
360 4: 2.23,
361 5: 0.3,
362 6: 1.9,
363 7: 2.23,
364 8: 1.9,
365 9: 5,
366 10: 1.9,
367 11: 1.18,
368 12: 0.3,
369 13: 0.5,
370 14: 1.9,
371 15: 9,
372 16: 10,
373 17: 0.26
374 },
375 y = 0.8 * 0.4,
376 z = [{},
377 {
378 ghostSpeed: 0.75,
379 ghostTunnelSpeed: 0.4,
380 playerSpeed: 0.8,
381 dotEatingSpeed: 0.71,
382 ghostFrightSpeed: 0.5,
383 playerFrightSpeed: 0.9,
384 dotEatingFrightSpeed: 0.79,
385 elroyDotsLeftPart1: 20,
386 elroySpeedPart1: 0.8,
387 elroyDotsLeftPart2: 10,
388 elroySpeedPart2: 0.85,
389 frightTime: 6,
390 frightBlinkCount: 5,
391 fruit: 1,
392 fruitScore: 100,
393 ghostModeSwitchTimes: [7, 20, 7, 20, 5, 20, 5, 1],
394 penForceTime: 4,
395 penLeavingLimits: [0, 0, 30, 60]
396 },
397 {
398 ghostSpeed: 0.85,
399 ghostTunnelSpeed: 0.45,
400 playerSpeed: 0.9,
401 dotEatingSpeed: 0.79,
402 ghostFrightSpeed: 0.55,
403 playerFrightSpeed: 0.95,
404 dotEatingFrightSpeed: 0.83,
405 elroyDotsLeftPart1: 30,
406 elroySpeedPart1: 0.9,
407 elroyDotsLeftPart2: 15,
408 elroySpeedPart2: 0.95,
409 frightTime: 5,
410 frightBlinkCount: 5,
411 fruit: 2,
412 fruitScore: 300,
413 ghostModeSwitchTimes: [7, 20, 7, 20, 5, 1033, 1 / 60, 1],
414 penForceTime: 4,
415 penLeavingLimits: [0, 0, 0, 50],
416 cutsceneId: 1
417 },
418 {
419 ghostSpeed: 0.85,
420 ghostTunnelSpeed: 0.45,
421 playerSpeed: 0.9,
422 dotEatingSpeed: 0.79,
423 ghostFrightSpeed: 0.55,
424 playerFrightSpeed: 0.95,
425 dotEatingFrightSpeed: 0.83,
426 elroyDotsLeftPart1: 40,
427 elroySpeedPart1: 0.9,
428 elroyDotsLeftPart2: 20,
429 elroySpeedPart2: 0.95,
430 frightTime: 4,
431 frightBlinkCount: 5,
432 fruit: 3,
433 fruitScore: 500,
434 ghostModeSwitchTimes: [7, 20, 7, 20, 5, 1033, 1 / 60, 1],
435 penForceTime: 4,
436 penLeavingLimits: [0, 0, 0, 0]
437 },
438 {
439 ghostSpeed: 0.85,
440 ghostTunnelSpeed: 0.45,
441 playerSpeed: 0.9,
442 dotEatingSpeed: 0.79,
443 ghostFrightSpeed: 0.55,
444 playerFrightSpeed: 0.95,
445 dotEatingFrightSpeed: 0.83,
446 elroyDotsLeftPart1: 40,
447 elroySpeedPart1: 0.9,
448 elroyDotsLeftPart2: 20,
449 elroySpeedPart2: 0.95,
450 frightTime: 3,
451 frightBlinkCount: 5,
452 fruit: 3,
453 fruitScore: 500,
454 ghostModeSwitchTimes: [7, 20, 7, 20, 5, 1033, 1 / 60, 1],
455 penForceTime: 4,
456 penLeavingLimits: [0, 0, 0, 0]
457 },
458 {
459 ghostSpeed: 0.95,
460 ghostTunnelSpeed: 0.5,
461 playerSpeed: 1,
462 dotEatingSpeed: 0.87,
463 ghostFrightSpeed: 0.6,
464 playerFrightSpeed: 1,
465 dotEatingFrightSpeed: 0.87,
466 elroyDotsLeftPart1: 40,
467 elroySpeedPart1: 1,
468 elroyDotsLeftPart2: 20,
469 elroySpeedPart2: 1.05,
470 frightTime: 2,
471 frightBlinkCount: 5,
472 fruit: 4,
473 fruitScore: 700,
474 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
475 penForceTime: 3,
476 penLeavingLimits: [0, 0, 0, 0],
477 cutsceneId: 2
478 },
479 {
480 ghostSpeed: 0.95,
481 ghostTunnelSpeed: 0.5,
482 playerSpeed: 1,
483 dotEatingSpeed: 0.87,
484 ghostFrightSpeed: 0.6,
485 playerFrightSpeed: 1,
486 dotEatingFrightSpeed: 0.87,
487 elroyDotsLeftPart1: 50,
488 elroySpeedPart1: 1,
489 elroyDotsLeftPart2: 25,
490 elroySpeedPart2: 1.05,
491 frightTime: 5,
492 frightBlinkCount: 5,
493 fruit: 4,
494 fruitScore: 700,
495 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
496 penForceTime: 3,
497 penLeavingLimits: [0, 0, 0, 0]
498 },
499 {
500 ghostSpeed: 0.95,
501 ghostTunnelSpeed: 0.5,
502 playerSpeed: 1,
503 dotEatingSpeed: 0.87,
504 ghostFrightSpeed: 0.6,
505 playerFrightSpeed: 1,
506 dotEatingFrightSpeed: 0.87,
507 elroyDotsLeftPart1: 50,
508 elroySpeedPart1: 1,
509 elroyDotsLeftPart2: 25,
510 elroySpeedPart2: 1.05,
511 frightTime: 2,
512 frightBlinkCount: 5,
513 fruit: 5,
514 fruitScore: 1E3,
515 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
516 penForceTime: 3,
517 penLeavingLimits: [0, 0, 0, 0]
518 },
519 {
520 ghostSpeed: 0.95,
521 ghostTunnelSpeed: 0.5,
522 playerSpeed: 1,
523 dotEatingSpeed: 0.87,
524 ghostFrightSpeed: 0.6,
525 playerFrightSpeed: 1,
526 dotEatingFrightSpeed: 0.87,
527 elroyDotsLeftPart1: 50,
528 elroySpeedPart1: 1,
529 elroyDotsLeftPart2: 25,
530 elroySpeedPart2: 1.05,
531 frightTime: 2,
532 frightBlinkCount: 5,
533 fruit: 5,
534 fruitScore: 1E3,
535 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
536 penForceTime: 3,
537 penLeavingLimits: [0, 0, 0, 0]
538 },
539 {
540 ghostSpeed: 0.95,
541 ghostTunnelSpeed: 0.5,
542 playerSpeed: 1,
543 dotEatingSpeed: 0.87,
544 ghostFrightSpeed: 0.6,
545 playerFrightSpeed: 1,
546 dotEatingFrightSpeed: 0.87,
547 elroyDotsLeftPart1: 60,
548 elroySpeedPart1: 1,
549 elroyDotsLeftPart2: 30,
550 elroySpeedPart2: 1.05,
551 frightTime: 1,
552 frightBlinkCount: 3,
553 fruit: 6,
554 fruitScore: 2E3,
555 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
556 penForceTime: 3,
557 penLeavingLimits: [0, 0, 0, 0],
558 cutsceneId: 3
559 },
560 {
561 ghostSpeed: 0.95,
562 ghostTunnelSpeed: 0.5,
563 playerSpeed: 1,
564 dotEatingSpeed: 0.87,
565 ghostFrightSpeed: 0.6,
566 playerFrightSpeed: 1,
567 dotEatingFrightSpeed: 0.87,
568 elroyDotsLeftPart1: 60,
569 elroySpeedPart1: 1,
570 elroyDotsLeftPart2: 30,
571 elroySpeedPart2: 1.05,
572 frightTime: 5,
573 frightBlinkCount: 5,
574 fruit: 6,
575 fruitScore: 2E3,
576 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
577 penForceTime: 3,
578 penLeavingLimits: [0, 0, 0, 0]
579 },
580 {
581 ghostSpeed: 0.95,
582 ghostTunnelSpeed: 0.5,
583 playerSpeed: 1,
584 dotEatingSpeed: 0.87,
585 ghostFrightSpeed: 0.6,
586 playerFrightSpeed: 1,
587 dotEatingFrightSpeed: 0.87,
588 elroyDotsLeftPart1: 60,
589 elroySpeedPart1: 1,
590 elroyDotsLeftPart2: 30,
591 elroySpeedPart2: 1.05,
592 frightTime: 2,
593 frightBlinkCount: 5,
594 fruit: 7,
595 fruitScore: 3E3,
596 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
597 penForceTime: 3,
598 penLeavingLimits: [0, 0, 0, 0]
599 },
600 {
601 ghostSpeed: 0.95,
602 ghostTunnelSpeed: 0.5,
603 playerSpeed: 1,
604 dotEatingSpeed: 0.87,
605 ghostFrightSpeed: 0.6,
606 playerFrightSpeed: 1,
607 dotEatingFrightSpeed: 0.87,
608 elroyDotsLeftPart1: 80,
609 elroySpeedPart1: 1,
610 elroyDotsLeftPart2: 40,
611 elroySpeedPart2: 1.05,
612 frightTime: 1,
613 frightBlinkCount: 3,
614 fruit: 7,
615 fruitScore: 3E3,
616 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
617 penForceTime: 3,
618 penLeavingLimits: [0, 0, 0, 0]
619 },
620 {
621 ghostSpeed: 0.95,
622 ghostTunnelSpeed: 0.5,
623 playerSpeed: 1,
624 dotEatingSpeed: 0.87,
625 ghostFrightSpeed: 0.6,
626 playerFrightSpeed: 1,
627 dotEatingFrightSpeed: 0.87,
628 elroyDotsLeftPart1: 80,
629 elroySpeedPart1: 1,
630 elroyDotsLeftPart2: 40,
631 elroySpeedPart2: 1.05,
632 frightTime: 1,
633 frightBlinkCount: 3,
634 fruit: 8,
635 fruitScore: 5E3,
636 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
637 penForceTime: 3,
638 penLeavingLimits: [0, 0, 0, 0],
639 cutsceneId: 3
640 },
641 {
642 ghostSpeed: 0.95,
643 ghostTunnelSpeed: 0.5,
644 playerSpeed: 1,
645 dotEatingSpeed: 0.87,
646 ghostFrightSpeed: 0.6,
647 playerFrightSpeed: 1,
648 dotEatingFrightSpeed: 0.87,
649 elroyDotsLeftPart1: 80,
650 elroySpeedPart1: 1,
651 elroyDotsLeftPart2: 40,
652 elroySpeedPart2: 1.05,
653 frightTime: 3,
654 frightBlinkCount: 5,
655 fruit: 8,
656 fruitScore: 5E3,
657 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
658 penForceTime: 3,
659 penLeavingLimits: [0, 0, 0, 0]
660 },
661 {
662 ghostSpeed: 0.95,
663 ghostTunnelSpeed: 0.5,
664 playerSpeed: 1,
665 dotEatingSpeed: 0.87,
666 ghostFrightSpeed: 0.6,
667 playerFrightSpeed: 1,
668 dotEatingFrightSpeed: 0.87,
669 elroyDotsLeftPart1: 100,
670 elroySpeedPart1: 1,
671 elroyDotsLeftPart2: 50,
672 elroySpeedPart2: 1.05,
673 frightTime: 1,
674 frightBlinkCount: 3,
675 fruit: 8,
676 fruitScore: 5E3,
677 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
678 penForceTime: 3,
679 penLeavingLimits: [0, 0, 0, 0]
680 },
681 {
682 ghostSpeed: 0.95,
683 ghostTunnelSpeed: 0.5,
684 playerSpeed: 1,
685 dotEatingSpeed: 0.87,
686 ghostFrightSpeed: 0.6,
687 playerFrightSpeed: 1,
688 dotEatingFrightSpeed: 0.87,
689 elroyDotsLeftPart1: 100,
690 elroySpeedPart1: 1,
691 elroyDotsLeftPart2: 50,
692 elroySpeedPart2: 1.05,
693 frightTime: 1,
694 frightBlinkCount: 3,
695 fruit: 8,
696 fruitScore: 5E3,
697 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
698 penForceTime: 3,
699 penLeavingLimits: [0, 0, 0, 0]
700 },
701 {
702 ghostSpeed: 0.95,
703 ghostTunnelSpeed: 0.5,
704 playerSpeed: 1,
705 dotEatingSpeed: 0.87,
706 ghostFrightSpeed: 0.6,
707 playerFrightSpeed: 1,
708 dotEatingFrightSpeed: 0.87,
709 elroyDotsLeftPart1: 100,
710 elroySpeedPart1: 1,
711 elroyDotsLeftPart2: 50,
712 elroySpeedPart2: 1.05,
713 frightTime: 0,
714 frightBlinkCount: 0,
715 fruit: 8,
716 fruitScore: 5E3,
717 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
718 penForceTime: 3,
719 penLeavingLimits: [0, 0, 0, 0],
720 cutsceneId: 3
721 },
722 {
723 ghostSpeed: 0.95,
724 ghostTunnelSpeed: 0.5,
725 playerSpeed: 1,
726 dotEatingSpeed: 0.87,
727 ghostFrightSpeed: 0.6,
728 playerFrightSpeed: 1,
729 dotEatingFrightSpeed: 0.87,
730 elroyDotsLeftPart1: 100,
731 elroySpeedPart1: 1,
732 elroyDotsLeftPart2: 50,
733 elroySpeedPart2: 1.05,
734 frightTime: 1,
735 frightBlinkCount: 3,
736 fruit: 8,
737 fruitScore: 5E3,
738 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
739 penForceTime: 3,
740 penLeavingLimits: [0, 0, 0, 0]
741 },
742 {
743 ghostSpeed: 0.95,
744 ghostTunnelSpeed: 0.5,
745 playerSpeed: 1,
746 dotEatingSpeed: 0.87,
747 ghostFrightSpeed: 0.6,
748 playerFrightSpeed: 1,
749 dotEatingFrightSpeed: 0.87,
750 elroyDotsLeftPart1: 120,
751 elroySpeedPart1: 1,
752 elroyDotsLeftPart2: 60,
753 elroySpeedPart2: 1.05,
754 frightTime: 0,
755 frightBlinkCount: 0,
756 fruit: 8,
757 fruitScore: 5E3,
758 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
759 penForceTime: 3,
760 penLeavingLimits: [0, 0, 0, 0]
761 },
762 {
763 ghostSpeed: 0.95,
764 ghostTunnelSpeed: 0.5,
765 playerSpeed: 1,
766 dotEatingSpeed: 0.87,
767 ghostFrightSpeed: 0.6,
768 playerFrightSpeed: 1,
769 dotEatingFrightSpeed: 0.87,
770 elroyDotsLeftPart1: 120,
771 elroySpeedPart1: 1,
772 elroyDotsLeftPart2: 60,
773 elroySpeedPart2: 1.05,
774 frightTime: 0,
775 frightBlinkCount: 0,
776 fruit: 8,
777 fruitScore: 5E3,
778 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
779 penForceTime: 3,
780 penLeavingLimits: [0, 0, 0, 0]
781 },
782 {
783 ghostSpeed: 0.95,
784 ghostTunnelSpeed: 0.5,
785 playerSpeed: 0.9,
786 dotEatingSpeed: 0.79,
787 ghostFrightSpeed: 0.75,
788 playerFrightSpeed: 0.9,
789 dotEatingFrightSpeed: 0.79,
790 elroyDotsLeftPart1: 120,
791 elroySpeedPart1: 1,
792 elroyDotsLeftPart2: 60,
793 elroySpeedPart2: 1.05,
794 frightTime: 0,
795 frightBlinkCount: 0,
796 fruit: 8,
797 fruitScore: 5E3,
798 ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
799 penForceTime: 3,
800 penLeavingLimits: [0, 0, 0, 0]
801 }],
802 A = {
803 1: [{
804 x: 37.6,
805 y: 7,
806 dir: 1,
807 dest: 6.375,
808 speed: 0.48
809 },
810 {
811 x: 37.6,
812 y: 6.375,
813 dir: 2,
814 dest: 7.625,
815 speed: 0.48
816 },
817 {
818 x: 37.6,
819 y: 7.625,
820 dir: 1,
821 dest: 7,
822 speed: 0.48
823 }],
824 2: [{
825 x: 39.5,
826 y: 7,
827 dir: 2,
828 dest: 7.625,
829 speed: 0.48
830 },
831 {
832 x: 39.5,
833 y: 7.625,
834 dir: 1,
835 dest: 6.375,
836 speed: 0.48
837 },
838 {
839 x: 39.5,
840 y: 6.375,
841 dir: 2,
842 dest: 7,
843 speed: 0.48
844 }],
845 3: [{
846 x: 41.4,
847 y: 7,
848 dir: 1,
849 dest: 6.375,
850 speed: 0.48
851 },
852 {
853 x: 41.4,
854 y: 6.375,
855 dir: 2,
856 dest: 7.625,
857 speed: 0.48
858 },
859 {
860 x: 41.4,
861 y: 7.625,
862 dir: 1,
863 dest: 7,
864 speed: 0.48
865 }],
866 4: [{
867 x: 37.6,
868 y: 7,
869 dir: 8,
870 dest: 39.5,
871 speed: y
872 },
873 {
874 x: 39.5,
875 y: 7,
876 dir: 1,
877 dest: 4,
878 speed: y
879 }],
880 5: [{
881 x: 39.5,
882 y: 7,
883 dir: 1,
884 dest: 4,
885 speed: y
886 }],
887 6: [{
888 x: 41.4,
889 y: 7,
890 dir: 4,
891 dest: 39.5,
892 speed: y
893 },
894 {
895 x: 39.5,
896 y: 7,
897 dir: 1,
898 dest: 4,
899 speed: y
900 }],
901 7: [{
902 x: 39.5,
903 y: 4,
904 dir: 2,
905 dest: 7,
906 speed: 1.6
907 },
908 {
909 x: 39.5,
910 y: 7,
911 dir: 4,
912 dest: 37.625,
913 speed: 1.6
914 }],
915 8: [{
916 x: 39.5,
917 y: 4,
918 dir: 2,
919 dest: 7,
920 speed: 1.6
921 }],
922 9: [{
923 x: 39.5,
924 y: 4,
925 dir: 2,
926 dest: 7,
927 speed: 1.6
928 },
929 {
930 x: 39.5,
931 y: 7,
932 dir: 8,
933 dest: 41.375,
934 speed: 1.6
935 }],
936 10: [{
937 x: 37.6,
938 y: 7,
939 dir: 8,
940 dest: 39.5,
941 speed: y
942 },
943 {
944 x: 39.5,
945 y: 7,
946 dir: 1,
947 dest: 4,
948 speed: y
949 }],
950 11: [{
951 x: 39.5,
952 y: 7,
953 dir: 1,
954 dest: 4,
955 speed: y
956 }],
957 12: [{
958 x: 41.4,
959 y: 7,
960 dir: 4,
961 dest: 39.5,
962 speed: y
963 },
964 {
965 x: 39.5,
966 y: 7,
967 dir: 1,
968 dest: 4,
969 speed: y
970 }]
971 },
972 B = {
973 1: {
974 actors: [{
975 ghost: e,
976 x: 64,
977 y: 9,
978 id: 0
979 },
980 {
981 ghost: a,
982 x: 68.2,
983 y: 9,
984 id: 1
985 }],
986 sequence: [{
987 time: 5.5,
988 moves: [{
989 dir: 4,
990 speed: 0.75 * 0.8 * 2
991 },
992 {
993 dir: 4,
994 speed: 0.78 * 0.8 * 2
995 }]
996 },
997 {
998 time: 0.1,
999 moves: [{
1000 dir: 4,
1001 speed: 32
1002 },
1003 {
1004 dir: 4,
1005 speed: 0
1006 }]
1007 },
1008 {
1009 time: 9,
1010 moves: [{
1011 dir: 8,
1012 speed: 0.75 * 0.8 * 2,
1013 elId: "pcm-bpcm"
1014 },
1015 {
1016 dir: 8,
1017 speed: 0.8,
1018 mode: 4
1019 }]
1020 }]
1021 },
1022 2: {
1023 actors: [{
1024 ghost: e,
1025 x: 64,
1026 y: 9,
1027 id: 0
1028 },
1029 {
1030 ghost: a,
1031 x: 70.2,
1032 y: 9,
1033 id: 1
1034 },
1035 {
1036 ghost: a,
1037 x: 32,
1038 y: 9.5,
1039 id: 2
1040 }],
1041 sequence: [{
1042 time: 2.7,
1043 moves: [{
1044 dir: 4,
1045 speed: 0.75 * 0.8 * 2
1046 },
1047 {
1048 dir: 4,
1049 speed: 0.78 * 0.8 * 2
1050 },
1051 {
1052 dir: 0,
1053 speed: 0,
1054 elId: "pcm-stck"
1055 }]
1056 },
1057 {
1058 time: 1,
1059 moves: [{
1060 dir: 4,
1061 speed: 0.75 * 0.8 * 2
1062 },
1063 {
1064 dir: 4,
1065 speed: 0.1 * 0.8
1066 },
1067 {
1068 dir: 0,
1069 speed: 0,
1070 elId: "pcm-stck"
1071 }]
1072 },
1073 {
1074 time: 1.3,
1075 moves: [{
1076 dir: 4,
1077 speed: 0.75 * 0.8 * 2
1078 },
1079 {
1080 dir: 4,
1081 speed: 0
1082 },
1083 {
1084 dir: 0,
1085 speed: 0,
1086 elId: "pcm-stck"
1087 }]
1088 },
1089 {
1090 time: 1,
1091 moves: [{
1092 dir: 4,
1093 speed: 0.75 * 0.8 * 2
1094 },
1095 {
1096 dir: 4,
1097 speed: 0,
1098 elId: "pcm-ghfa"
1099 },
1100 {
1101 dir: 0,
1102 speed: 0,
1103 elId: "pcm-stck"
1104 }]
1105 },
1106 {
1107 time: 2.5,
1108 moves: [{
1109 dir: 4,
1110 speed: 0.75 * 0.8 * 2
1111 },
1112 {
1113 dir: 4,
1114 speed: 0,
1115 elId: "pcm-ghfa"
1116 },
1117 {
1118 dir: 0,
1119 speed: 0,
1120 elId: "pcm-stck"
1121 }]
1122 }]
1123 },
1124 3: {
1125 actors: [{
1126 ghost: e,
1127 x: 64,
1128 y: 9,
1129 id: 0
1130 },
1131 {
1132 ghost: a,
1133 x: 70.2,
1134 y: 9,
1135 id: 2
1136 }],
1137 sequence: [{
1138 time: 5.3,
1139 moves: [{
1140 dir: 4,
1141 speed: 0.75 * 0.8 * 2
1142 },
1143 {
1144 dir: 4,
1145 speed: 0.78 * 0.8 * 2,
1146 elId: "pcm-ghin"
1147 }]
1148 },
1149 {
1150 time: 5.3,
1151 moves: [{
1152 dir: 4,
1153 speed: 0
1154 },
1155 {
1156 dir: 8,
1157 speed: 0.78 * 0.8 * 2,
1158 elId: "pcm-gbug"
1159 }]
1160 }]
1161 }
1162 },
1163 C = [90, 45, 30],
1164 D = C[0];
1165
1166 function E(b) {
1167 this.id = b
1168 }
1169 E.prototype.A = function () {
1170 var b = r[g.playerCount][this.id];
1171 this.pos = [b.y * 8, b.x * 8];
1172 this.posDelta = [0, 0];
1173 this.tilePos = [b.y * 8, b.x * 8];
1174 this.targetPos = [b.scatterY * 8, b.scatterX * 8];
1175 this.scatterPos = [b.scatterY * 8, b.scatterX * 8];
1176 this.lastActiveDir = this.dir = b.dir;
1177 this.physicalSpeed = this.requestedDir = this.nextDir = 0;
1178 this.c(0);
1179 this.reverseDirectionsNext = this.freeToLeavePen = this.modeChangedWhileInPen = this.eatenInThisFrightMode = e;
1180 this.l()
1181 };
1182 E.prototype.createElement = function () {
1183 this.el = document.createElement("div");
1184 this.el.className = "pcm-ac";
1185 this.el.id = "actor" + this.id;
1186 g.prepareElement(this.el, 0, 0);
1187 g.playfieldEl.appendChild(this.el);
1188 this.elPos = [0, 0];
1189 this.elBackgroundPos = [0, 0]
1190 };
1191 E.prototype.a = function (b) {
1192 var c = this.mode;
1193 this.mode = b;
1194 if (this.id == g.playerCount + 3 && (b == 16 || c == 16)) g.updateCruiseElroySpeed();
1195 switch (c) {
1196 case 32:
1197 g.ghostExitingPenNow = e;
1198 break;
1199 case 8:
1200 g.ghostEyesCount > 0 && g.ghostEyesCount--;
1201 g.ghostEyesCount == 0 && g.playAmbientSound();
1202 break
1203 }
1204 switch (b) {
1205 case 4:
1206 this.fullSpeed = g.levels.ghostFrightSpeed * 0.8;
1207 this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
1208 this.followingRoutine = e;
1209 break;
1210 case 1:
1211 this.fullSpeed = g.levels.ghostSpeed * 0.8;
1212 this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
1213 this.followingRoutine =
1214 e;
1215 break;
1216 case 2:
1217 this.targetPos = this.scatterPos;
1218 this.fullSpeed = g.levels.ghostSpeed * 0.8;
1219 this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
1220 this.followingRoutine = e;
1221 break;
1222 case 8:
1223 this.tunnelSpeed = this.fullSpeed = 1.6;
1224 this.targetPos = [s[0], s[1]];
1225 this.freeToLeavePen = this.followingRoutine = e;
1226 break;
1227 case 16:
1228 this.l();
1229 this.followingRoutine = a;
1230 this.routineMoveId = -1;
1231 switch (this.id) {
1232 case g.playerCount + 1:
1233 this.routineToFollow = 2;
1234 break;
1235 case g.playerCount + 2:
1236 this.routineToFollow = 1;
1237 break;
1238 case g.playerCount + 3:
1239 this.routineToFollow =
1240 3;
1241 break
1242 }
1243 break;
1244 case 32:
1245 this.followingRoutine = a;
1246 this.routineMoveId = -1;
1247 switch (this.id) {
1248 case g.playerCount + 1:
1249 this.routineToFollow = 5;
1250 break;
1251 case g.playerCount + 2:
1252 this.routineToFollow = 4;
1253 break;
1254 case g.playerCount + 3:
1255 this.routineToFollow = 6;
1256 break
1257 }
1258 g.ghostExitingPenNow = a;
1259 break;
1260 case 64:
1261 this.followingRoutine = a;
1262 this.routineMoveId = -1;
1263 switch (this.id) {
1264 case g.playerCount:
1265 case g.playerCount + 1:
1266 this.routineToFollow = 8;
1267 break;
1268 case g.playerCount + 2:
1269 this.routineToFollow = 7;
1270 break;
1271 case g.playerCount + 3:
1272 this.routineToFollow = 9;
1273 break
1274 }
1275 break;
1276 case 128:
1277 this.followingRoutine = a;
1278 this.routineMoveId = -1;
1279 switch (this.id) {
1280 case g.playerCount:
1281 case g.playerCount + 1:
1282 this.routineToFollow = 11;
1283 break;
1284 case g.playerCount + 2:
1285 this.routineToFollow = 10;
1286 break;
1287 case g.playerCount + 3:
1288 this.routineToFollow = 12;
1289 break
1290 }
1291 break
1292 }
1293 this.d()
1294 };
1295 E.prototype.l = function () {
1296 if (this.id >= g.playerCount) this.targetPlayerId = Math.floor(g.rand() * g.playerCount)
1297 };
1298 E.prototype.z = function (b) {
1299 if (this.dir == g.oppositeDirections[b]) {
1300 this.dir = b;
1301 this.posDelta = [0, 0];
1302 this.currentSpeed != 2 && this.c(0);
1303 if (this.dir != 0) this.lastActiveDir = this.dir;
1304 this.nextDir = 0
1305 } else if (this.dir != b) if (this.dir == 0) {
1306 if (g.playfield[this.pos[0]][this.pos[1]].allowedDir & b) this.dir = b
1307 } else {
1308 var c = g.playfield[this.tilePos[0]][this.tilePos[1]];
1309 if (c && c.allowedDir & b) {
1310 c = l[this.dir];
1311 var d = [this.pos[0], this.pos[1]];
1312 d[c.axis] -= c.increment;
1313 var f = 0;
1314 if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) f = 1;
1315 else {
1316 d[c.axis] -= c.increment;
1317 if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) f = 2
1318 }
1319 if (f) {
1320 this.dir = b;
1321 this.pos[0] = this.tilePos[0];
1322 this.pos[1] = this.tilePos[1];
1323 c = l[this.dir];
1324 this.pos[c.axis] += c.increment * f;
1325 return
1326 }
1327 }
1328 this.nextDir = b;
1329 this.posDelta = [0, 0]
1330 }
1331 };
1332 E.prototype.i = function (b) {
1333 var c = this.tilePos,
1334 d = l[this.dir],
1335 f = [c[0], c[1]];
1336 f[d.axis] += d.increment * 8;
1337 var h = g.playfield[f[0]][f[1]];
1338 if (b && !h.intersection) h = g.playfield[c[0]][c[1]];
1339 if (h.intersection) switch (this.mode) {
1340 case 2:
1341 case 1:
1342 case 8:
1343 if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) this.nextDir = g.oppositeDirections[this.dir];
1344 else {
1345 b = 99999999999;
1346 c = 0;
1347 for (var j in i) {
1348 var k = i[j];
1349 if (h.allowedDir & k && this.dir != g.oppositeDirections[k]) {
1350 d = l[k];
1351 var x = [f[0], f[1]];
1352 x[d.axis] += d.increment;
1353 d = g.getDistance(x, [this.targetPos[0], this.targetPos[1]]);
1354 if (d < b) {
1355 b = d;
1356 c = k
1357 }
1358 }
1359 }
1360 if (c) this.nextDir = c
1361 }
1362 break;
1363 case 4:
1364 if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) this.nextDir = g.oppositeDirections[this.dir];
1365 else {
1366 do f = i[Math.floor(g.rand() * 4)];
1367 while ((f & h.allowedDir) == 0 || f == g.oppositeDirections[this.dir]);
1368 this.nextDir = f
1369 }
1370 break
1371 }
1372 };
1373 E.prototype.p = function (b) {
1374 g.tilesChanged = a;
1375 if (this.reverseDirectionsNext) {
1376 this.dir = g.oppositeDirections[this.dir];
1377 this.nextDir = 0;
1378 this.reverseDirectionsNext = e;
1379 this.i(a)
1380 }
1381 if (!this.ghost && !g.playfield[b[0]][b[1]].path) {
1382 this.pos[0] = this.lastGoodTilePos[0];
1383 this.pos[1] = this.lastGoodTilePos[1];
1384 b[0] = this.lastGoodTilePos[0];
1385 b[1] = this.lastGoodTilePos[1];
1386 this.dir = 0
1387 } else this.lastGoodTilePos = [b[0], b[1]];
1388 g.playfield[b[0]][b[1]].type == 1 && this.mode != 8 ? this.c(2) : this.c(0);
1389 !this.ghost && g.playfield[b[0]][b[1]].dot && g.dotEaten(this.id, b);
1390 this.tilePos[0] = b[0];
1391 this.tilePos[1] = b[1]
1392 };
1393 E.prototype.t = function () {
1394 var b = this.tilePos;
1395 switch (this.dir) {
1396 case 1:
1397 var c = [b[0], b[1]],
1398 d = [b[0] + 3.6, b[1]];
1399 break;
1400 case 2:
1401 c = [b[0] - 4, b[1]];
1402 d = [b[0], b[1]];
1403 break;
1404 case 4:
1405 c = [b[0], b[1]];
1406 d = [b[0], b[1] + 3.6];
1407 break;
1408 case 8:
1409 c = [b[0], b[1] - 4];
1410 d = [b[0], b[1]];
1411 break
1412 }
1413 if (this.pos[0] >= c[0] && this.pos[0] <= d[0] && this.pos[1] >= c[1] && this.pos[1] <= d[1]) {
1414 b = l[this.nextDir];
1415 this.posDelta[b.axis] += b.increment
1416 }
1417 };
1418 E.prototype.n = function () {
1419 if (this.pos[0] == q[0].y * 8 && this.pos[1] == q[0].x * 8) {
1420 this.pos[0] = q[1].y * 8;
1421 this.pos[1] = (q[1].x - 1) * 8
1422 } else if (this.pos[0] == q[1].y * 8 && this.pos[1] == q[1].x * 8) {
1423 this.pos[0] = q[0].y * 8;
1424 this.pos[1] = (q[0].x + 1) * 8
1425 }
1426 this.mode == 8 && this.pos[0] == s[0] && this.pos[1] == s[1] && this.a(64);
1427 if (!this.ghost && this.pos[0] == v[0] && (this.pos[1] == v[1] || this.pos[1] == v[1] + 8)) g.eatFruit(this.id)
1428 };
1429 E.prototype.u = function () {
1430 this.n();
1431 this.ghost && this.i(e);
1432 var b = g.playfield[this.pos[0]][this.pos[1]];
1433 if (b.intersection) if (this.nextDir && this.nextDir & b.allowedDir) {
1434 if (this.dir != 0) this.lastActiveDir = this.dir;
1435 this.dir = this.nextDir;
1436 this.nextDir = 0;
1437 if (!this.ghost) {
1438 this.pos[0] += this.posDelta[0];
1439 this.pos[1] += this.posDelta[1];
1440 this.posDelta = [0, 0]
1441 }
1442 } else if ((this.dir & b.allowedDir) == 0) {
1443 if (this.dir != 0) this.lastActiveDir = this.dir;
1444 this.nextDir = this.dir = 0;
1445 this.c(0)
1446 }
1447 };
1448 E.prototype.o = function () {
1449 var b = this.pos[0] / 8,
1450 c = this.pos[1] / 8,
1451 d = [Math.round(b) * 8, Math.round(c) * 8];
1452 if (d[0] != this.tilePos[0] || d[1] != this.tilePos[1]) this.p(d);
1453 else {
1454 b = [Math.floor(b) * 8, Math.floor(c) * 8];
1455 this.pos[1] == b[1] && this.pos[0] == b[0] && this.u()
1456 }!this.ghost && this.nextDir && g.playfield[d[0]][d[1]].intersection && this.nextDir & g.playfield[d[0]][d[1]].allowedDir && this.t()
1457 };
1458 E.prototype.B = function () {
1459 if (this.id == g.playerCount && g.dotsRemaining < g.levels.elroyDotsLeftPart1 && this.mode == 2 && (!g.lostLifeOnThisLevel || g.actors[g.playerCount + 3].mode != 16)) {
1460 var b = g.actors[this.targetPlayerId];
1461 this.targetPos = [b.tilePos[0], b.tilePos[1]]
1462 } else if (this.ghost && this.mode == 1) {
1463 b = g.actors[this.targetPlayerId];
1464 switch (this.id) {
1465 case g.playerCount:
1466 this.targetPos = [b.tilePos[0], b.tilePos[1]];
1467 break;
1468 case g.playerCount + 1:
1469 this.targetPos = [b.tilePos[0], b.tilePos[1]];
1470 var c = l[b.dir];
1471 this.targetPos[c.axis] += 32 * c.increment;
1472 if (b.dir == 1) this.targetPos[1] -= 32;
1473 break;
1474 case g.playerCount + 2:
1475 var d = g.actors[g.playerCount],
1476 f = [b.tilePos[0], b.tilePos[1]];
1477 c = l[b.dir];
1478 f[c.axis] += 16 * c.increment;
1479 if (b.dir == 1) f[1] -= 16;
1480 this.targetPos[0] = f[0] * 2 - d.tilePos[0];
1481 this.targetPos[1] = f[1] * 2 - d.tilePos[1];
1482 break;
1483 case g.playerCount + 3:
1484 c = g.getDistance(b.tilePos, this.tilePos);
1485 this.targetPos = c > 64 ? [b.tilePos[0], b.tilePos[1]] : this.scatterPos;
1486 break
1487 }
1488 }
1489 };
1490 E.prototype.v = function () {
1491 this.routineMoveId++;
1492 if (this.routineMoveId == A[this.routineToFollow].length) if (this.mode == 16 && this.freeToLeavePen && !g.ghostExitingPenNow) {
1493 this.eatenInThisFrightMode ? this.a(128) : this.a(32);
1494 return
1495 } else if (this.mode == 32 || this.mode == 128) {
1496 this.pos = [s[0], s[1] + 4];
1497 this.dir = this.modeChangedWhileInPen ? 8 : 4;
1498 var b = g.mainGhostMode;
1499 if (this.mode == 128 && b == 4) b = g.lastMainGhostMode;
1500 this.a(b);
1501 return
1502 } else if (this.mode == 64) {
1503 if (this.id == g.playerCount || this.freeToLeavePen) this.a(128);
1504 else {
1505 this.eatenInThisFrightMode =
1506 a;
1507 this.a(16)
1508 }
1509 return
1510 } else this.routineMoveId = 0;
1511 b = A[this.routineToFollow][this.routineMoveId];
1512 this.pos[0] = b.y * 8;
1513 this.pos[1] = b.x * 8;
1514 this.dir = b.dir;
1515 this.physicalSpeed = 0;
1516 this.speedIntervals = g.getSpeedIntervals(b.speed);
1517 this.proceedToNextRoutineMove = e;
1518 this.b()
1519 };
1520 E.prototype.m = function () {
1521 var b = A[this.routineToFollow][this.routineMoveId];
1522 if (b) if (this.speedIntervals[g.intervalTime]) {
1523 var c = l[this.dir];
1524 this.pos[c.axis] += c.increment;
1525 switch (this.dir) {
1526 case 1:
1527 case 4:
1528 if (this.pos[c.axis] < b.dest * 8) {
1529 this.pos[c.axis] = b.dest * 8;
1530 this.proceedToNextRoutineMove = a
1531 }
1532 break;
1533 case 2:
1534 case 8:
1535 if (this.pos[c.axis] > b.dest * 8) {
1536 this.pos[c.axis] = b.dest * 8;
1537 this.proceedToNextRoutineMove = a
1538 }
1539 break
1540 }
1541 this.b()
1542 }
1543 };
1544 E.prototype.j = function () {
1545 if (this.routineMoveId == -1 || this.proceedToNextRoutineMove) this.v();
1546 this.m()
1547 };
1548 E.prototype.d = function () {
1549 switch (this.currentSpeed) {
1550 case 0:
1551 var b = this.id == g.playerCount && (this.mode == 2 || this.mode == 1) ? g.cruiseElroySpeed : this.fullSpeed;
1552 break;
1553 case 1:
1554 b = this.dotEatingSpeed;
1555 break;
1556 case 2:
1557 b = this.tunnelSpeed;
1558 break
1559 }
1560 if (this.physicalSpeed != b) {
1561 this.physicalSpeed = b;
1562 this.speedIntervals = g.getSpeedIntervals(this.physicalSpeed)
1563 }
1564 };
1565 E.prototype.c = function (b) {
1566 this.currentSpeed = b;
1567 this.d()
1568 };
1569 E.prototype.e = function () {
1570 if (this.dir) if (this.speedIntervals[g.intervalTime]) {
1571 var b = l[this.dir];
1572 this.pos[b.axis] += b.increment;
1573 this.o();
1574 this.b()
1575 }
1576 };
1577 E.prototype.move = function () {
1578 if (g.gameplayMode == 0 || this.ghost && g.gameplayMode == 1 && (this.mode == 8 || this.mode == 64)) {
1579 if (this.requestedDir != 0) {
1580 this.z(this.requestedDir);
1581 this.requestedDir = 0
1582 }
1583 if (this.followingRoutine) {
1584 this.j();
1585 this.mode == 64 && this.j()
1586 } else {
1587 this.e();
1588 this.mode == 8 && this.e()
1589 }
1590 }
1591 };
1592 E.prototype.k = function () {
1593 var b = g.getPlayfieldX(this.pos[1] + this.posDelta[1]),
1594 c = g.getPlayfieldY(this.pos[0] + this.posDelta[0]);
1595 if (this.elPos[0] != c || this.elPos[1] != b) {
1596 this.elPos[0] = c;
1597 this.elPos[1] = b;
1598 this.el.style.left = b + "px";
1599 this.el.style.top = c + "px"
1600 }
1601 };
1602 E.prototype.s = function () {
1603 var b = 0,
1604 c = 0,
1605 d = this.dir;
1606 if (d == 0) d = this.lastActiveDir;
1607 if (g.gameplayMode == 1 && this.id == g.playerEatingGhostId) {
1608 b = 3;
1609 c = 0
1610 } else if ((g.gameplayMode == 9 || g.gameplayMode == 10) && this.id == 0) {
1611 b = 2;
1612 c = 0
1613 } else if (g.gameplayMode == 4 || g.gameplayMode == 5 || g.gameplayMode == 7) {
1614 b = this.id == 0 ? 2 : 4;
1615 c = 0
1616 } else if (g.gameplayMode == 3) if (this.id == g.playerDyingId) {
1617 d = 20 - Math.floor(g.gameplayModeTime / g.timing[4] * 21);
1618 if (this.id == 0) {
1619 b = d - 1;
1620 switch (b) {
1621 case -1:
1622 b = 0;
1623 break;
1624 case 11:
1625 b = 10;
1626 break;
1627 case 12:
1628 case 13:
1629 case 14:
1630 case 15:
1631 case 16:
1632 case 17:
1633 case 18:
1634 case 19:
1635 case 20:
1636 b =
1637 11;
1638 break
1639 }
1640 c = 12
1641 } else switch (d) {
1642 case 0:
1643 case 1:
1644 case 2:
1645 case 6:
1646 case 10:
1647 b = 4;
1648 c = 3;
1649 break;
1650 case 3:
1651 case 7:
1652 case 11:
1653 b = 4;
1654 c = 0;
1655 break;
1656 case 4:
1657 case 8:
1658 case 12:
1659 case 13:
1660 case 14:
1661 case 15:
1662 case 16:
1663 case 17:
1664 case 18:
1665 case 19:
1666 case 20:
1667 b = 4;
1668 c = 2;
1669 break;
1670 case 5:
1671 case 9:
1672 b = 4;
1673 c = 1;
1674 break
1675 }
1676 } else {
1677 b = 3;
1678 c = 0
1679 } else if (this.el.id == "pcm-bpcm") {
1680 b = 14;
1681 c = 0;
1682 d = Math.floor(g.globalTime * 0.2) % 4;
1683 if (d == 3) d = 1;
1684 c += 2 * d
1685 } else {
1686 switch (d) {
1687 case 4:
1688 c = 0;
1689 break;
1690 case 8:
1691 c = 1;
1692 break;
1693 case 1:
1694 c = 2;
1695 break;
1696 case 2:
1697 c = 3;
1698 break
1699 }
1700 if (g.gameplayMode != 2) b = Math.floor(g.globalTime * 0.3) % 4;
1701 if (b == 3 && this.dir == 0) b = 0;
1702 if (b == 2 && this.id == 0) b = 0;
1703 if (b == 3) {
1704 b = 2;
1705 if (this.id == 0) c = 0
1706 }
1707 if (this.id == 1) b += 4
1708 }
1709 return [c, b]
1710 };
1711 E.prototype.r = function () {
1712 var b = 0,
1713 c = 0;
1714 if (g.gameplayMode == 10 || g.gameplayMode == 4 || g.gameplayMode == 3) {
1715 b = 3;
1716 c = 0
1717 } else if (g.gameplayMode == 1 && this.id == g.ghostBeingEatenId) {
1718 switch (g.modeScoreMultiplier) {
1719 case 2:
1720 b = 0;
1721 break;
1722 case 4:
1723 b = 1;
1724 break;
1725 case 8:
1726 b = 2;
1727 break;
1728 case 16:
1729 b = 3;
1730 break
1731 }
1732 c = 11;
1733 this.el.className = "pcm-ac pcm-n"
1734 } else if (this.mode == 4 || (this.mode == 16 || this.mode == 32) && g.mainGhostMode == 4 && !this.eatenInThisFrightMode) {
1735 b = 0;
1736 c = 8;
1737 if (g.frightModeTime < g.levels.frightTotalTime - g.levels.frightTime && Math.floor(g.frightModeTime / g.timing[1]) % 2 == 0) b += 2;
1738 b += Math.floor(g.globalTime / 16) % 2
1739 } else if (this.mode == 8 || this.mode == 64) {
1740 c = this.nextDir;
1741 if (!c) c = this.dir;
1742 switch (c) {
1743 case 4:
1744 b = 2;
1745 break;
1746 case 8:
1747 b = 3;
1748 break;
1749 case 1:
1750 b = 0;
1751 break;
1752 case 2:
1753 b = 1;
1754 break
1755 }
1756 c = 10
1757 } else if (this.el.id == "pcm-ghin") {
1758 b = 6;
1759 c = 8;
1760 b += Math.floor(g.globalTime / 16) % 2
1761 } else if (this.el.id == "pcm-gbug") {
1762 b = 6;
1763 c = 9;
1764 c += Math.floor(g.globalTime / 16) % 2
1765 } else if (this.el.id == "pcm-ghfa") {
1766 b = g.cutsceneSequenceId == 3 ? 6 : 7;
1767 c = 11
1768 } else if (this.el.id == "pcm-stck") {
1769 b = g.cutsceneSequenceId == 1 ? g.cutsceneTime > 60 ? 1 : g.cutsceneTime > 45 ? 2 : 3 : g.cutsceneSequenceId == 2 ? 3 : g.cutsceneSequenceId == 3 || g.cutsceneSequenceId == 4 ? 4 : 0;
1770 c = 13
1771 } else {
1772 c = this.nextDir;
1773 if (!c || g.playfield[this.tilePos[0]][this.tilePos[1]].type == 1) c = this.dir;
1774 switch (c) {
1775 case 4:
1776 b = 4;
1777 break;
1778 case 8:
1779 b = 6;
1780 break;
1781 case 1:
1782 b = 0;
1783 break;
1784 case 2:
1785 b = 2;
1786 break
1787 }
1788 c = 4 + this.id - g.playerCount;
1789 if (this.speed > 0 || g.gameplayMode != 13) b += Math.floor(g.globalTime / 16) % 2
1790 }
1791 return [c, b]
1792 };
1793 E.prototype.b = function () {
1794 this.k();
1795 var b = [0, 0];
1796 b = g.gameplayMode == 8 || g.gameplayMode == 14 ? [0, 3] : this.ghost ? this.r() : this.s();
1797 if (this.elBackgroundPos[0] != b[0] || this.elBackgroundPos[1] != b[1]) {
1798 this.elBackgroundPos[0] = b[0];
1799 this.elBackgroundPos[1] = b[1];
1800 b[0] *= 16;
1801 b[1] *= 16;
1802 g.changeElementBkPos(this.el, b[1], b[0], a)
1803 }
1804 };
1805 g.rand = function () {
1806 var b = 4294967296,
1807 c = 134775813;
1808 c = c * g.randSeed + 1;
1809 return (g.randSeed = c % b) / b
1810 };
1811 g.seed = function (b) {
1812 g.randSeed = b
1813 };
1814 g.getDistance = function (b, c) {
1815 return Math.sqrt((c[1] - b[1]) * (c[1] - b[1]) + (c[0] - b[0]) * (c[0] - b[0]))
1816 };
1817 g.getPlayfieldX = function (b) {
1818 return b + -32
1819 };
1820 g.getPlayfieldY = function (b) {
1821 return b + 0
1822 };
1823 g.getCorrectedSpritePos = function (b) {
1824 return b / 8 * 10 + 2
1825 };
1826 g.getDotElementId = function (b, c) {
1827 return "pcm-d" + b + "-" + c
1828 };
1829 g.showElementById = function (b, c) {
1830 var d = document.getElementById(b);
1831 if (d) d.style.visibility = c ? "visible" : "hidden"
1832 };
1833 g.getAbsoluteElPos = function (b) {
1834 var c = [0, 0];
1835 do {
1836 c[0] += b.offsetTop;
1837 c[1] += b.offsetLeft
1838 } while (b = b.offsetParent);
1839 return c
1840 };
1841 g.prepareElement = function (b, c, d) {
1842 c = g.getCorrectedSpritePos(parseInt(c, 10));
1843 d = g.getCorrectedSpritePos(parseInt(d, 10));
1844 if (g.useCss) {
1845 b.style.backgroundImage = "url(src/pacman10-hp-sprite.png)";
1846 b.style.backgroundPosition = -c + "px " + -d + "px";
1847 b.style.backgroundRepeat = "no-repeat"
1848 } else {
1849 b.style.overflow = "hidden";
1850 c = "display: block; position: relative; left: " + -c + "px; top: " + -d + "px";
1851 b.innerHTML = '<img style="' + c + '" src="src/pacman10-hp-sprite.png">'
1852 }
1853 };
1854 g.changeElementBkPos = function (b, c, d, f) {
1855 if (f) {
1856 c = g.getCorrectedSpritePos(c);
1857 d = g.getCorrectedSpritePos(d)
1858 }
1859 if (g.useCss) b.style.backgroundPosition = -c + "px " + -d + "px";
1860 else if (b.childNodes[0]) {
1861 b.childNodes[0].style.left = -c + "px";
1862 b.childNodes[0].style.top = -d + "px"
1863 }
1864 };
1865 g.determinePlayfieldDimensions = function () {
1866 g.playfieldWidth = 0;
1867 g.playfieldHeight = 0;
1868 for (var b in n) {
1869 var c = n[b];
1870 if (c.w) {
1871 c = c.x + c.w - 1;
1872 if (c > g.playfieldWidth) g.playfieldWidth = c
1873 } else {
1874 c = c.y + c.h - 1;
1875 if (c > g.playfieldHeight) g.playfieldHeight = c
1876 }
1877 }
1878 };
1879 g.preparePlayfield = function () {
1880 g.playfield = [];
1881 for (var b = 0; b <= g.playfieldHeight + 1; b++) {
1882 g.playfield[b * 8] = [];
1883 for (var c = -2; c <= g.playfieldWidth + 1; c++) g.playfield[b * 8][c * 8] = {
1884 path: 0,
1885 dot: 0,
1886 intersection: 0
1887 }
1888 }
1889 };
1890 g.preparePaths = function () {
1891 for (var b in n) {
1892 var c = n[b],
1893 d = c.type;
1894 if (c.w) {
1895 for (var f = c.y * 8, h = c.x * 8; h <= (c.x + c.w - 1) * 8; h += 8) {
1896 g.playfield[f][h].path = a;
1897 if (g.playfield[f][h].dot == 0) {
1898 g.playfield[f][h].dot = 1;
1899 g.dotsRemaining++
1900 }
1901 g.playfield[f][h].type = !d || h != c.x * 8 && h != (c.x + c.w - 1) * 8 ? d : 0
1902 }
1903 g.playfield[f][c.x * 8].intersection = a;
1904 g.playfield[f][(c.x + c.w - 1) * 8].intersection = a
1905 } else {
1906 h = c.x * 8;
1907 for (f = c.y * 8; f <= (c.y + c.h - 1) * 8; f += 8) {
1908 if (g.playfield[f][h].path) g.playfield[f][h].intersection = a;
1909 g.playfield[f][h].path = a;
1910 if (g.playfield[f][h].dot == 0) {
1911 g.playfield[f][h].dot = 1;
1912 g.dotsRemaining++
1913 }
1914 g.playfield[f][h].type = !d || f != c.y * 8 && f != (c.y + c.h - 1) * 8 ? d : 0
1915 }
1916 g.playfield[c.y * 8][h].intersection = a;
1917 g.playfield[(c.y + c.h - 1) * 8][h].intersection = a
1918 }
1919 }
1920 for (b in o) if (o[b].w) for (h = o[b].x * 8; h <= (o[b].x + o[b].w - 1) * 8; h += 8) {
1921 g.playfield[o[b].y * 8][h].dot = 0;
1922 g.dotsRemaining--
1923 } else for (f = o[b].y * 8; f <= (o[b].y + o[b].h - 1) * 8; f += 8) {
1924 g.playfield[f][o[b].x * 8].dot = 0;
1925 g.dotsRemaining--
1926 }
1927 };
1928 g.prepareAllowedDirections = function () {
1929 for (var b = 8; b <= g.playfieldHeight * 8; b += 8) for (var c = 8; c <= g.playfieldWidth * 8; c += 8) {
1930 g.playfield[b][c].allowedDir = 0;
1931 if (g.playfield[b - 8][c].path) g.playfield[b][c].allowedDir += 1;
1932 if (g.playfield[b + 8][c].path) g.playfield[b][c].allowedDir += 2;
1933 if (g.playfield[b][c - 8].path) g.playfield[b][c].allowedDir += 4;
1934 if (g.playfield[b][c + 8].path) g.playfield[b][c].allowedDir += 8
1935 }
1936 };
1937 g.createDotElements = function () {
1938 for (var b = 8; b <= g.playfieldHeight * 8; b += 8) for (var c = 8; c <= g.playfieldWidth * 8; c += 8) if (g.playfield[b][c].dot) {
1939 var d = document.createElement("div");
1940 d.className = "pcm-d";
1941 d.id = g.getDotElementId(b, c);
1942 d.style.left = c + -32 + "px";
1943 d.style.top = b + 0 + "px";
1944 g.playfieldEl.appendChild(d)
1945 }
1946 };
1947 g.createEnergizerElements = function () {
1948 for (var b in p) {
1949 var c = p[b],
1950 d = g.getDotElementId(c.y * 8, c.x * 8);
1951 document.getElementById(d).className = "pcm-e";
1952 g.prepareElement(document.getElementById(d), 0, 144);
1953 g.playfield[c.y * 8][c.x * 8].dot = 2
1954 }
1955 };
1956 g.createFruitElement = function () {
1957 g.fruitEl = document.createElement("div");
1958 g.fruitEl.id = "pcm-f";
1959 g.fruitEl.style.left = g.getPlayfieldX(v[1]) + "px";
1960 g.fruitEl.style.top = g.getPlayfieldY(v[0]) + "px";
1961 g.prepareElement(g.fruitEl, -32, -16);
1962 g.playfieldEl.appendChild(g.fruitEl)
1963 };
1964 g.createPlayfieldElements = function () {
1965 g.doorEl = document.createElement("div");
1966 g.doorEl.id = "pcm-do";
1967 g.doorEl.style.display = "none";
1968 g.playfieldEl.appendChild(g.doorEl);
1969 g.createDotElements();
1970 g.createEnergizerElements();
1971 g.createFruitElement()
1972 };
1973 g.createActors = function () {
1974 g.actors = [];
1975 for (var b = 0; b < g.playerCount + 4; b++) {
1976 g.actors[b] = new E(b);
1977 if (b < g.playerCount) {
1978 g.actors[b].ghost = e;
1979 g.actors[b].mode = 1
1980 } else g.actors[b].ghost = a
1981 }
1982 };
1983 g.restartActors = function () {
1984 for (var b in g.actors) g.actors[b].A()
1985 };
1986 g.createActorElements = function () {
1987 for (var b in g.actors) g.actors[b].createElement()
1988 };
1989 g.createPlayfield = function () {
1990 g.playfieldEl = document.createElement("div");
1991 g.playfieldEl.id = "pcm-p";
1992 g.canvasEl.appendChild(g.playfieldEl)
1993 };
1994 g.resetPlayfield = function () {
1995 g.dotsRemaining = 0;
1996 g.dotsEaten = 0;
1997 g.playfieldEl.innerHTML = "";
1998 g.prepareElement(g.playfieldEl, 256, 0);
1999 g.determinePlayfieldDimensions();
2000 g.preparePlayfield();
2001 g.preparePaths();
2002 g.prepareAllowedDirections();
2003 g.createPlayfieldElements();
2004 g.createActorElements()
2005 };
2006 g.keyPressed = function (b) {
2007 var c = e;
2008 switch (b) {
2009 case 37:
2010 g.actors[0].requestedDir = 4;
2011 c = a;
2012 break;
2013 case 38:
2014 g.actors[0].requestedDir = 1;
2015 c = a;
2016 break;
2017 case 39:
2018 g.actors[0].requestedDir = 8;
2019 c = a;
2020 break;
2021 case 40:
2022 g.actors[0].requestedDir = 2;
2023 c = a;
2024 break;
2025 case 65:
2026 if (g.playerCount == 2) {
2027 g.actors[1].requestedDir = 4;
2028 c = a
2029 }
2030 break;
2031 case 83:
2032 if (g.playerCount == 2) {
2033 g.actors[1].requestedDir = 2;
2034 c = a
2035 }
2036 break;
2037 case 68:
2038 if (g.playerCount == 2) {
2039 g.actors[1].requestedDir = 8;
2040 c = a
2041 }
2042 break;
2043 case 87:
2044 if (g.playerCount == 2) {
2045 g.actors[1].requestedDir = 1;
2046 c = a
2047 }
2048 break
2049 }
2050 return c
2051 };
2052 g.handleKeyDown = function (b) {
2053 if (!b) b = window.event;
2054 if (g.keyPressed(b.keyCode)) if (b.preventDefault) b.preventDefault();
2055 else b.returnValue = e
2056 };
2057 g.canvasClicked = function (b, c) {
2058 var d = g.getAbsoluteElPos(g.canvasEl);
2059 b -= d[1] - -32;
2060 c -= d[0] - 0;
2061 d = g.actors[0];
2062 var f = g.getPlayfieldX(d.pos[1] + d.posDelta[1]) + 16,
2063 h = g.getPlayfieldY(d.pos[0] + d.posDelta[0]) + 32,
2064 j = Math.abs(b - f),
2065 k = Math.abs(c - h);
2066 if (j > 8 && k < j) d.requestedDir = b > f ? 8 : 4;
2067 else if (k > 8 && j < k) d.requestedDir = c > h ? 2 : 1
2068 };
2069 g.handleClick = function (b) {
2070 if (!b) b = window.event;
2071 g.canvasClicked(b.clientX, b.clientY)
2072 };
2073 g.registerTouch = function () {
2074 document.body.addEventListener("touchstart", g.handleTouchStart, a);
2075 g.canvasEl.addEventListener("touchstart", g.handleTouchStart, a);
2076 document.f && document.f.q && document.f.q.addEventListener("touchstart", g.handleTouchStart, a)
2077 };
2078 g.handleTouchStart = function (b) {
2079 g.touchDX = 0;
2080 g.touchDY = 0;
2081 if (b.touches.length == 1) {
2082 g.touchStartX = b.touches[0].pageX;
2083 g.touchStartY = b.touches[0].pageY;
2084 document.body.addEventListener("touchmove", g.handleTouchMove, a);
2085 document.body.addEventListener("touchend", g.handleTouchEnd, a)
2086 }
2087 b.preventDefault();
2088 b.stopPropagation()
2089 };
2090 g.handleTouchMove = function (b) {
2091 if (b.touches.length > 1) g.cancelTouch();
2092 else {
2093 g.touchDX = b.touches[0].pageX - g.touchStartX;
2094 g.touchDY = b.touches[0].pageY - g.touchStartY
2095 }
2096 b.preventDefault();
2097 b.stopPropagation()
2098 };
2099 g.handleTouchEnd = function (b) {
2100 if (g.touchDX == 0 && g.touchDY == 0) g.canvasClicked(g.touchStartX, g.touchStartY);
2101 else {
2102 var c = Math.abs(g.touchDX),
2103 d = Math.abs(g.touchDY);
2104 if (c < 8 && d < 8) g.canvasClicked(g.touchStartX, g.touchStartY);
2105 else if (c > 15 && d < c * 2 / 3) g.actors[0].requestedDir = g.touchDX > 0 ? 8 : 4;
2106 else if (d > 15 && c < d * 2 / 3) g.actors[0].requestedDir = g.touchDY > 0 ? 2 : 1
2107 }
2108 b.preventDefault();
2109 b.stopPropagation();
2110 g.cancelTouch()
2111 };
2112 g.cancelTouch = function () {
2113 document.body.removeEventListener("touchmove", g.handleTouchMove, a);
2114 document.body.removeEventListener("touchend", g.handleTouchEnd, a);
2115 g.touchStartX = null;
2116 g.touchStartY = null
2117 };
2118 g.addEventListeners = function () {
2119 if (window.addEventListener) {
2120 window.addEventListener("keydown", g.handleKeyDown, e);
2121 g.canvasEl.addEventListener("click", g.handleClick, e);
2122 g.registerTouch()
2123 } else {
2124 document.body.attachEvent("onkeydown", g.handleKeyDown);
2125 g.canvasEl.attachEvent("onclick", g.handleClick)
2126 }
2127 };
2128 g.startGameplay = function () {
2129 g.score = [0, 0];
2130 g.extraLifeAwarded = [e, e];
2131 g.lives = 3;
2132 g.level = 0;
2133 g.paused = e;
2134 g.globalTime = 0;
2135 g.newLevel(a)
2136 };
2137 g.restartGameplay = function (b) {
2138 g.seed(0);
2139 g.frightModeTime = 0;
2140 g.intervalTime = 0;
2141 g.gameplayModeTime = 0;
2142 g.fruitTime = 0;
2143 g.ghostModeSwitchPos = 0;
2144 g.ghostModeTime = g.levels.ghostModeSwitchTimes[0] * D;
2145 g.ghostExitingPenNow = e;
2146 g.ghostEyesCount = 0;
2147 g.tilesChanged = e;
2148 g.updateCruiseElroySpeed();
2149 g.hideFruit();
2150 g.resetForcePenLeaveTime();
2151 g.restartActors();
2152 g.updateActorPositions();
2153 g.switchMainGhostMode(2, a);
2154 for (var c = g.playerCount + 1; c < g.playerCount + 4; c++) g.actors[c].a(16);
2155 g.dotEatingChannel = [0, 0];
2156 g.dotEatingSoundPart = [1, 1];
2157 g.clearDotEatingNow();
2158 b ? g.changeGameplayMode(4) : g.changeGameplayMode(6)
2159 };
2160 g.initiateDoubleMode = function () {
2161 if (g.playerCount != 2) {
2162 g.stopAllAudio();
2163 g.changeGameplayMode(12)
2164 }
2165 };
2166 g.newGame = function () {
2167 g.playerCount = 1;
2168 g.createChrome();
2169 g.createPlayfield();
2170 g.createActors();
2171 g.startGameplay()
2172 };
2173 g.switchToDoubleMode = function () {
2174 g.playerCount = 2;
2175 g.createChrome();
2176 g.createPlayfield();
2177 g.createActors();
2178 g.startGameplay()
2179 };
2180 g.insertCoin = function () {
2181 g.gameplayMode == 8 || g.gameplayMode == 14 ? g.newGame() : g.initiateDoubleMode()
2182 };
2183 g.createKillScreenElement = function (b, c, d, f, h) {
2184 var j = document.createElement("div");
2185 j.style.left = b + "px";
2186 j.style.top = c + "px";
2187 j.style.width = d + "px";
2188 j.style.height = f + "px";
2189 j.style.zIndex = 119;
2190 if (h) {
2191 j.style.background = "url(src/pacman10-hp-sprite.png) -" + g.killScreenTileX + "px -" + g.killScreenTileY + "px no-repeat";
2192 g.killScreenTileY += 8
2193 } else j.style.background = "black";
2194 g.playfieldEl.appendChild(j)
2195 };
2196 g.killScreen = function () {
2197 g.seed(0);
2198 g.canvasEl.style.visibility = "";
2199 g.createKillScreenElement(272, 0, 200, 80, e);
2200 g.createKillScreenElement(280, 80, 192, 56, e);
2201 g.killScreenTileX = 80;
2202 g.killScreenTileY = 0;
2203 for (var b = 280; b <= 472; b += 8) for (var c = 0; c <= 136; c += 8) {
2204 if (g.rand() < 0.03) {
2205 g.killScreenTileX = Math.floor(g.rand() * 25) * 10;
2206 g.killScreenTileY = Math.floor(g.rand() * 2) * 10
2207 }
2208 g.createKillScreenElement(b, c, 8, 8, a)
2209 }
2210 g.changeGameplayMode(14)
2211 };
2212 g.newLevel = function (b) {
2213 g.level++;
2214 g.levels = g.level >= z.length ? z[z.length - 1] : z[g.level];
2215 g.levels.frightTime = Math.round(g.levels.frightTime * D);
2216 g.levels.frightTotalTime = g.levels.frightTime + g.timing[1] * (g.levels.frightBlinkCount * 2 - 1);
2217 for (var c in g.actors) g.actors[c].dotCount = 0;
2218 g.alternatePenLeavingScheme = e;
2219 g.lostLifeOnThisLevel = e;
2220 g.updateChrome();
2221 g.resetPlayfield();
2222 g.restartGameplay(b);
2223 g.level == 256 && g.killScreen()
2224 };
2225 g.newLife = function () {
2226 g.lostLifeOnThisLevel = a;
2227 g.alternatePenLeavingScheme = a;
2228 g.alternateDotCount = 0;
2229 g.lives--;
2230 g.updateChromeLives();
2231 g.lives == -1 ? g.changeGameplayMode(8) : g.restartGameplay(e)
2232 };
2233 g.switchMainGhostMode = function (b, c) {
2234 if (b == 4 && g.levels.frightTime == 0) for (var d in g.actors) {
2235 var f = g.actors[d];
2236 if (f.ghost) f.reverseDirectionsNext = a
2237 } else {
2238 f = g.mainGhostMode;
2239 if (b == 4 && g.mainGhostMode != 4) g.lastMainGhostMode = g.mainGhostMode;
2240 g.mainGhostMode = b;
2241 if (b == 4 || f == 4) g.playAmbientSound();
2242 switch (b) {
2243 case 1:
2244 case 2:
2245 g.currentPlayerSpeed = g.levels.playerSpeed * 0.8;
2246 g.currentDotEatingSpeed = g.levels.dotEatingSpeed * 0.8;
2247 break;
2248 case 4:
2249 g.currentPlayerSpeed = g.levels.playerFrightSpeed * 0.8;
2250 g.currentDotEatingSpeed = g.levels.dotEatingFrightSpeed * 0.8;
2251 g.frightModeTime = g.levels.frightTotalTime;
2252 g.modeScoreMultiplier = 1;
2253 break
2254 }
2255 for (d in g.actors) {
2256 f = g.actors[d];
2257 if (f.ghost) {
2258 if (b != 64 && !c) f.modeChangedWhileInPen = a;
2259 if (b == 4) f.eatenInThisFrightMode = e;
2260 if (f.mode != 8 && f.mode != 16 && f.mode != 32 && f.mode != 128 && f.mode != 64 || c) {
2261 if (!c && f.mode != 4 && f.mode != b) f.reverseDirectionsNext = a;
2262 f.a(b)
2263 }
2264 } else {
2265 f.fullSpeed = g.currentPlayerSpeed;
2266 f.dotEatingSpeed = g.currentDotEatingSpeed;
2267 f.tunnelSpeed = g.currentPlayerSpeed;
2268 f.d()
2269 }
2270 }
2271 }
2272 };
2273 g.figureOutPenLeaving = function () {
2274 if (g.alternatePenLeavingScheme) {
2275 g.alternateDotCount++;
2276 switch (g.alternateDotCount) {
2277 case m[1]:
2278 g.actors[g.playerCount + 1].freeToLeavePen = a;
2279 break;
2280 case m[2]:
2281 g.actors[g.playerCount + 2].freeToLeavePen = a;
2282 break;
2283 case m[3]:
2284 if (g.actors[g.playerCount + 3].mode == 16) g.alternatePenLeavingScheme = e;
2285 break
2286 }
2287 } else if (g.actors[g.playerCount + 1].mode == 16 || g.actors[g.playerCount + 1].mode == 8) {
2288 g.actors[g.playerCount + 1].dotCount++;
2289 if (g.actors[g.playerCount + 1].dotCount >= g.levels.penLeavingLimits[1]) g.actors[g.playerCount + 1].freeToLeavePen = a
2290 } else if (g.actors[g.playerCount + 2].mode == 16 || g.actors[g.playerCount + 2].mode == 8) {
2291 g.actors[g.playerCount + 2].dotCount++;
2292 if (g.actors[g.playerCount + 2].dotCount >= g.levels.penLeavingLimits[2]) g.actors[g.playerCount + 2].freeToLeavePen = a
2293 } else if (g.actors[g.playerCount + 3].mode == 16 || g.actors[g.playerCount + 3].mode == 8) {
2294 g.actors[g.playerCount + 3].dotCount++;
2295 if (g.actors[g.playerCount + 3].dotCount >= g.levels.penLeavingLimits[3]) g.actors[g.playerCount + 3].freeToLeavePen = a
2296 }
2297 };
2298 g.resetForcePenLeaveTime = function () {
2299 g.forcePenLeaveTime = g.levels.penForceTime * D
2300 };
2301 g.dotEaten = function (b, c) {
2302 g.dotsRemaining--;
2303 g.dotsEaten++;
2304 g.actors[b].c(1);
2305 g.playDotEatingSound(b);
2306 if (g.playfield[c[0]][c[1]].dot == 2) {
2307 g.switchMainGhostMode(4, e);
2308 g.addToScore(50, b)
2309 } else g.addToScore(10, b);
2310 var d = document.getElementById(g.getDotElementId(c[0], c[1]));
2311 d.style.display = "none";
2312 g.playfield[c[0]][c[1]].dot = 0;
2313 g.updateCruiseElroySpeed();
2314 g.resetForcePenLeaveTime();
2315 g.figureOutPenLeaving();
2316 if (g.dotsEaten == 70 || g.dotsEaten == 170) g.showFruit();
2317 g.dotsRemaining == 0 && g.finishLevel();
2318 g.playAmbientSound()
2319 };
2320 g.getFruitSprite = function (b) {
2321 var c = b <= 4 ? 128 : 160;
2322 b = 128 + 16 * ((b - 1) % 4);
2323 return [c, b]
2324 };
2325 g.getFruitScoreSprite = function (b) {
2326 var c = 128;
2327 b = 16 * (b - 1);
2328 return [c, b]
2329 };
2330 g.hideFruit = function () {
2331 g.fruitShown = e;
2332 g.changeElementBkPos(g.fruitEl, 32, 16, a)
2333 };
2334 g.showFruit = function () {
2335 g.fruitShown = a;
2336 var b = g.getFruitSprite(g.levels.fruit);
2337 g.changeElementBkPos(g.fruitEl, b[0], b[1], a);
2338 g.fruitTime = g.timing[15] + (g.timing[16] - g.timing[15]) * g.rand()
2339 };
2340 g.eatFruit = function (b) {
2341 if (g.fruitShown) {
2342 g.playSound("fruit", 0);
2343 g.fruitShown = e;
2344 var c = g.getFruitScoreSprite(g.levels.fruit);
2345 g.changeElementBkPos(g.fruitEl, c[0], c[1], a);
2346 g.fruitTime = g.timing[14];
2347 g.addToScore(g.levels.fruitScore, b)
2348 }
2349 };
2350 g.updateActorTargetPositions = function () {
2351 for (var b = g.playerCount; b < g.playerCount + 4; b++) g.actors[b].B()
2352 };
2353 g.moveActors = function () {
2354 for (var b in g.actors) g.actors[b].move()
2355 };
2356 g.ghostDies = function (b, c) {
2357 g.playSound("eating-ghost", 0);
2358 g.addToScore(200 * g.modeScoreMultiplier, c);
2359 g.modeScoreMultiplier *= 2;
2360 g.ghostBeingEatenId = b;
2361 g.playerEatingGhostId = c;
2362 g.changeGameplayMode(1)
2363 };
2364 g.playerDies = function (b) {
2365 g.playerDyingId = b;
2366 g.changeGameplayMode(2)
2367 };
2368 g.detectCollisions = function () {
2369 g.tilesChanged = e;
2370 for (var b = g.playerCount; b < g.playerCount + 4; b++) for (var c = 0; c < g.playerCount; c++) if (g.actors[b].tilePos[0] == g.actors[c].tilePos[0] && g.actors[b].tilePos[1] == g.actors[c].tilePos[1]) if (g.actors[b].mode == 4) {
2371 g.ghostDies(b, c);
2372 return
2373 } else g.actors[b].mode != 8 && g.actors[b].mode != 16 && g.actors[b].mode != 32 && g.actors[b].mode != 128 && g.actors[b].mode != 64 && g.playerDies(c)
2374 };
2375 g.updateCruiseElroySpeed = function () {
2376 var b = g.levels.ghostSpeed * 0.8;
2377 if (!g.lostLifeOnThisLevel || g.actors[g.playerCount + 3].mode != 16) {
2378 var c = g.levels;
2379 if (g.dotsRemaining < c.elroyDotsLeftPart2) b = c.elroySpeedPart2 * 0.8;
2380 else if (g.dotsRemaining < c.elroyDotsLeftPart1) b = c.elroySpeedPart1 * 0.8
2381 }
2382 if (b != g.cruiseElroySpeed) {
2383 g.cruiseElroySpeed = b;
2384 g.actors[g.playerCount].d()
2385 }
2386 };
2387 g.getSpeedIntervals = function (b) {
2388 if (!g.speedIntervals[b]) {
2389 var c = 0,
2390 d = 0;
2391 g.speedIntervals[b] = [];
2392 for (var f = 0; f < D; f++) {
2393 c += b;
2394 if (Math.floor(c) > d) {
2395 g.speedIntervals[b].push(a);
2396 d = Math.floor(c)
2397 } else g.speedIntervals[b].push(e)
2398 }
2399 }
2400 return g.speedIntervals[b]
2401 };
2402 g.finishLevel = function () {
2403 g.changeGameplayMode(9)
2404 };
2405 g.changeGameplayMode = function (b) {
2406 g.gameplayMode = b;
2407 if (b != 13) for (var c = 0; c < g.playerCount + 4; c++) g.actors[c].b();
2408 switch (b) {
2409 case 0:
2410 g.playAmbientSound();
2411 break;
2412 case 2:
2413 g.stopAllAudio();
2414 g.gameplayModeTime = g.timing[3];
2415 break;
2416 case 3:
2417 g.playerDyingId == 0 ? g.playSound("death", 0) : g.playSound("death-double", 0);
2418 g.gameplayModeTime = g.timing[4];
2419 break;
2420 case 6:
2421 g.canvasEl.style.visibility = "hidden";
2422 g.gameplayModeTime = g.timing[5];
2423 break;
2424 case 7:
2425 g.stopAllAudio();
2426 g.canvasEl.style.visibility = "";
2427 g.doorEl.style.display = "block";
2428 b = document.createElement("div");
2429 b.id = "pcm-re";
2430 g.prepareElement(b, 160, 0);
2431 g.playfieldEl.appendChild(b);
2432 g.gameplayModeTime = g.timing[6];
2433 break;
2434 case 4:
2435 g.doorEl.style.display = "block";
2436 b = document.createElement("div");
2437 b.id = "pcm-re";
2438 g.prepareElement(b, 160, 0);
2439 g.playfieldEl.appendChild(b);
2440 g.gameplayModeTime = g.timing[7];
2441 g.stopAllAudio();
2442 g.playerCount == 2 ? g.playSound("start-music-double", 0, a) : g.playSound("start-music", 0, a);
2443 break;
2444 case 5:
2445 g.lives--;
2446 g.updateChromeLives();
2447 g.gameplayModeTime = g.timing[8];
2448 break;
2449 case 8:
2450 case 14:
2451 b = document.getElementById("pcm-re");
2452 google.dom.remove(b);
2453 g.stopAllAudio();
2454 b = document.createElement("div");
2455 b.id = "pcm-go";
2456 g.prepareElement(b, 8, 152);
2457 g.playfieldEl.appendChild(b);
2458 g.gameplayModeTime = g.timing[9];
2459 break;
2460 case 9:
2461 g.stopAllAudio();
2462 g.gameplayModeTime = g.timing[10];
2463 break;
2464 case 10:
2465 g.doorEl.style.display = "none";
2466 g.gameplayModeTime = g.timing[11];
2467 break;
2468 case 11:
2469 g.canvasEl.style.visibility = "hidden";
2470 g.gameplayModeTime = g.timing[12];
2471 break;
2472 case 12:
2473 g.playfieldEl.style.visibility = "hidden";
2474 g.gameplayModeTime = g.timing[13];
2475 break;
2476 case 1:
2477 g.gameplayModeTime =
2478 g.timing[2];
2479 break;
2480 case 13:
2481 g.startCutscene();
2482 break
2483 }
2484 };
2485 g.showChrome = function (b) {
2486 g.showElementById("pcm-sc-1-l", b);
2487 g.showElementById("pcm-sc-2-l", b);
2488 g.showElementById("pcm-sc-1", b);
2489 g.showElementById("pcm-sc-2", b);
2490 g.showElementById("pcm-li", b);
2491 g.showElementById("pcm-so", b)
2492 };
2493 g.startCutscene = function () {
2494 g.playfieldEl.style.visibility = "hidden";
2495 g.canvasEl.style.visibility = "";
2496 g.showChrome(e);
2497 g.cutsceneCanvasEl = document.createElement("div");
2498 g.cutsceneCanvasEl.id = "pcm-cc";
2499 g.canvasEl.appendChild(g.cutsceneCanvasEl);
2500 g.cutscene = B[g.cutsceneId];
2501 g.cutsceneSequenceId = -1;
2502 g.frightModeTime = g.levels.frightTotalTime;
2503 g.cutsceneActors = [];
2504 for (var b in g.cutscene.actors) {
2505 var c = g.cutscene.actors[b].id;
2506 if (c > 0) c += g.playerCount - 1;
2507 var d = document.createElement("div");
2508 d.className = "pcm-ac";
2509 d.id = "actor" + c;
2510 g.prepareElement(d, 0, 0);
2511 c = new E(c);
2512 c.el = d;
2513 c.elBackgroundPos = [0, 0];
2514 c.elPos = [0, 0];
2515 c.pos = [g.cutscene.actors[b].y * 8, g.cutscene.actors[b].x * 8];
2516 c.posDelta = [0, 0];
2517 c.ghost = g.cutscene.actors[b].ghost;
2518 g.cutsceneCanvasEl.appendChild(d);
2519 g.cutsceneActors.push(c)
2520 }
2521 g.cutsceneNextSequence();
2522 g.stopAllAudio();
2523 g.playAmbientSound()
2524 };
2525 g.stopCutscene = function () {
2526 g.playfieldEl.style.visibility = "";
2527 google.dom.remove(g.cutsceneCanvasEl);
2528 g.showChrome(a);
2529 g.newLevel(e)
2530 };
2531 g.cutsceneNextSequence = function () {
2532 g.cutsceneSequenceId++;
2533 if (g.cutscene.sequence.length == g.cutsceneSequenceId) g.stopCutscene();
2534 else {
2535 var b = g.cutscene.sequence[g.cutsceneSequenceId];
2536 g.cutsceneTime = b.time * D;
2537 for (var c in g.cutsceneActors) {
2538 var d = g.cutsceneActors[c];
2539 d.dir = b.moves[c].dir;
2540 d.speed = b.moves[c].speed;
2541 if (b.moves[c].elId) d.el.id = b.moves[c].elId;
2542 if (b.moves[c].mode) d.mode = b.moves[c].mode;
2543 d.b()
2544 }
2545 }
2546 };
2547 g.checkCutscene = function () {
2548 g.cutsceneTime <= 0 && g.cutsceneNextSequence()
2549 };
2550 g.advanceCutscene = function () {
2551 for (var b in g.cutsceneActors) {
2552 var c = g.cutsceneActors[b],
2553 d = l[c.dir];
2554 c.pos[d.axis] += d.increment * c.speed;
2555 c.b()
2556 }
2557 g.cutsceneTime--
2558 };
2559 g.updateActorPositions = function () {
2560 for (var b in g.actors) g.actors[b].k()
2561 };
2562 g.blinkEnergizers = function () {
2563 switch (g.gameplayMode) {
2564 case 4:
2565 case 5:
2566 case 6:
2567 case 7:
2568 case 9:
2569 case 10:
2570 case 11:
2571 case 12:
2572 g.playfieldEl.className = "";
2573 break;
2574 case 8:
2575 case 14:
2576 g.playfieldEl.className = "blk";
2577 break;
2578 default:
2579 if (g.globalTime % (g.timing[0] * 2) == 0) g.playfieldEl.className = "";
2580 else if (g.globalTime % (g.timing[0] * 2) == g.timing[0]) g.playfieldEl.className = "blk";
2581 break
2582 }
2583 };
2584 g.blinkScoreLabels = function () {
2585 if (g.gameplayMode != 13) {
2586 var b = "";
2587 if (g.globalTime % (g.timing[17] * 2) == 0) b = "visible";
2588 else if (g.globalTime % (g.timing[17] * 2) == g.timing[17]) b = "hidden";
2589 if (b) for (var c = 0; c < g.playerCount; c++) g.scoreLabelEl[c].style.visibility = b
2590 }
2591 };
2592 g.finishFrightMode = function () {
2593 g.switchMainGhostMode(g.lastMainGhostMode, e)
2594 };
2595 g.handleGameplayModeTimer = function () {
2596 if (g.gameplayModeTime) {
2597 g.gameplayModeTime--;
2598 switch (g.gameplayMode) {
2599 case 2:
2600 case 3:
2601 for (var b = 0; b < g.playerCount + 4; b++) g.actors[b].b();
2602 break;
2603 case 10:
2604 Math.floor(g.gameplayModeTime / (g.timing[11] / 8)) % 2 == 0 ? g.changeElementBkPos(g.playfieldEl, 322, 2, e) : g.changeElementBkPos(g.playfieldEl, 322, 138, e)
2605 }
2606 if (g.gameplayModeTime <= 0) {
2607 g.gameplayModeTime = 0;
2608 switch (g.gameplayMode) {
2609 case 1:
2610 g.changeGameplayMode(0);
2611 g.ghostEyesCount++;
2612 g.playAmbientSound();
2613 g.actors[g.ghostBeingEatenId].el.className = "pcm-ac";
2614 g.actors[g.ghostBeingEatenId].a(8);
2615 var c = e;
2616 for (b = g.playerCount; b < g.playerCount + 4; b++) if (g.actors[b].mode == 4 || (g.actors[b].mode == 16 || g.actors[b].mode == 128) && !g.actors[b].eatenInThisFrightMode) {
2617 c = a;
2618 break
2619 }
2620 c || g.finishFrightMode();
2621 break;
2622 case 2:
2623 g.changeGameplayMode(3);
2624 break;
2625 case 3:
2626 g.newLife();
2627 break;
2628 case 4:
2629 g.changeGameplayMode(5);
2630 break;
2631 case 6:
2632 g.changeGameplayMode(7);
2633 break;
2634 case 7:
2635 case 5:
2636 b = document.getElementById("pcm-re");
2637 google.dom.remove(b);
2638 g.changeGameplayMode(0);
2639 break;
2640 case 8:
2641 b = document.getElementById("pcm-go");
2642 google.dom.remove(b);
2643 google.pacManQuery && google.pacManQuery();
2644 break;
2645 case 9:
2646 g.changeGameplayMode(10);
2647 break;
2648 case 10:
2649 g.changeGameplayMode(11);
2650 break;
2651 case 11:
2652 if (g.levels.cutsceneId) {
2653 g.cutsceneId = g.levels.cutsceneId;
2654 g.changeGameplayMode(13)
2655 } else {
2656 g.canvasEl.style.visibility = "";
2657 g.newLevel(e)
2658 }
2659 break;
2660 case 12:
2661 g.playfieldEl.style.visibility = "";
2662 g.canvasEl.style.visibility = "";
2663 g.switchToDoubleMode();
2664 break
2665 }
2666 }
2667 }
2668 };
2669 g.handleFruitTimer = function () {
2670 if (g.fruitTime) {
2671 g.fruitTime--;
2672 g.fruitTime <= 0 && g.hideFruit()
2673 }
2674 };
2675 g.handleGhostModeTimer = function () {
2676 if (g.frightModeTime) {
2677 g.frightModeTime--;
2678 if (g.frightModeTime <= 0) {
2679 g.frightModeTime = 0;
2680 g.finishFrightMode()
2681 }
2682 } else if (g.ghostModeTime > 0) {
2683 g.ghostModeTime--;
2684 if (g.ghostModeTime <= 0) {
2685 g.ghostModeTime = 0;
2686 g.ghostModeSwitchPos++;
2687 if (g.levels.ghostModeSwitchTimes[g.ghostModeSwitchPos]) {
2688 g.ghostModeTime = g.levels.ghostModeSwitchTimes[g.ghostModeSwitchPos] * D;
2689 switch (g.mainGhostMode) {
2690 case 2:
2691 g.switchMainGhostMode(1, e);
2692 break;
2693 case 1:
2694 g.switchMainGhostMode(2, e);
2695 break
2696 }
2697 }
2698 }
2699 }
2700 };
2701 g.handleForcePenLeaveTimer = function () {
2702 if (g.forcePenLeaveTime) {
2703 g.forcePenLeaveTime--;
2704 if (g.forcePenLeaveTime <= 0) {
2705 for (var b = 1; b <= 3; b++) if (g.actors[g.playerCount + b].mode == 16) {
2706 g.actors[g.playerCount + b].freeToLeavePen = a;
2707 break
2708 }
2709 g.resetForcePenLeaveTime()
2710 }
2711 }
2712 };
2713 g.handleTimers = function () {
2714 if (g.gameplayMode == 0) {
2715 g.handleForcePenLeaveTimer();
2716 g.handleFruitTimer();
2717 g.handleGhostModeTimer()
2718 }
2719 g.handleGameplayModeTimer()
2720 };
2721 g.tick = function () {
2722 var b = (new Date).getTime();
2723 g.lastTimeDelta += b - g.lastTime - g.tickInterval;
2724 if (g.lastTimeDelta > 100) g.lastTimeDelta = 100;
2725 if (g.canDecreaseFps && g.lastTimeDelta > 50) {
2726 g.lastTimeSlownessCount++;
2727 g.lastTimeSlownessCount == 20 && g.decreaseFps()
2728 }
2729 var c = 0;
2730 if (g.lastTimeDelta > g.tickInterval) {
2731 c = Math.floor(g.lastTimeDelta / g.tickInterval);
2732 g.lastTimeDelta -= g.tickInterval * c
2733 }
2734 g.lastTime = b;
2735 if (g.gameplayMode == 13) {
2736 for (b = 0; b < g.tickMultiplier + c; b++) {
2737 g.advanceCutscene();
2738 g.intervalTime = (g.intervalTime + 1) % D;
2739 g.globalTime++
2740 }
2741 g.checkCutscene();
2742 g.blinkScoreLabels()
2743 } else for (b = 0; b < g.tickMultiplier + c; b++) {
2744 g.moveActors();
2745 if (g.gameplayMode == 0) if (g.tilesChanged) {
2746 g.detectCollisions();
2747 g.updateActorTargetPositions()
2748 }
2749 g.globalTime++;
2750 g.intervalTime = (g.intervalTime + 1) % D;
2751 g.blinkEnergizers();
2752 g.blinkScoreLabels();
2753 g.handleTimers()
2754 }
2755 };
2756 g.extraLife = function (b) {
2757 g.playSound("extra-life", 0);
2758 g.extraLifeAwarded[b] = a;
2759 g.lives++;
2760 if (g.lives > 5) g.lives = 5;
2761 g.updateChromeLives()
2762 };
2763 g.addToScore = function (b, c) {
2764 g.score[c] += b;
2765 !g.extraLifeAwarded[c] && g.score[c] > 1E4 && g.extraLife(c);
2766 g.updateChromeScore(c)
2767 };
2768 g.updateChrome = function () {
2769 g.updateChromeLevel();
2770 g.updateChromeLives();
2771 for (var b = 0; b < g.playerCount; b++) g.updateChromeScore(b)
2772 };
2773 g.updateChromeScore = function (b) {
2774 var c = g.score[b].toString();
2775 if (c.length > g.scoreDigits) c = c.substr(c.length - g.scoreDigits, g.scoreDigits);
2776 for (var d = 0; d < g.scoreDigits; d++) {
2777 var f = document.getElementById("pcm-sc-" + (b + 1) + "-" + d),
2778 h = c.substr(d, 1);
2779 h ? g.changeElementBkPos(f, 8 + 8 * parseInt(h, 10), 144, a) : g.changeElementBkPos(f, 48, 0, a)
2780 }
2781 };
2782 g.updateChromeLives = function () {
2783 g.livesEl.innerHTML = "";
2784 for (var b = 0; b < g.lives; b++) {
2785 var c = document.createElement("div");
2786 c.className = "pcm-lif";
2787 g.prepareElement(c, 64, 129);
2788 g.livesEl.appendChild(c)
2789 }
2790 };
2791 g.updateChromeLevel = function () {
2792 g.levelEl.innerHTML = "";
2793 for (var b = g.level; b >= Math.max(g.level - 4 + 1, 1); b--) {
2794 var c = b >= z.length ? z[z.length - 1].fruit : z[b].fruit,
2795 d = document.createElement("div");
2796 c = g.getFruitSprite(c);
2797 g.prepareElement(d, c[0], c[1]);
2798 g.levelEl.appendChild(d)
2799 }
2800 g.levelEl.style.marginTop = (4 - Math.min(g.level, 4)) * 16 + "px"
2801 };
2802 g.createChrome = function () {
2803 g.canvasEl.innerHTML = "";
2804 g.scoreDigits = g.playerCount == 1 ? 10 : 5;
2805 g.scoreLabelEl = [];
2806 g.scoreLabelEl[0] = document.createElement("div");
2807 g.scoreLabelEl[0].id = "pcm-sc-1-l";
2808 g.prepareElement(g.scoreLabelEl[0], 160, 56);
2809 g.canvasEl.appendChild(g.scoreLabelEl[0]);
2810 g.scoreEl = [];
2811 g.scoreEl[0] = document.createElement("div");
2812 g.scoreEl[0].id = "pcm-sc-1";
2813 for (var b = 0; b < g.scoreDigits; b++) {
2814 var c = document.createElement("div");
2815 c.id = "pcm-sc-1-" + b;
2816 c.style.top = b * 8 + "px";
2817 c.style.left = 0;
2818 c.style.position = "absolute";
2819 c.style.width = "8px";
2820 c.style.height = "8px";
2821 g.prepareElement(c, 48, 0);
2822 g.scoreEl[0].appendChild(c)
2823 }
2824 g.canvasEl.appendChild(g.scoreEl[0]);
2825 g.livesEl = document.createElement("div");
2826 g.livesEl.id = "pcm-li";
2827 g.canvasEl.appendChild(g.livesEl);
2828 g.levelEl = document.createElement("div");
2829 g.levelEl.id = "pcm-le";
2830 g.canvasEl.appendChild(g.levelEl);
2831 if (g.playerCount == 2) {
2832 g.scoreLabelEl[1] = document.createElement("div");
2833 g.scoreLabelEl[1].id = "pcm-sc-2-l";
2834 g.prepareElement(g.scoreLabelEl[1], 160, 64);
2835 g.canvasEl.appendChild(g.scoreLabelEl[1]);
2836 g.scoreEl[1] = document.createElement("div");
2837 g.scoreEl[1].id = "pcm-sc-2";
2838 for (b = 0; b < g.scoreDigits; b++) {
2839 c = document.createElement("div");
2840 c.id = "pcm-sc-2-" + b;
2841 c.style.top = b * 8 + "px";
2842 c.style.left = 0;
2843 c.style.position = "absolute";
2844 c.style.width = "8px";
2845 c.style.height = "8px";
2846 g.prepareElement(c, 48, 0);
2847 g.scoreEl[1].appendChild(c)
2848 }
2849 g.canvasEl.appendChild(g.scoreEl[1])
2850 }
2851 };
2852 g.clearDotEatingNow = function () {
2853 g.dotEatingNow = [e, e];
2854 g.dotEatingNext = [e, e]
2855 };
2856 g.playSound = function (b, c, d) {
2857 if (!(!g.soundAvailable || !g.soundEnabled || g.paused)) {
2858 d || g.stopSoundChannel(c);
2859 try {
2860 g.flashSoundPlayer.playTrack(b, c)
2861 } catch (f) {
2862 g.soundAvailable = e
2863 }
2864 }
2865 };
2866 g.stopSoundChannel = function (b) {
2867 if (g.soundAvailable && g.soundEnabled) try {
2868 g.flashSoundPlayer.stopChannel(b)
2869 } catch (c) {
2870 g.soundAvailable = e
2871 }
2872 };
2873 g.stopAllAudio = function () {
2874 if (g.soundAvailable && g.soundEnabled) {
2875 try {
2876 g.flashSoundPlayer.stopAmbientTrack()
2877 } catch (b) {
2878 g.soundAvailable = e
2879 }
2880 for (var c = 0; c < 5; c++) g.stopSoundChannel(c)
2881 }
2882 };
2883 g.playDotEatingSound = function (b) {
2884 if (g.soundAvailable && g.soundEnabled) if (g.gameplayMode == 0) if (g.dotEatingNow[b]) g.dotEatingNext[b] = a;
2885 else {
2886 if (b == 0) {
2887 var c = g.dotEatingSoundPart[b] == 1 ? "eating-dot-1" : "eating-dot-2";
2888 g.playSound(c, 1 + g.dotEatingChannel[b], a);
2889 g.dotTimer = window.setInterval(g.repeatDotEatingSoundPacMan, 150)
2890 } else {
2891 g.playSound("eating-dot-double", 3 + g.dotEatingChannel[b], a);
2892 g.dotTimerMs = window.setInterval(g.repeatDotEatingSoundMsPacMan, 150)
2893 }
2894 g.dotEatingChannel[b] = (g.dotEatingChannel[b] + 1) % 2;
2895 g.dotEatingSoundPart[b] =
2896 3 - g.dotEatingSoundPart[b]
2897 }
2898 };
2899 g.repeatDotEatingSound = function (b) {
2900 g.dotEatingNow[b] = e;
2901 if (g.dotEatingNext[b]) {
2902 g.dotEatingNext[b] = e;
2903 g.playDotEatingSound(b)
2904 }
2905 };
2906 g.repeatDotEatingSoundPacMan = function () {
2907 g.repeatDotEatingSound(0)
2908 };
2909 g.repeatDotEatingSoundMsPacMan = function () {
2910 g.repeatDotEatingSound(1)
2911 };
2912 g.playAmbientSound = function () {
2913 if (g.soundAvailable && g.soundEnabled) {
2914 var b = 0;
2915 if (g.gameplayMode == 0 || g.gameplayMode == 1) b = g.ghostEyesCount ? "ambient-eyes" : g.mainGhostMode == 4 ? "ambient-fright" : g.dotsEaten > 241 ? "ambient-4" : g.dotsEaten > 207 ? "ambient-3" : g.dotsEaten > 138 ? "ambient-2" : "ambient-1";
2916 else if (g.gameplayMode == 13) b = "cutscene";
2917 if (b) try {
2918 g.flashSoundPlayer.playAmbientTrack(b)
2919 } catch (c) {
2920 g.soundAvailable = e
2921 }
2922 }
2923 };
2924 g.initializeTickTimer = function () {
2925 window.clearInterval(g.tickTimer);
2926 g.fps = C[g.fpsChoice];
2927 g.tickInterval = 1E3 / g.fps;
2928 g.tickMultiplier = D / g.fps;
2929 g.timing = {};
2930 for (var b in w) {
2931 var c = !g.soundEnabled && (b == 7 || b == 8) ? 1 : w[b];
2932 g.timing[b] = Math.round(c * D)
2933 }
2934 g.lastTime = (new Date).getTime();
2935 g.lastTimeDelta = 0;
2936 g.lastTimeSlownessCount = 0;
2937 g.tickTimer = window.setInterval(g.tick, g.tickInterval)
2938 };
2939 g.decreaseFps = function () {
2940 if (g.fpsChoice < C.length - 1) {
2941 g.fpsChoice++;
2942 g.initializeTickTimer();
2943 if (g.fpsChoice == C.length - 1) g.canDecreaseFps = e
2944 }
2945 };
2946 g.addCss = function () {
2947 var b = "#pcm-c { width: 554px; border-top: 25px solid black; padding-bottom: 25px; height: 136px; position: relative; background: black; outline: 0; overflow: hidden; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}#pcm-c * { position: absolute; overflow: hidden;}#pcm-p,#pcm-cc { left: 45px; width: 464px; height: 136px; z-index: 99; overflow: hidden;}#pcm-p .pcm-d { width: 2px; height: 2px; margin-left: 3px; margin-top: 3px; background: #f8b090; z-index: 100;}#pcm-p .pcm-e { width: 8px; height: 8px; z-index: 101;}#pcm-sc-1 { left: 18px; top: 16px; width: 8px; height: 56px; position: absolute; overflow: hidden;}#pcm-sc-2 { left: 18px; top: 80px; width: 8px; height: 56px; position: absolute; overflow: hidden;}#pcm-le { position: absolute; left: 515px; top: 74px; height: 64px; width: 32px;} #pcm-le div { position: relative;}#pcm-sc-1-l { left: -2px; top: 0; width: 48px; height: 8px;}#pcm-sc-2-l { left: -2px; top: 64px; width: 48px; height: 8px;}#pcm-so { left: 7px; top: 116px; width: 12px; height: 12px; border: 8px solid black; cursor: pointer;}#pcm-li { position: absolute; left: 523px; top: 0; height: 80px; width: 16px;}#pcm-li .pcm-lif { position: relative; width: 16px; height: 12px; margin-bottom: 3px;}#pcm-p.blk .pcm-e { visibility: hidden;}#pcm-c .pcm-ac { width: 16px; height: 16px; margin-left: -4px; margin-top: -4px; z-index: 110;}#pcm-c .pcm-n { z-index: 111;}#pcm-c #pcm-stck { z-index: 109;}#pcm-c #pcm-gbug { width: 32px;}#pcm-c #pcm-bpcm { width: 32px; height: 32px; margin-left: -20px; margin-top: -20px;}#pcm-f,#pcm-le div { width: 32px; height: 16px; z-index: 105;}#pcm-f { margin-left: -8px; margin-top: -4px;}#pcm-do { width: 19px; height: 2px; left: 279px; top: 46px; overflow: hidden; position: absolute; background: #ffaaa5;}#pcm-re { width: 48px; height: 8px; z-index: 120; left: 264px; top: 80px;}#pcm-go { width: 80px; height: 8px; z-index: 120; left: 248px; top: 80px;}";
2948 g.styleElement =
2949 document.createElement("style");
2950 g.styleElement.type = "text/css";
2951 if (g.styleElement.styleSheet) g.styleElement.styleSheet.cssText = b;
2952 else g.styleElement.appendChild(document.createTextNode(b));
2953 document.getElementsByTagName("head")[0].appendChild(g.styleElement)
2954 };
2955 g.createCanvasElement = function () {
2956 g.canvasEl = document.createElement("div");
2957 g.canvasEl.id = "pcm-c";
2958 g.canvasEl.hideFocus = a;
2959 document.getElementById("logo").appendChild(g.canvasEl);
2960 g.canvasEl.tabIndex = 0;
2961 g.canvasEl.focus()
2962 };
2963 g.everythingIsReady = function () {
2964 if (!g.ready) {
2965 g.ready = a;
2966 var b = document.getElementById("logo-l");
2967 google.dom.remove(b);
2968 document.getElementById("logo").style.background = "black";
2969 g.addCss();
2970 g.createCanvasElement();
2971 g.speedIntervals = [];
2972 g.oppositeDirections = [];
2973 g.oppositeDirections[1] = 2;
2974 g.oppositeDirections[2] = 1;
2975 g.oppositeDirections[4] = 8;
2976 g.oppositeDirections[8] = 4;
2977 g.addEventListeners();
2978 g.fpsChoice = 0;
2979 g.canDecreaseFps = a;
2980 g.initializeTickTimer();
2981 g.newGame()
2982 }
2983 };
2984 g.checkIfEverythingIsReady = function () {
2985 if (g.soundReady || g.graphicsReady) g.updateLoadingProgress(0.67);
2986 if (g.soundReady && g.graphicsReady) {
2987 g.updateLoadingProgress(1);
2988 g.everythingIsReady()
2989 }
2990 };
2991 g.preloadImage = function (b) {
2992 var c = new Image,
2993 d = google.browser.engine.IE;
2994 if (!d) c.onload = g.imageLoaded;
2995 c.src = b;
2996 d && g.imageLoaded()
2997 };
2998 g.imageLoaded = function () {
2999 g.graphicsReady = a;
3000 g.checkIfEverythingIsReady()
3001 };
3002 g.prepareGraphics = function () {
3003 g.graphicsReady = e;
3004 g.preloadImage("src/pacman10-hp-sprite.png")
3005 };
3006 g.trimString = function (b) {
3007 return b.replace(/^[\s\xa0]+|[\s\xa0]+$/g, "")
3008 };
3009 g.g = function (b, c) {
3010 if (b < c) return -1;
3011 else if (b > c) return 1;
3012 return 0
3013 };
3014 g.compareVersions = function (b, c) {
3015 for (var d = 0, f = g.trimString(String(b)).split("."), h = g.trimString(String(c)).split("."), j = Math.max(f.length, h.length), k = 0; d == 0 && k < j; k++) {
3016 var x = f[k] || "",
3017 F = h[k] || "",
3018 G = new RegExp("(\\d*)(\\D*)", "g"),
3019 H = new RegExp("(\\d*)(\\D*)", "g");
3020 do {
3021 var t = G.exec(x) || ["", "", ""],
3022 u = H.exec(F) || ["", "", ""];
3023 if (t[0].length == 0 && u[0].length == 0) break;
3024 d = t[1].length == 0 ? 0 : parseInt(t[1], 10);
3025 var I = u[1].length == 0 ? 0 : parseInt(u[1], 10);
3026 d = g.g(d, I) || g.g(t[2].length == 0, u[2].length == 0) || g.g(t[2], u[2])
3027 } while (d == 0)
3028 }
3029 return d
3030 };
3031 g.getFlashVersion = function (b) {
3032 b = b.match(/[\d]+/g);
3033 b.length = 3;
3034 return b.join(".")
3035 };
3036 g.detectFlash = function () {
3037 var b = e,
3038 c = "";
3039 if (navigator.plugins && navigator.plugins.length) {
3040 var d = navigator.plugins["Shockwave Flash"];
3041 if (d) {
3042 b = a;
3043 if (d.description) c = g.getFlashVersion(d.description)
3044 }
3045 if (navigator.plugins["Shockwave Flash 2.0"]) {
3046 b = a;
3047 c = "2.0.0.11"
3048 }
3049 } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
3050 if (b = (d = navigator.mimeTypes["application/x-shockwave-flash"]) && d.enabledPlugin) {
3051 c = d.enabledPlugin.description;
3052 c = g.getFlashVersion(c)
3053 }
3054 } else try {
3055 d = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
3056 b = a;
3057 c = g.getFlashVersion(d.GetVariable("$version"))
3058 } catch (f) {
3059 try {
3060 d = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
3061 b = a;
3062 c = "6.0.21"
3063 } catch (h) {
3064 try {
3065 d = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
3066 b = a;
3067 c = g.getFlashVersion(d.GetVariable("$version"))
3068 } catch (j) {}
3069 }
3070 }
3071 g.hasFlash = b;
3072 g.flashVersion = c
3073 };
3074 g.isFlashVersion = function (b) {
3075 return g.compareVersions(g.flashVersion, b) >= 0
3076 };
3077 g.prepareSound = function () {
3078 g.soundAvailable = e;
3079 g.soundEnabled = e;
3080 g.soundReady = e;
3081 g.detectFlash();
3082 if (!g.hasFlash || !g.isFlashVersion("9.0.0.0")) {
3083 g.soundReady = a;
3084 g.checkIfEverythingIsReady()
3085 } else {
3086 g.flashIframe = document.createElement("iframe");
3087 g.flashIframe.name = "pm-sound";
3088 g.flashIframe.style.position = "absolute";
3089 g.flashIframe.style.top = "-150px";
3090 g.flashIframe.style.border = 0;
3091 g.flashIframe.style.width = "100px";
3092 g.flashIframe.style.height = "100px";
3093 google.dom.append(g.flashIframe);
3094 g.flashIframeDoc = g.flashIframe.contentDocument;
3095 if (g.flashIframeDoc == undefined || g.flashIframeDoc == null) g.flashIframeDoc = g.flashIframe.contentWindow.document;
3096 g.flashIframeDoc.open();
3097 g.flashIframeDoc.write('<html><head></head><body><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="0" height="0" id="pacman-sound-player" type="application/x-shockwave-flash"> <param name="movie" value="src/swf/pacman10-hp-sound.swf"> <param name="allowScriptAccess" value="always"> <object id="pacman-sound-player-2" type="application/x-shockwave-flash" data="src/swf/pacman10-hp-sound.swf" width="0" height="0"><param name="allowScriptAccess" value="always"> </object></object></body></html>');
3098 g.flashIframeDoc.close();
3099 window.setTimeout(g.flashNotReady, 3E3)
3100 }
3101 };
3102 g.flashNotReady = function () {
3103 if (!g.ready) {
3104 g.soundAvailable = e;
3105 g.soundEnabled = e;
3106 g.soundReady = a;
3107 g.checkIfEverythingIsReady()
3108 }
3109 };
3110 g.flashReady = function (b) {
3111 g.flashSoundPlayer = b;
3112 g.soundAvailable = a;
3113 g.soundEnabled = a;
3114 g.soundReady = a;
3115 g.checkIfEverythingIsReady()
3116 };
3117 g.flashLoaded = function () {
3118 if (g.flashIframeDoc) {
3119 var b = g.flashIframeDoc.getElementById("pacman-sound-player");
3120 if (b && b.playTrack) {
3121 g.flashReady(b);
3122 return
3123 } else if ((b = g.flashIframeDoc.getElementById("pacman-sound-player-2")) && b.playTrack) {
3124 g.flashReady(b);
3125 return
3126 }
3127 }
3128 g.flashNotReady()
3129 };
3130 g.destroy = function () {
3131 if (google.pacman) {
3132 g.stopAllAudio();
3133 window.clearInterval(g.tickTimer);
3134 window.clearInterval(g.dotTimer);
3135 window.clearInterval(g.dotTimerMs);
3136 google.dom.remove(g.styleElement);
3137 google.dom.remove(g.flashIframe);
3138 google.dom.remove(g.canvasEl);
3139 google.pacman = undefined
3140 }
3141 };
3142 g.exportFunctionCalls = function () {
3143 google.pacman = {};
3144 google.pacman.insertCoin = g.insertCoin;
3145 google.pacman.flashLoaded = g.flashLoaded;
3146 google.pacman.destroy = g.destroy
3147 };
3148 g.updateLoadingProgress = function (b) {
3149 b = Math.round(b * 200);
3150 document.getElementById("logo-b").style.width = b + "px"
3151 };
3152 g.init = function () {
3153 g.ready = e;
3154 document.getElementById("logo").title = "";
3155 g.updateLoadingProgress(0.33);
3156 g.exportFunctionCalls();
3157 g.useCss = navigator.userAgent.indexOf("MSIE 5.") != -1 || navigator.userAgent.indexOf("MSIE 6.") != -1 || navigator.userAgent.indexOf("MSIE 7.") != -1 ? e : a;
3158 g.prepareGraphics();
3159 g.prepareSound()
3160 };
3161 g.init();
3162}(); \ No newline at end of file