Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

re-adding gh-pages

  • Loading branch information...
commit 21a67e3c29d47fe51bde7c967c1f3b4a135c62c5 0 parents
@macek authored
64 README
@@ -0,0 +1,64 @@
+Google Pacman
+-------------
+
+This is a copy of Google's playable Pacman game logo hosted for
+Pacman's 30th Anniversary.
+
+With the help of StackOverflow users, we were able to get a playable
+version working 100%.
+
+To play a live version: http://macek.github.com/google_pacman/
+
+Or download the source and run it offline.
+
+
+
+
+
+Sound in Offline Mode
+---------------------
+
+A snippet from Adobe.com
+
+> For example, a trusted local HTML file may permit an untrusted local SWF to script it by setting allowScriptAccess="always". However, an untrusted local HTML file may never permit an untrusted local SWF to script it, regardless of the value of allowScriptAccess.
+
+To have flash trust your local SWF, you must add your google_pacman
+folder to the allow list using your Flash Control Panel.
+
+1. Adobe Flash Control Panel:
+ http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
+
+2. Click `Edit Locations`
+
+3. Click `Add Location`
+
+4. Browse to your `google_pacman` directory
+
+5. Click `Confirm`
+
+Read more about this issue here:
+http://www.adobe.com/devnet/flash/articles/fplayer8_security_09.html
+
+
+
+
+
+Thanks to:
+----------
+SteD for providing a nicely formatted version of pacman10-hp.2.js
+
+Skizo for noticing that relative paths don't work as expected when
+executed locally
+
+Skizo for fixing issue: "Ghosts stay blue permanently on restart"
+
+Mason Barry for cleaning up the homepage, adding a nice starting graphic,
+and fixing the `Insert Coin` button
+
+winwakr for showing us how to get sound working in offline mode.
+
+KevinCathcart for recommending we setup a live version on the `gh-pages` branch
+
+KevinCathcart and Barry Silverman for removing a good amount of unnecessary HTML/JavaScript
+
+KevinCathcart and Barry Silverman for getting the famous intro song working
115 index.html
@@ -0,0 +1,115 @@
+<!doctype html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>Google Pacman</title>
+ <script>
+ window.google = {}
+ </script>
+ <style>
+ body{background:#222;font-family:monospace;margin-top:50px}
+ td{line-height:.8em;}
+ form{margin-bottom:20px;}
+ input{font-family:inherit;-moz-box-sizing:content-box}
+ a{color:#11c;text-decoration:none}
+ a:hover,a:active{text-decoration:underline}
+ a:visited{color:#551a8b}
+ #logo{width:554px;height:186px;background:black url(src/pacman10-hp.gif) 0 0 no-repeat;position:relative;margin-bottom:9px}
+ #logo-l{width:200px;height:2px;left:177px;top:157px;background:#990;position:absolute;display:none;overflow:hidden}
+ #logo-b{position:absolute;left:0;background:#ff0;height:8px;width:0}
+ #wrapper{width:554px;height:186px;padding:10px;background:#000;-webkit-border-radius:8px;}
+ .lsb:active{background:-webkit-gradient(linear,left top,left bottom,from(#ccc),to(#ddd))}
+ .ds{display:-moz-inline-box}
+ .ds{border-bottom:solid 1px #e7e7e7;border-right:solid 1px #e7e7e7;display:inline-block;margin:3px 0 4px;margin-left:4px;margin-right:3px:height:32px}
+ .lsbb{background:#eee;border:solid 1px;border-color:#ccc #999 #999 #ccc;height:30px;display:block}
+ .lsb{background:url(/images/srpr/nav_logo13.png) bottom;font:15px arial,sans-serif;border:none;cursor:pointer;height:30px;margin:0;outline:0;vertical-align:top}
+ .lsb:active{background:#ccc}
+ #footer ul{list-style-type:none;padding:0}
+ #footer a{display:inline-block;color:#444;font-size:10pt;font-family:monospace;padding:5px}
+ #footer a:hover{color:#666;text-decoration:none;background:#333}
+
+ </style>
+</head>
+<body>
+ <center>
+ <div id="wrapper">
+ <a href="#gameover" id="dlink"></a>
+ <div id='logo' title="PAC-MAN's 30th Birthday! Doodle with PAC-MAN™ & ©1980 NAMCO BANDAI Games Inc.">
+ <div id="logo-l">
+ <div id="logo-b">
+ </div>
+ </div>
+ </div>
+ </div>
+ <script>
+ google.dom = {};
+ google.pacManSound = true;
+ google.browser = {};
+ google.browser.engine = {}
+
+ google.dom.remove = function (a) {
+ return a && a.parentNode && a.parentNode.removeChild(a)
+ };
+
+ google.dom.append = function (a) {
+ return document.body.appendChild(a)
+ };
+
+ google.browser.engine.IE = false
+ google.pml = function () {
+ function d(a) {
+ if (!google.pml_installed) {
+ google.pml_installed = true;
+ if (!a) {
+ document.getElementById("logo").style.background = "black";
+ window.setTimeout(function () {
+ var b = document.getElementById("logo-l");
+ if (b) b.style.display = "block"
+ }, 400)
+ }
+ a = document.createElement("script");
+ a.type = "text/javascript";
+ a.src = "src/js/pacman10-hp.3.js";
+ document.body.appendChild(a)
+ }
+ }
+ function e() {
+ if (document.f && document.f.btnI) document.f.btnI.onclick = function () {
+ typeof google.pacman != "undefined" ? google.pacman.insertCoin() : d(false);
+ return false
+ }
+ }
+ if (!google.pml_loaded) {
+ google.pml_loaded = true;
+ window.setTimeout(function () {
+ document.f && d(true)
+ }, 1E4);
+ e();
+ }
+ };
+ </script>
+
+ <form action="#submit" name='f'>
+ <table width="23%" cellpadding='0' cellspacing='0'>
+ <tr valign='top'>
+ <td align='center' nowrap><br style="line-height:0">
+ <span class='ds'>
+ <span class='lsbb'>
+ <input name='btnI' type='submit' value="Insert Coin" class='lsb'>
+ </span>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <div id="footer">
+ <ul>
+ <li><a href="http://github.com/macek/google_pacman">GitHub macek/google_pacman</a></li>
+ <li><a href="http://google.com">&copy; 2010, Google</a></li>
+ <li><a href="http://pacman.com">&copy; 1980, NAMCO BANDAI Games Inc.</a></li>
+ </ul>
+ </div>
+ <script>google.pml && google.pml()</script>
+ </center>
+</html>
3,162 src/js/pacman10-hp.2.js
@@ -0,0 +1,3162 @@
+google.pacman ||
+function () {
+ var a = true,
+ e = false,
+ g = {},
+ i = [1, 4, 2, 8],
+ l = {
+ 0: {
+ axis: 0,
+ increment: 0
+ },
+ 1: {
+ axis: 0,
+ increment: -1
+ },
+ 2: {
+ axis: 0,
+ increment: +1
+ },
+ 4: {
+ axis: 1,
+ increment: -1
+ },
+ 8: {
+ axis: 1,
+ increment: +1
+ }
+ },
+ m = [0, 7, 17, 32],
+ n = [{
+ x: 5,
+ y: 1,
+ w: 56
+ },
+ {
+ x: 5,
+ y: 4,
+ w: 5
+ },
+ {
+ x: 5,
+ y: 1,
+ h: 4
+ },
+ {
+ x: 9,
+ y: 1,
+ h: 12
+ },
+ {
+ x: 5,
+ y: 12,
+ h: 4
+ },
+ {
+ x: 10,
+ y: 12,
+ h: 4
+ },
+ {
+ x: 5,
+ y: 15,
+ w: 16
+ },
+ {
+ x: 5,
+ y: 12,
+ w: 31
+ },
+ {
+ x: 60,
+ y: 1,
+ h: 4
+ },
+ {
+ x: 54,
+ y: 1,
+ h: 4
+ },
+ {
+ x: 19,
+ y: 1,
+ h: 12
+ },
+ {
+ x: 19,
+ y: 4,
+ w: 26
+ },
+ {
+ x: 13,
+ y: 5,
+ w: 7
+ },
+ {
+ x: 13,
+ y: 5,
+ h: 4
+ },
+ {
+ x: 13,
+ y: 8,
+ w: 3
+ },
+ {
+ x: 56,
+ y: 4,
+ h: 9
+ },
+ {
+ x: 48,
+ y: 4,
+ w: 13
+ },
+ {
+ x: 48,
+ y: 1,
+ h: 12
+ },
+ {
+ x: 60,
+ y: 12,
+ h: 4
+ },
+ {
+ x: 44,
+ y: 15,
+ w: 17
+ },
+ {
+ x: 54,
+ y: 12,
+ h: 4
+ },
+ {
+ x: 44,
+ y: 12,
+ w: 17
+ },
+ {
+ x: 44,
+ y: 1,
+ h: 15
+ },
+ {
+ x: 41,
+ y: 13,
+ w: 4
+ },
+ {
+ x: 41,
+ y: 13,
+ h: 3
+ },
+ {
+ x: 38,
+ y: 13,
+ h: 3
+ },
+ {
+ x: 38,
+ y: 15,
+ w: 4
+ },
+ {
+ x: 35,
+ y: 10,
+ w: 10
+ },
+ {
+ x: 35,
+ y: 1,
+ h: 15
+ },
+ {
+ x: 35,
+ y: 13,
+ w: 4
+ },
+ {
+ x: 21,
+ y: 12,
+ h: 4
+ },
+ {
+ x: 24,
+ y: 12,
+ h: 4
+ },
+ {
+ x: 24,
+ y: 15,
+ w: 12
+ },
+ {
+ x: 27,
+ y: 4,
+ h: 9
+ },
+ {
+ x: 52,
+ y: 9,
+ w: 5
+ },
+ {
+ x: 56,
+ y: 8,
+ w: 10,
+ type: 1
+ },
+ {
+ x: 1,
+ y: 8,
+ w: 9,
+ type: 1
+ }],
+ o = [{
+ x: 1,
+ y: 8,
+ w: 8
+ },
+ {
+ x: 57,
+ y: 8,
+ w: 9
+ },
+ {
+ x: 44,
+ y: 2,
+ h: 10
+ },
+ {
+ x: 35,
+ y: 5,
+ h: 7
+ },
+ {
+ x: 36,
+ y: 4,
+ w: 8
+ },
+ {
+ x: 36,
+ y: 10,
+ w: 8
+ },
+ {
+ x: 39,
+ y: 15,
+ w: 2
+ }],
+ p = [{
+ x: 5,
+ y: 15
+ },
+ {
+ x: 5,
+ y: 3
+ },
+ {
+ x: 15,
+ y: 8
+ },
+ {
+ x: 60,
+ y: 3
+ },
+ {
+ x: 60,
+ y: 15
+ }],
+ q = [{
+ x: 2,
+ y: 8
+ },
+ {
+ x: 63,
+ y: 8
+ }],
+ r = {
+ 1: [{
+ x: 39.5,
+ y: 15,
+ dir: 4
+ },
+ {
+ x: 39.5,
+ y: 4,
+ dir: 4,
+ scatterX: 57,
+ scatterY: -4
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 2,
+ scatterX: 0,
+ scatterY: -4
+ },
+ {
+ x: 37.625,
+ y: 7,
+ dir: 1,
+ scatterX: 57,
+ scatterY: 20
+ },
+ {
+ x: 41.375,
+ y: 7,
+ dir: 1,
+ scatterX: 0,
+ scatterY: 20
+ }],
+ 2: [{
+ x: 40.25,
+ y: 15,
+ dir: 8
+ },
+ {
+ x: 38.75,
+ y: 15,
+ dir: 4
+ },
+ {
+ x: 39.5,
+ y: 4,
+ dir: 4,
+ scatterX: 57,
+ scatterY: -4
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 2,
+ scatterX: 0,
+ scatterY: -4
+ },
+ {
+ x: 37.625,
+ y: 7,
+ dir: 1,
+ scatterX: 57,
+ scatterY: 20
+ },
+ {
+ x: 41.375,
+ y: 7,
+ dir: 1,
+ scatterX: 0,
+ scatterY: 20
+ }]
+ },
+ s = [32, 312],
+ v = [80, 312],
+ w = {
+ 0: 0.16,
+ 1: 0.23,
+ 2: 1,
+ 3: 1,
+ 4: 2.23,
+ 5: 0.3,
+ 6: 1.9,
+ 7: 2.23,
+ 8: 1.9,
+ 9: 5,
+ 10: 1.9,
+ 11: 1.18,
+ 12: 0.3,
+ 13: 0.5,
+ 14: 1.9,
+ 15: 9,
+ 16: 10,
+ 17: 0.26
+ },
+ y = 0.8 * 0.4,
+ z = [{},
+ {
+ ghostSpeed: 0.75,
+ ghostTunnelSpeed: 0.4,
+ playerSpeed: 0.8,
+ dotEatingSpeed: 0.71,
+ ghostFrightSpeed: 0.5,
+ playerFrightSpeed: 0.9,
+ dotEatingFrightSpeed: 0.79,
+ elroyDotsLeftPart1: 20,
+ elroySpeedPart1: 0.8,
+ elroyDotsLeftPart2: 10,
+ elroySpeedPart2: 0.85,
+ frightTime: 6,
+ frightBlinkCount: 5,
+ fruit: 1,
+ fruitScore: 100,
+ ghostModeSwitchTimes: [7, 20, 7, 20, 5, 20, 5, 1],
+ penForceTime: 4,
+ penLeavingLimits: [0, 0, 30, 60]
+ },
+ {
+ ghostSpeed: 0.85,
+ ghostTunnelSpeed: 0.45,
+ playerSpeed: 0.9,
+ dotEatingSpeed: 0.79,
+ ghostFrightSpeed: 0.55,
+ playerFrightSpeed: 0.95,
+ dotEatingFrightSpeed: 0.83,
+ elroyDotsLeftPart1: 30,
+ elroySpeedPart1: 0.9,
+ elroyDotsLeftPart2: 15,
+ elroySpeedPart2: 0.95,
+ frightTime: 5,
+ frightBlinkCount: 5,
+ fruit: 2,
+ fruitScore: 300,
+ ghostModeSwitchTimes: [7, 20, 7, 20, 5, 1033, 1 / 60, 1],
+ penForceTime: 4,
+ penLeavingLimits: [0, 0, 0, 50],
+ cutsceneId: 1
+ },
+ {
+ ghostSpeed: 0.85,
+ ghostTunnelSpeed: 0.45,
+ playerSpeed: 0.9,
+ dotEatingSpeed: 0.79,
+ ghostFrightSpeed: 0.55,
+ playerFrightSpeed: 0.95,
+ dotEatingFrightSpeed: 0.83,
+ elroyDotsLeftPart1: 40,
+ elroySpeedPart1: 0.9,
+ elroyDotsLeftPart2: 20,
+ elroySpeedPart2: 0.95,
+ frightTime: 4,
+ frightBlinkCount: 5,
+ fruit: 3,
+ fruitScore: 500,
+ ghostModeSwitchTimes: [7, 20, 7, 20, 5, 1033, 1 / 60, 1],
+ penForceTime: 4,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.85,
+ ghostTunnelSpeed: 0.45,
+ playerSpeed: 0.9,
+ dotEatingSpeed: 0.79,
+ ghostFrightSpeed: 0.55,
+ playerFrightSpeed: 0.95,
+ dotEatingFrightSpeed: 0.83,
+ elroyDotsLeftPart1: 40,
+ elroySpeedPart1: 0.9,
+ elroyDotsLeftPart2: 20,
+ elroySpeedPart2: 0.95,
+ frightTime: 3,
+ frightBlinkCount: 5,
+ fruit: 3,
+ fruitScore: 500,
+ ghostModeSwitchTimes: [7, 20, 7, 20, 5, 1033, 1 / 60, 1],
+ penForceTime: 4,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 40,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 20,
+ elroySpeedPart2: 1.05,
+ frightTime: 2,
+ frightBlinkCount: 5,
+ fruit: 4,
+ fruitScore: 700,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0],
+ cutsceneId: 2
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 50,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 25,
+ elroySpeedPart2: 1.05,
+ frightTime: 5,
+ frightBlinkCount: 5,
+ fruit: 4,
+ fruitScore: 700,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 50,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 25,
+ elroySpeedPart2: 1.05,
+ frightTime: 2,
+ frightBlinkCount: 5,
+ fruit: 5,
+ fruitScore: 1E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 50,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 25,
+ elroySpeedPart2: 1.05,
+ frightTime: 2,
+ frightBlinkCount: 5,
+ fruit: 5,
+ fruitScore: 1E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 60,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 30,
+ elroySpeedPart2: 1.05,
+ frightTime: 1,
+ frightBlinkCount: 3,
+ fruit: 6,
+ fruitScore: 2E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0],
+ cutsceneId: 3
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 60,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 30,
+ elroySpeedPart2: 1.05,
+ frightTime: 5,
+ frightBlinkCount: 5,
+ fruit: 6,
+ fruitScore: 2E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 60,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 30,
+ elroySpeedPart2: 1.05,
+ frightTime: 2,
+ frightBlinkCount: 5,
+ fruit: 7,
+ fruitScore: 3E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 80,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 40,
+ elroySpeedPart2: 1.05,
+ frightTime: 1,
+ frightBlinkCount: 3,
+ fruit: 7,
+ fruitScore: 3E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 80,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 40,
+ elroySpeedPart2: 1.05,
+ frightTime: 1,
+ frightBlinkCount: 3,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0],
+ cutsceneId: 3
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 80,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 40,
+ elroySpeedPart2: 1.05,
+ frightTime: 3,
+ frightBlinkCount: 5,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 100,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 50,
+ elroySpeedPart2: 1.05,
+ frightTime: 1,
+ frightBlinkCount: 3,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 100,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 50,
+ elroySpeedPart2: 1.05,
+ frightTime: 1,
+ frightBlinkCount: 3,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 100,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 50,
+ elroySpeedPart2: 1.05,
+ frightTime: 0,
+ frightBlinkCount: 0,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0],
+ cutsceneId: 3
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 100,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 50,
+ elroySpeedPart2: 1.05,
+ frightTime: 1,
+ frightBlinkCount: 3,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 120,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 60,
+ elroySpeedPart2: 1.05,
+ frightTime: 0,
+ frightBlinkCount: 0,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 1,
+ dotEatingSpeed: 0.87,
+ ghostFrightSpeed: 0.6,
+ playerFrightSpeed: 1,
+ dotEatingFrightSpeed: 0.87,
+ elroyDotsLeftPart1: 120,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 60,
+ elroySpeedPart2: 1.05,
+ frightTime: 0,
+ frightBlinkCount: 0,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ },
+ {
+ ghostSpeed: 0.95,
+ ghostTunnelSpeed: 0.5,
+ playerSpeed: 0.9,
+ dotEatingSpeed: 0.79,
+ ghostFrightSpeed: 0.75,
+ playerFrightSpeed: 0.9,
+ dotEatingFrightSpeed: 0.79,
+ elroyDotsLeftPart1: 120,
+ elroySpeedPart1: 1,
+ elroyDotsLeftPart2: 60,
+ elroySpeedPart2: 1.05,
+ frightTime: 0,
+ frightBlinkCount: 0,
+ fruit: 8,
+ fruitScore: 5E3,
+ ghostModeSwitchTimes: [5, 20, 5, 20, 5, 1037, 1 / 60, 1],
+ penForceTime: 3,
+ penLeavingLimits: [0, 0, 0, 0]
+ }],
+ A = {
+ 1: [{
+ x: 37.6,
+ y: 7,
+ dir: 1,
+ dest: 6.375,
+ speed: 0.48
+ },
+ {
+ x: 37.6,
+ y: 6.375,
+ dir: 2,
+ dest: 7.625,
+ speed: 0.48
+ },
+ {
+ x: 37.6,
+ y: 7.625,
+ dir: 1,
+ dest: 7,
+ speed: 0.48
+ }],
+ 2: [{
+ x: 39.5,
+ y: 7,
+ dir: 2,
+ dest: 7.625,
+ speed: 0.48
+ },
+ {
+ x: 39.5,
+ y: 7.625,
+ dir: 1,
+ dest: 6.375,
+ speed: 0.48
+ },
+ {
+ x: 39.5,
+ y: 6.375,
+ dir: 2,
+ dest: 7,
+ speed: 0.48
+ }],
+ 3: [{
+ x: 41.4,
+ y: 7,
+ dir: 1,
+ dest: 6.375,
+ speed: 0.48
+ },
+ {
+ x: 41.4,
+ y: 6.375,
+ dir: 2,
+ dest: 7.625,
+ speed: 0.48
+ },
+ {
+ x: 41.4,
+ y: 7.625,
+ dir: 1,
+ dest: 7,
+ speed: 0.48
+ }],
+ 4: [{
+ x: 37.6,
+ y: 7,
+ dir: 8,
+ dest: 39.5,
+ speed: y
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 1,
+ dest: 4,
+ speed: y
+ }],
+ 5: [{
+ x: 39.5,
+ y: 7,
+ dir: 1,
+ dest: 4,
+ speed: y
+ }],
+ 6: [{
+ x: 41.4,
+ y: 7,
+ dir: 4,
+ dest: 39.5,
+ speed: y
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 1,
+ dest: 4,
+ speed: y
+ }],
+ 7: [{
+ x: 39.5,
+ y: 4,
+ dir: 2,
+ dest: 7,
+ speed: 1.6
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 4,
+ dest: 37.625,
+ speed: 1.6
+ }],
+ 8: [{
+ x: 39.5,
+ y: 4,
+ dir: 2,
+ dest: 7,
+ speed: 1.6
+ }],
+ 9: [{
+ x: 39.5,
+ y: 4,
+ dir: 2,
+ dest: 7,
+ speed: 1.6
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 8,
+ dest: 41.375,
+ speed: 1.6
+ }],
+ 10: [{
+ x: 37.6,
+ y: 7,
+ dir: 8,
+ dest: 39.5,
+ speed: y
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 1,
+ dest: 4,
+ speed: y
+ }],
+ 11: [{
+ x: 39.5,
+ y: 7,
+ dir: 1,
+ dest: 4,
+ speed: y
+ }],
+ 12: [{
+ x: 41.4,
+ y: 7,
+ dir: 4,
+ dest: 39.5,
+ speed: y
+ },
+ {
+ x: 39.5,
+ y: 7,
+ dir: 1,
+ dest: 4,
+ speed: y
+ }]
+ },
+ B = {
+ 1: {
+ actors: [{
+ ghost: e,
+ x: 64,
+ y: 9,
+ id: 0
+ },
+ {
+ ghost: a,
+ x: 68.2,
+ y: 9,
+ id: 1
+ }],
+ sequence: [{
+ time: 5.5,
+ moves: [{
+ dir: 4,
+ speed: 0.75 * 0.8 * 2
+ },
+ {
+ dir: 4,
+ speed: 0.78 * 0.8 * 2
+ }]
+ },
+ {
+ time: 0.1,
+ moves: [{
+ dir: 4,
+ speed: 32
+ },
+ {
+ dir: 4,
+ speed: 0
+ }]
+ },
+ {
+ time: 9,
+ moves: [{
+ dir: 8,
+ speed: 0.75 * 0.8 * 2,
+ elId: "pcm-bpcm"
+ },
+ {
+ dir: 8,
+ speed: 0.8,
+ mode: 4
+ }]
+ }]
+ },
+ 2: {
+ actors: [{
+ ghost: e,
+ x: 64,
+ y: 9,
+ id: 0
+ },
+ {
+ ghost: a,
+ x: 70.2,
+ y: 9,
+ id: 1
+ },
+ {
+ ghost: a,
+ x: 32,
+ y: 9.5,
+ id: 2
+ }],
+ sequence: [{
+ time: 2.7,
+ moves: [{
+ dir: 4,
+ speed: 0.75 * 0.8 * 2
+ },
+ {
+ dir: 4,
+ speed: 0.78 * 0.8 * 2
+ },
+ {
+ dir: 0,
+ speed: 0,
+ elId: "pcm-stck"
+ }]
+ },
+ {
+ time: 1,
+ moves: [{
+ dir: 4,
+ speed: 0.75 * 0.8 * 2
+ },
+ {
+ dir: 4,
+ speed: 0.1 * 0.8
+ },
+ {
+ dir: 0,
+ speed: 0,
+ elId: "pcm-stck"
+ }]
+ },
+ {
+ time: 1.3,
+ moves: [{
+ dir: 4,
+ speed: 0.75 * 0.8 * 2
+ },
+ {
+ dir: 4,
+ speed: 0
+ },
+ {
+ dir: 0,
+ speed: 0,
+ elId: "pcm-stck"
+ }]
+ },
+ {
+ time: 1,
+ moves: [{
+ dir: 4,
+ speed: 0.75 * 0.8 * 2
+ },
+ {
+ dir: 4,
+ speed: 0,
+ elId: "pcm-ghfa"
+ },
+ {
+ dir: 0,
+ speed: 0,
+ elId: "pcm-stck"
+ }]
+ },
+ {
+ time: 2.5,
+ moves: [{
+ dir: 4,
+ speed: 0.75 * 0.8 * 2
+ },
+ {
+ dir: 4,
+ speed: 0,
+ elId: "pcm-ghfa"
+ },
+ {
+ dir: 0,
+ speed: 0,
+ elId: "pcm-stck"
+ }]
+ }]
+ },
+ 3: {
+ actors: [{
+ ghost: e,
+ x: 64,
+ y: 9,
+ id: 0
+ },
+ {
+ ghost: a,
+ x: 70.2,
+ y: 9,
+ id: 2
+ }],
+ sequence: [{
+ time: 5.3,
+ moves: [{
+ dir: 4,
+ speed: 0.75 * 0.8 * 2
+ },
+ {
+ dir: 4,
+ speed: 0.78 * 0.8 * 2,
+ elId: "pcm-ghin"
+ }]
+ },
+ {
+ time: 5.3,
+ moves: [{
+ dir: 4,
+ speed: 0
+ },
+ {
+ dir: 8,
+ speed: 0.78 * 0.8 * 2,
+ elId: "pcm-gbug"
+ }]
+ }]
+ }
+ },
+ C = [90, 45, 30],
+ D = C[0];
+
+ function E(b) {
+ this.id = b
+ }
+ E.prototype.A = function () {
+ var b = r[g.playerCount][this.id];
+ this.pos = [b.y * 8, b.x * 8];
+ this.posDelta = [0, 0];
+ this.tilePos = [b.y * 8, b.x * 8];
+ this.targetPos = [b.scatterY * 8, b.scatterX * 8];
+ this.scatterPos = [b.scatterY * 8, b.scatterX * 8];
+ this.lastActiveDir = this.dir = b.dir;
+ this.physicalSpeed = this.requestedDir = this.nextDir = 0;
+ this.c(0);
+ this.reverseDirectionsNext = this.freeToLeavePen = this.modeChangedWhileInPen = this.eatenInThisFrightMode = e;
+ this.l()
+ };
+ E.prototype.createElement = function () {
+ this.el = document.createElement("div");
+ this.el.className = "pcm-ac";
+ this.el.id = "actor" + this.id;
+ g.prepareElement(this.el, 0, 0);
+ g.playfieldEl.appendChild(this.el);
+ this.elPos = [0, 0];
+ this.elBackgroundPos = [0, 0]
+ };
+ E.prototype.a = function (b) {
+ var c = this.mode;
+ this.mode = b;
+ if (this.id == g.playerCount + 3 && (b == 16 || c == 16)) g.updateCruiseElroySpeed();
+ switch (c) {
+ case 32:
+ g.ghostExitingPenNow = e;
+ break;
+ case 8:
+ g.ghostEyesCount > 0 && g.ghostEyesCount--;
+ g.ghostEyesCount == 0 && g.playAmbientSound();
+ break
+ }
+ switch (b) {
+ case 4:
+ this.fullSpeed = g.levels.ghostFrightSpeed * 0.8;
+ this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
+ this.followingRoutine = e;
+ break;
+ case 1:
+ this.fullSpeed = g.levels.ghostSpeed * 0.8;
+ this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
+ this.followingRoutine =
+ e;
+ break;
+ case 2:
+ this.targetPos = this.scatterPos;
+ this.fullSpeed = g.levels.ghostSpeed * 0.8;
+ this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
+ this.followingRoutine = e;
+ break;
+ case 8:
+ this.tunnelSpeed = this.fullSpeed = 1.6;
+ this.targetPos = [s[0], s[1]];
+ this.freeToLeavePen = this.followingRoutine = e;
+ break;
+ case 16:
+ this.l();
+ this.followingRoutine = a;
+ this.routineMoveId = -1;
+ switch (this.id) {
+ case g.playerCount + 1:
+ this.routineToFollow = 2;
+ break;
+ case g.playerCount + 2:
+ this.routineToFollow = 1;
+ break;
+ case g.playerCount + 3:
+ this.routineToFollow =
+ 3;
+ break
+ }
+ break;
+ case 32:
+ this.followingRoutine = a;
+ this.routineMoveId = -1;
+ switch (this.id) {
+ case g.playerCount + 1:
+ this.routineToFollow = 5;
+ break;
+ case g.playerCount + 2:
+ this.routineToFollow = 4;
+ break;
+ case g.playerCount + 3:
+ this.routineToFollow = 6;
+ break
+ }
+ g.ghostExitingPenNow = a;
+ break;
+ case 64:
+ this.followingRoutine = a;
+ this.routineMoveId = -1;
+ switch (this.id) {
+ case g.playerCount:
+ case g.playerCount + 1:
+ this.routineToFollow = 8;
+ break;
+ case g.playerCount + 2:
+ this.routineToFollow = 7;
+ break;
+ case g.playerCount + 3:
+ this.routineToFollow = 9;
+ break
+ }
+ break;
+ case 128:
+ this.followingRoutine = a;
+ this.routineMoveId = -1;
+ switch (this.id) {
+ case g.playerCount:
+ case g.playerCount + 1:
+ this.routineToFollow = 11;
+ break;
+ case g.playerCount + 2:
+ this.routineToFollow = 10;
+ break;
+ case g.playerCount + 3:
+ this.routineToFollow = 12;
+ break
+ }
+ break
+ }
+ this.d()
+ };
+ E.prototype.l = function () {
+ if (this.id >= g.playerCount) this.targetPlayerId = Math.floor(g.rand() * g.playerCount)
+ };
+ E.prototype.z = function (b) {
+ if (this.dir == g.oppositeDirections[b]) {
+ this.dir = b;
+ this.posDelta = [0, 0];
+ this.currentSpeed != 2 && this.c(0);
+ if (this.dir != 0) this.lastActiveDir = this.dir;
+ this.nextDir = 0
+ } else if (this.dir != b) if (this.dir == 0) {
+ if (g.playfield[this.pos[0]][this.pos[1]].allowedDir & b) this.dir = b
+ } else {
+ var c = g.playfield[this.tilePos[0]][this.tilePos[1]];
+ if (c && c.allowedDir & b) {
+ c = l[this.dir];
+ var d = [this.pos[0], this.pos[1]];
+ d[c.axis] -= c.increment;
+ var f = 0;
+ if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) f = 1;
+ else {
+ d[c.axis] -= c.increment;
+ if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) f = 2
+ }
+ if (f) {
+ this.dir = b;
+ this.pos[0] = this.tilePos[0];
+ this.pos[1] = this.tilePos[1];
+ c = l[this.dir];
+ this.pos[c.axis] += c.increment * f;
+ return
+ }
+ }
+ this.nextDir = b;
+ this.posDelta = [0, 0]
+ }
+ };
+ E.prototype.i = function (b) {
+ var c = this.tilePos,
+ d = l[this.dir],
+ f = [c[0], c[1]];
+ f[d.axis] += d.increment * 8;
+ var h = g.playfield[f[0]][f[1]];
+ if (b && !h.intersection) h = g.playfield[c[0]][c[1]];
+ if (h.intersection) switch (this.mode) {
+ case 2:
+ case 1:
+ case 8:
+ if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) this.nextDir = g.oppositeDirections[this.dir];
+ else {
+ b = 99999999999;
+ c = 0;
+ for (var j in i) {
+ var k = i[j];
+ if (h.allowedDir & k && this.dir != g.oppositeDirections[k]) {
+ d = l[k];
+ var x = [f[0], f[1]];
+ x[d.axis] += d.increment;
+ d = g.getDistance(x, [this.targetPos[0], this.targetPos[1]]);
+ if (d < b) {
+ b = d;
+ c = k
+ }
+ }
+ }
+ if (c) this.nextDir = c
+ }
+ break;
+ case 4:
+ if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) this.nextDir = g.oppositeDirections[this.dir];
+ else {
+ do f = i[Math.floor(g.rand() * 4)];
+ while ((f & h.allowedDir) == 0 || f == g.oppositeDirections[this.dir]);
+ this.nextDir = f
+ }
+ break
+ }
+ };
+ E.prototype.p = function (b) {
+ g.tilesChanged = a;
+ if (this.reverseDirectionsNext) {
+ this.dir = g.oppositeDirections[this.dir];
+ this.nextDir = 0;
+ this.reverseDirectionsNext = e;
+ this.i(a)
+ }
+ if (!this.ghost && !g.playfield[b[0]][b[1]].path) {
+ this.pos[0] = this.lastGoodTilePos[0];
+ this.pos[1] = this.lastGoodTilePos[1];
+ b[0] = this.lastGoodTilePos[0];
+ b[1] = this.lastGoodTilePos[1];
+ this.dir = 0
+ } else this.lastGoodTilePos = [b[0], b[1]];
+ g.playfield[b[0]][b[1]].type == 1 && this.mode != 8 ? this.c(2) : this.c(0);
+ !this.ghost && g.playfield[b[0]][b[1]].dot && g.dotEaten(this.id, b);
+ this.tilePos[0] = b[0];
+ this.tilePos[1] = b[1]
+ };
+ E.prototype.t = function () {
+ var b = this.tilePos;
+ switch (this.dir) {
+ case 1:
+ var c = [b[0], b[1]],
+ d = [b[0] + 3.6, b[1]];
+ break;
+ case 2:
+ c = [b[0] - 4, b[1]];
+ d = [b[0], b[1]];
+ break;
+ case 4:
+ c = [b[0], b[1]];
+ d = [b[0], b[1] + 3.6];
+ break;
+ case 8:
+ c = [b[0], b[1] - 4];
+ d = [b[0], b[1]];
+ break
+ }
+ if (this.pos[0] >= c[0] && this.pos[0] <= d[0] && this.pos[1] >= c[1] && this.pos[1] <= d[1]) {
+ b = l[this.nextDir];
+ this.posDelta[b.axis] += b.increment
+ }
+ };
+ E.prototype.n = function () {
+ if (this.pos[0] == q[0].y * 8 && this.pos[1] == q[0].x * 8) {
+ this.pos[0] = q[1].y * 8;
+ this.pos[1] = (q[1].x - 1) * 8
+ } else if (this.pos[0] == q[1].y * 8 && this.pos[1] == q[1].x * 8) {
+ this.pos[0] = q[0].y * 8;
+ this.pos[1] = (q[0].x + 1) * 8
+ }
+ this.mode == 8 && this.pos[0] == s[0] && this.pos[1] == s[1] && this.a(64);
+ if (!this.ghost && this.pos[0] == v[0] && (this.pos[1] == v[1] || this.pos[1] == v[1] + 8)) g.eatFruit(this.id)
+ };
+ E.prototype.u = function () {
+ this.n();
+ this.ghost && this.i(e);
+ var b = g.playfield[this.pos[0]][this.pos[1]];
+ if (b.intersection) if (this.nextDir && this.nextDir & b.allowedDir) {
+ if (this.dir != 0) this.lastActiveDir = this.dir;
+ this.dir = this.nextDir;
+ this.nextDir = 0;
+ if (!this.ghost) {
+ this.pos[0] += this.posDelta[0];
+ this.pos[1] += this.posDelta[1];
+ this.posDelta = [0, 0]
+ }
+ } else if ((this.dir & b.allowedDir) == 0) {
+ if (this.dir != 0) this.lastActiveDir = this.dir;
+ this.nextDir = this.dir = 0;
+ this.c(0)
+ }
+ };
+ E.prototype.o = function () {
+ var b = this.pos[0] / 8,
+ c = this.pos[1] / 8,
+ d = [Math.round(b) * 8, Math.round(c) * 8];
+ if (d[0] != this.tilePos[0] || d[1] != this.tilePos[1]) this.p(d);
+ else {
+ b = [Math.floor(b) * 8, Math.floor(c) * 8];
+ this.pos[1] == b[1] && this.pos[0] == b[0] && this.u()
+ }!this.ghost && this.nextDir && g.playfield[d[0]][d[1]].intersection && this.nextDir & g.playfield[d[0]][d[1]].allowedDir && this.t()
+ };
+ E.prototype.B = function () {
+ if (this.id == g.playerCount && g.dotsRemaining < g.levels.elroyDotsLeftPart1 && this.mode == 2 && (!g.lostLifeOnThisLevel || g.actors[g.playerCount + 3].mode != 16)) {
+ var b = g.actors[this.targetPlayerId];
+ this.targetPos = [b.tilePos[0], b.tilePos[1]]
+ } else if (this.ghost && this.mode == 1) {
+ b = g.actors[this.targetPlayerId];
+ switch (this.id) {
+ case g.playerCount:
+ this.targetPos = [b.tilePos[0], b.tilePos[1]];
+ break;
+ case g.playerCount + 1:
+ this.targetPos = [b.tilePos[0], b.tilePos[1]];
+ var c = l[b.dir];
+ this.targetPos[c.axis] += 32 * c.increment;
+ if (b.dir == 1) this.targetPos[1] -= 32;
+ break;
+ case g.playerCount + 2:
+ var d = g.actors[g.playerCount],
+ f = [b.tilePos[0], b.tilePos[1]];
+ c = l[b.dir];
+ f[c.axis] += 16 * c.increment;
+ if (b.dir == 1) f[1] -= 16;
+ this.targetPos[0] = f[0] * 2 - d.tilePos[0];
+ this.targetPos[1] = f[1] * 2 - d.tilePos[1];
+ break;
+ case g.playerCount + 3:
+ c = g.getDistance(b.tilePos, this.tilePos);
+ this.targetPos = c > 64 ? [b.tilePos[0], b.tilePos[1]] : this.scatterPos;
+ break
+ }
+ }
+ };
+ E.prototype.v = function () {
+ this.routineMoveId++;
+ if (this.routineMoveId == A[this.routineToFollow].length) if (this.mode == 16 && this.freeToLeavePen && !g.ghostExitingPenNow) {
+ this.eatenInThisFrightMode ? this.a(128) : this.a(32);
+ return
+ } else if (this.mode == 32 || this.mode == 128) {
+ this.pos = [s[0], s[1] + 4];
+ this.dir = this.modeChangedWhileInPen ? 8 : 4;
+ var b = g.mainGhostMode;
+ if (this.mode == 128 && b == 4) b = g.lastMainGhostMode;
+ this.a(b);
+ return
+ } else if (this.mode == 64) {
+ if (this.id == g.playerCount || this.freeToLeavePen) this.a(128);
+ else {
+ this.eatenInThisFrightMode =
+ a;
+ this.a(16)
+ }
+ return
+ } else this.routineMoveId = 0;
+ b = A[this.routineToFollow][this.routineMoveId];
+ this.pos[0] = b.y * 8;
+ this.pos[1] = b.x * 8;
+ this.dir = b.dir;
+ this.physicalSpeed = 0;
+ this.speedIntervals = g.getSpeedIntervals(b.speed);
+ this.proceedToNextRoutineMove = e;
+ this.b()
+ };
+ E.prototype.m = function () {
+ var b = A[this.routineToFollow][this.routineMoveId];
+ if (b) if (this.speedIntervals[g.intervalTime]) {
+ var c = l[this.dir];
+ this.pos[c.axis] += c.increment;
+ switch (this.dir) {
+ case 1:
+ case 4:
+ if (this.pos[c.axis] < b.dest * 8) {
+ this.pos[c.axis] = b.dest * 8;
+ this.proceedToNextRoutineMove = a
+ }
+ break;
+ case 2:
+ case 8:
+ if (this.pos[c.axis] > b.dest * 8) {
+ this.pos[c.axis] = b.dest * 8;
+ this.proceedToNextRoutineMove = a
+ }
+ break
+ }
+ this.b()
+ }
+ };
+ E.prototype.j = function () {
+ if (this.routineMoveId == -1 || this.proceedToNextRoutineMove) this.v();
+ this.m()
+ };
+ E.prototype.d = function () {
+ switch (this.currentSpeed) {
+ case 0:
+ var b = this.id == g.playerCount && (this.mode == 2 || this.mode == 1) ? g.cruiseElroySpeed : this.fullSpeed;
+ break;
+ case 1:
+ b = this.dotEatingSpeed;
+ break;
+ case 2:
+ b = this.tunnelSpeed;
+ break
+ }
+ if (this.physicalSpeed != b) {
+ this.physicalSpeed = b;
+ this.speedIntervals = g.getSpeedIntervals(this.physicalSpeed)
+ }
+ };
+ E.prototype.c = function (b) {
+ this.currentSpeed = b;
+ this.d()
+ };
+ E.prototype.e = function () {
+ if (this.dir) if (this.speedIntervals[g.intervalTime]) {
+ var b = l[this.dir];
+ this.pos[b.axis] += b.increment;
+ this.o();
+ this.b()
+ }
+ };
+ E.prototype.move = function () {
+ if (g.gameplayMode == 0 || this.ghost && g.gameplayMode == 1 && (this.mode == 8 || this.mode == 64)) {
+ if (this.requestedDir != 0) {
+ this.z(this.requestedDir);
+ this.requestedDir = 0
+ }
+ if (this.followingRoutine) {
+ this.j();
+ this.mode == 64 && this.j()
+ } else {
+ this.e();
+ this.mode == 8 && this.e()
+ }
+ }
+ };
+ E.prototype.k = function () {
+ var b = g.getPlayfieldX(this.pos[1] + this.posDelta[1]),
+ c = g.getPlayfieldY(this.pos[0] + this.posDelta[0]);
+ if (this.elPos[0] != c || this.elPos[1] != b) {
+ this.elPos[0] = c;
+ this.elPos[1] = b;
+ this.el.style.left = b + "px";
+ this.el.style.top = c + "px"
+ }
+ };
+ E.prototype.s = function () {
+ var b = 0,
+ c = 0,
+ d = this.dir;
+ if (d == 0) d = this.lastActiveDir;
+ if (g.gameplayMode == 1 && this.id == g.playerEatingGhostId) {
+ b = 3;
+ c = 0
+ } else if ((g.gameplayMode == 9 || g.gameplayMode == 10) && this.id == 0) {
+ b = 2;
+ c = 0
+ } else if (g.gameplayMode == 4 || g.gameplayMode == 5 || g.gameplayMode == 7) {
+ b = this.id == 0 ? 2 : 4;
+ c = 0
+ } else if (g.gameplayMode == 3) if (this.id == g.playerDyingId) {
+ d = 20 - Math.floor(g.gameplayModeTime / g.timing[4] * 21);
+ if (this.id == 0) {
+ b = d - 1;
+ switch (b) {
+ case -1:
+ b = 0;
+ break;
+ case 11:
+ b = 10;
+ break;
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ b =
+ 11;
+ break
+ }
+ c = 12
+ } else switch (d) {
+ case 0:
+ case 1:
+ case 2:
+ case 6:
+ case 10:
+ b = 4;
+ c = 3;
+ break;
+ case 3:
+ case 7:
+ case 11:
+ b = 4;
+ c = 0;
+ break;
+ case 4:
+ case 8:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ b = 4;
+ c = 2;
+ break;
+ case 5:
+ case 9:
+ b = 4;
+ c = 1;
+ break
+ }
+ } else {
+ b = 3;
+ c = 0
+ } else if (this.el.id == "pcm-bpcm") {
+ b = 14;
+ c = 0;
+ d = Math.floor(g.globalTime * 0.2) % 4;
+ if (d == 3) d = 1;
+ c += 2 * d
+ } else {
+ switch (d) {
+ case 4:
+ c = 0;
+ break;
+ case 8:
+ c = 1;
+ break;
+ case 1:
+ c = 2;
+ break;
+ case 2:
+ c = 3;
+ break
+ }
+ if (g.gameplayMode != 2) b = Math.floor(g.globalTime * 0.3) % 4;
+ if (b == 3 && this.dir == 0) b = 0;
+ if (b == 2 && this.id == 0) b = 0;
+ if (b == 3) {
+ b = 2;
+ if (this.id == 0) c = 0
+ }
+ if (this.id == 1) b += 4
+ }
+ return [c, b]
+ };
+ E.prototype.r = function () {
+ var b = 0,
+ c = 0;
+ if (g.gameplayMode == 10 || g.gameplayMode == 4 || g.gameplayMode == 3) {
+ b = 3;
+ c = 0
+ } else if (g.gameplayMode == 1 && this.id == g.ghostBeingEatenId) {
+ switch (g.modeScoreMultiplier) {
+ case 2:
+ b = 0;
+ break;
+ case 4:
+ b = 1;
+ break;
+ case 8:
+ b = 2;
+ break;
+ case 16:
+ b = 3;
+ break
+ }
+ c = 11;
+ this.el.className = "pcm-ac pcm-n"
+ } else if (this.mode == 4 || (this.mode == 16 || this.mode == 32) && g.mainGhostMode == 4 && !this.eatenInThisFrightMode) {
+ b = 0;
+ c = 8;
+ if (g.frightModeTime < g.levels.frightTotalTime - g.levels.frightTime && Math.floor(g.frightModeTime / g.timing[1]) % 2 == 0) b += 2;
+ b += Math.floor(g.globalTime / 16) % 2
+ } else if (this.mode == 8 || this.mode == 64) {
+ c = this.nextDir;
+ if (!c) c = this.dir;
+ switch (c) {
+ case 4:
+ b = 2;
+ break;
+ case 8:
+ b = 3;
+ break;
+ case 1:
+ b = 0;
+ break;
+ case 2:
+ b = 1;
+ break
+ }
+ c = 10
+ } else if (this.el.id == "pcm-ghin") {
+ b = 6;
+ c = 8;
+ b += Math.floor(g.globalTime / 16) % 2
+ } else if (this.el.id == "pcm-gbug") {
+ b = 6;
+ c = 9;
+ c += Math.floor(g.globalTime / 16) % 2
+ } else if (this.el.id == "pcm-ghfa") {
+ b = g.cutsceneSequenceId == 3 ? 6 : 7;
+ c = 11
+ } else if (this.el.id == "pcm-stck") {
+ 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;
+ c = 13
+ } else {
+ c = this.nextDir;
+ if (!c || g.playfield[this.tilePos[0]][this.tilePos[1]].type == 1) c = this.dir;
+ switch (c) {
+ case 4:
+ b = 4;
+ break;
+ case 8:
+ b = 6;
+ break;
+ case 1:
+ b = 0;
+ break;
+ case 2:
+ b = 2;
+ break
+ }
+ c = 4 + this.id - g.playerCount;
+ if (this.speed > 0 || g.gameplayMode != 13) b += Math.floor(g.globalTime / 16) % 2
+ }
+ return [c, b]
+ };
+ E.prototype.b = function () {
+ this.k();
+ var b = [0, 0];
+ b = g.gameplayMode == 8 || g.gameplayMode == 14 ? [0, 3] : this.ghost ? this.r() : this.s();
+ if (this.elBackgroundPos[0] != b[0] || this.elBackgroundPos[1] != b[1]) {
+ this.elBackgroundPos[0] = b[0];
+ this.elBackgroundPos[1] = b[1];
+ b[0] *= 16;
+ b[1] *= 16;
+ g.changeElementBkPos(this.el, b[1], b[0], a)
+ }
+ };
+ g.rand = function () {
+ var b = 4294967296,
+ c = 134775813;
+ c = c * g.randSeed + 1;
+ return (g.randSeed = c % b) / b
+ };
+ g.seed = function (b) {
+ g.randSeed = b
+ };
+ g.getDistance = function (b, c) {
+ return Math.sqrt((c[1] - b[1]) * (c[1] - b[1]) + (c[0] - b[0]) * (c[0] - b[0]))
+ };
+ g.getPlayfieldX = function (b) {
+ return b + -32
+ };
+ g.getPlayfieldY = function (b) {
+ return b + 0
+ };
+ g.getCorrectedSpritePos = function (b) {
+ return b / 8 * 10 + 2
+ };
+ g.getDotElementId = function (b, c) {
+ return "pcm-d" + b + "-" + c
+ };
+ g.showElementById = function (b, c) {
+ var d = document.getElementById(b);
+ if (d) d.style.visibility = c ? "visible" : "hidden"
+ };
+ g.getAbsoluteElPos = function (b) {
+ var c = [0, 0];
+ do {
+ c[0] += b.offsetTop;
+ c[1] += b.offsetLeft
+ } while (b = b.offsetParent);
+ return c
+ };
+ g.prepareElement = function (b, c, d) {
+ c = g.getCorrectedSpritePos(parseInt(c, 10));
+ d = g.getCorrectedSpritePos(parseInt(d, 10));
+ if (g.useCss) {
+ b.style.backgroundImage = "url(src/pacman10-hp-sprite.png)";
+ b.style.backgroundPosition = -c + "px " + -d + "px";
+ b.style.backgroundRepeat = "no-repeat"
+ } else {
+ b.style.overflow = "hidden";
+ c = "display: block; position: relative; left: " + -c + "px; top: " + -d + "px";
+ b.innerHTML = '<img style="' + c + '" src="src/pacman10-hp-sprite.png">'
+ }
+ };
+ g.changeElementBkPos = function (b, c, d, f) {
+ if (f) {
+ c = g.getCorrectedSpritePos(c);
+ d = g.getCorrectedSpritePos(d)
+ }
+ if (g.useCss) b.style.backgroundPosition = -c + "px " + -d + "px";
+ else if (b.childNodes[0]) {
+ b.childNodes[0].style.left = -c + "px";
+ b.childNodes[0].style.top = -d + "px"
+ }
+ };
+ g.determinePlayfieldDimensions = function () {
+ g.playfieldWidth = 0;
+ g.playfieldHeight = 0;
+ for (var b in n) {
+ var c = n[b];
+ if (c.w) {
+ c = c.x + c.w - 1;
+ if (c > g.playfieldWidth) g.playfieldWidth = c
+ } else {
+ c = c.y + c.h - 1;
+ if (c > g.playfieldHeight) g.playfieldHeight = c
+ }
+ }
+ };
+ g.preparePlayfield = function () {
+ g.playfield = [];
+ for (var b = 0; b <= g.playfieldHeight + 1; b++) {
+ g.playfield[b * 8] = [];
+ for (var c = -2; c <= g.playfieldWidth + 1; c++) g.playfield[b * 8][c * 8] = {
+ path: 0,
+ dot: 0,
+ intersection: 0
+ }
+ }
+ };
+ g.preparePaths = function () {
+ for (var b in n) {
+ var c = n[b],
+ d = c.type;
+ if (c.w) {
+ for (var f = c.y * 8, h = c.x * 8; h <= (c.x + c.w - 1) * 8; h += 8) {
+ g.playfield[f][h].path = a;
+ if (g.playfield[f][h].dot == 0) {
+ g.playfield[f][h].dot = 1;
+ g.dotsRemaining++
+ }
+ g.playfield[f][h].type = !d || h != c.x * 8 && h != (c.x + c.w - 1) * 8 ? d : 0
+ }
+ g.playfield[f][c.x * 8].intersection = a;
+ g.playfield[f][(c.x + c.w - 1) * 8].intersection = a
+ } else {
+ h = c.x * 8;
+ for (f = c.y * 8; f <= (c.y + c.h - 1) * 8; f += 8) {
+ if (g.playfield[f][h].path) g.playfield[f][h].intersection = a;
+ g.playfield[f][h].path = a;
+ if (g.playfield[f][h].dot == 0) {
+ g.playfield[f][h].dot = 1;
+ g.dotsRemaining++
+ }
+ g.playfield[f][h].type = !d || f != c.y * 8 && f != (c.y + c.h - 1) * 8 ? d : 0
+ }
+ g.playfield[c.y * 8][h].intersection = a;
+ g.playfield[(c.y + c.h - 1) * 8][h].intersection = a
+ }
+ }
+ 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) {
+ g.playfield[o[b].y * 8][h].dot = 0;
+ g.dotsRemaining--
+ } else for (f = o[b].y * 8; f <= (o[b].y + o[b].h - 1) * 8; f += 8) {
+ g.playfield[f][o[b].x * 8].dot = 0;
+ g.dotsRemaining--
+ }
+ };
+ g.prepareAllowedDirections = function () {
+ for (var b = 8; b <= g.playfieldHeight * 8; b += 8) for (var c = 8; c <= g.playfieldWidth * 8; c += 8) {
+ g.playfield[b][c].allowedDir = 0;
+ if (g.playfield[b - 8][c].path) g.playfield[b][c].allowedDir += 1;
+ if (g.playfield[b + 8][c].path) g.playfield[b][c].allowedDir += 2;
+ if (g.playfield[b][c - 8].path) g.playfield[b][c].allowedDir += 4;
+ if (g.playfield[b][c + 8].path) g.playfield[b][c].allowedDir += 8
+ }
+ };
+ g.createDotElements = function () {
+ 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) {
+ var d = document.createElement("div");
+ d.className = "pcm-d";
+ d.id = g.getDotElementId(b, c);
+ d.style.left = c + -32 + "px";
+ d.style.top = b + 0 + "px";
+ g.playfieldEl.appendChild(d)
+ }
+ };
+ g.createEnergizerElements = function () {
+ for (var b in p) {
+ var c = p[b],
+ d = g.getDotElementId(c.y * 8, c.x * 8);
+ document.getElementById(d).className = "pcm-e";
+ g.prepareElement(document.getElementById(d), 0, 144);
+ g.playfield[c.y * 8][c.x * 8].dot = 2
+ }
+ };
+ g.createFruitElement = function () {
+ g.fruitEl = document.createElement("div");
+ g.fruitEl.id = "pcm-f";
+ g.fruitEl.style.left = g.getPlayfieldX(v[1]) + "px";
+ g.fruitEl.style.top = g.getPlayfieldY(v[0]) + "px";
+ g.prepareElement(g.fruitEl, -32, -16);
+ g.playfieldEl.appendChild(g.fruitEl)
+ };
+ g.createPlayfieldElements = function () {
+ g.doorEl = document.createElement("div");
+ g.doorEl.id = "pcm-do";
+ g.doorEl.style.display = "none";
+ g.playfieldEl.appendChild(g.doorEl);
+ g.createDotElements();
+ g.createEnergizerElements();
+ g.createFruitElement()
+ };
+ g.createActors = function () {
+ g.actors = [];
+ for (var b = 0; b < g.playerCount + 4; b++) {
+ g.actors[b] = new E(b);
+ if (b < g.playerCount) {
+ g.actors[b].ghost = e;
+ g.actors[b].mode = 1
+ } else g.actors[b].ghost = a
+ }
+ };
+ g.restartActors = function () {
+ for (var b in g.actors) g.actors[b].A()
+ };
+ g.createActorElements = function () {
+ for (var b in g.actors) g.actors[b].createElement()
+ };
+ g.createPlayfield = function () {
+ g.playfieldEl = document.createElement("div");
+ g.playfieldEl.id = "pcm-p";
+ g.canvasEl.appendChild(g.playfieldEl)
+ };
+ g.resetPlayfield = function () {
+ g.dotsRemaining = 0;
+ g.dotsEaten = 0;
+ g.playfieldEl.innerHTML = "";
+ g.prepareElement(g.playfieldEl, 256, 0);
+ g.determinePlayfieldDimensions();
+ g.preparePlayfield();
+ g.preparePaths();
+ g.prepareAllowedDirections();
+ g.createPlayfieldElements();
+ g.createActorElements()
+ };
+ g.keyPressed = function (b) {
+ var c = e;
+ switch (b) {
+ case 37:
+ g.actors[0].requestedDir = 4;
+ c = a;
+ break;
+ case 38:
+ g.actors[0].requestedDir = 1;
+ c = a;
+ break;
+ case 39:
+ g.actors[0].requestedDir = 8;
+ c = a;
+ break;
+ case 40:
+ g.actors[0].requestedDir = 2;
+ c = a;
+ break;
+ case 65:
+ if (g.playerCount == 2) {
+ g.actors[1].requestedDir = 4;
+ c = a
+ }
+ break;
+ case 83:
+ if (g.playerCount == 2) {
+ g.actors[1].requestedDir = 2;
+ c = a
+ }
+ break;
+ case 68:
+ if (g.playerCount == 2) {
+ g.actors[1].requestedDir = 8;
+ c = a
+ }
+ break;
+ case 87:
+ if (g.playerCount == 2) {
+ g.actors[1].requestedDir = 1;
+ c = a
+ }
+ break
+ }
+ return c
+ };
+ g.handleKeyDown = function (b) {
+ if (!b) b = window.event;
+ if (g.keyPressed(b.keyCode)) if (b.preventDefault) b.preventDefault();
+ else b.returnValue = e
+ };
+ g.canvasClicked = function (b, c) {
+ var d = g.getAbsoluteElPos(g.canvasEl);
+ b -= d[1] - -32;
+ c -= d[0] - 0;
+ d = g.actors[0];
+ var f = g.getPlayfieldX(d.pos[1] + d.posDelta[1]) + 16,
+ h = g.getPlayfieldY(d.pos[0] + d.posDelta[0]) + 32,
+ j = Math.abs(b - f),
+ k = Math.abs(c - h);
+ if (j > 8 && k < j) d.requestedDir = b > f ? 8 : 4;
+ else if (k > 8 && j < k) d.requestedDir = c > h ? 2 : 1
+ };
+ g.handleClick = function (b) {
+ if (!b) b = window.event;
+ g.canvasClicked(b.clientX, b.clientY)
+ };
+ g.registerTouch = function () {
+ document.body.addEventListener("touchstart", g.handleTouchStart, a);
+ g.canvasEl.addEventListener("touchstart", g.handleTouchStart, a);
+ document.f && document.f.q && document.f.q.addEventListener("touchstart", g.handleTouchStart, a)
+ };
+ g.handleTouchStart = function (b) {
+ g.touchDX = 0;
+ g.touchDY = 0;
+ if (b.touches.length == 1) {
+ g.touchStartX = b.touches[0].pageX;
+ g.touchStartY = b.touches[0].pageY;
+ document.body.addEventListener("touchmove", g.handleTouchMove, a);
+ document.body.addEventListener("touchend", g.handleTouchEnd, a)
+ }
+ b.preventDefault();
+ b.stopPropagation()
+ };
+ g.handleTouchMove = function (b) {
+ if (b.touches.length > 1) g.cancelTouch();
+ else {
+ g.touchDX = b.touches[0].pageX - g.touchStartX;
+ g.touchDY = b.touches[0].pageY - g.touchStartY
+ }
+ b.preventDefault();
+ b.stopPropagation()
+ };
+ g.handleTouchEnd = function (b) {
+ if (g.touchDX == 0 && g.touchDY == 0) g.canvasClicked(g.touchStartX, g.touchStartY);
+ else {
+ var c = Math.abs(g.touchDX),
+ d = Math.abs(g.touchDY);
+ if (c < 8 && d < 8) g.canvasClicked(g.touchStartX, g.touchStartY);
+ else if (c > 15 && d < c * 2 / 3) g.actors[0].requestedDir = g.touchDX > 0 ? 8 : 4;
+ else if (d > 15 && c < d * 2 / 3) g.actors[0].requestedDir = g.touchDY > 0 ? 2 : 1
+ }
+ b.preventDefault();
+ b.stopPropagation();
+ g.cancelTouch()
+ };
+ g.cancelTouch = function () {
+ document.body.removeEventListener("touchmove", g.handleTouchMove, a);
+ document.body.removeEventListener("touchend", g.handleTouchEnd, a);
+ g.touchStartX = null;
+ g.touchStartY = null
+ };
+ g.addEventListeners = function () {
+ if (window.addEventListener) {
+ window.addEventListener("keydown", g.handleKeyDown, e);
+ g.canvasEl.addEventListener("click", g.handleClick, e);
+ g.registerTouch()
+ } else {
+ document.body.attachEvent("onkeydown", g.handleKeyDown);
+ g.canvasEl.attachEvent("onclick", g.handleClick)
+ }
+ };
+ g.startGameplay = function () {
+ g.score = [0, 0];
+ g.extraLifeAwarded = [e, e];
+ g.lives = 3;
+ g.level = 0;
+ g.paused = e;
+ g.globalTime = 0;
+ g.newLevel(a)
+ };
+ g.restartGameplay = function (b) {
+ g.seed(0);
+ g.frightModeTime = 0;
+ g.intervalTime = 0;
+ g.gameplayModeTime = 0;
+ g.fruitTime = 0;
+ g.ghostModeSwitchPos = 0;
+ g.ghostModeTime = g.levels.ghostModeSwitchTimes[0] * D;
+ g.ghostExitingPenNow = e;
+ g.ghostEyesCount = 0;
+ g.tilesChanged = e;
+ g.updateCruiseElroySpeed();
+ g.hideFruit();
+ g.resetForcePenLeaveTime();
+ g.restartActors();
+ g.updateActorPositions();
+ g.switchMainGhostMode(2, a);
+ for (var c = g.playerCount + 1; c < g.playerCount + 4; c++) g.actors[c].a(16);
+ g.dotEatingChannel = [0, 0];
+ g.dotEatingSoundPart = [1, 1];
+ g.clearDotEatingNow();
+ b ? g.changeGameplayMode(4) : g.changeGameplayMode(6)
+ };
+ g.initiateDoubleMode = function () {
+ if (g.playerCount != 2) {
+ g.stopAllAudio();
+ g.changeGameplayMode(12)
+ }
+ };
+ g.newGame = function () {
+ g.playerCount = 1;
+ g.createChrome();
+ g.createPlayfield();
+ g.createActors();
+ g.startGameplay()
+ };
+ g.switchToDoubleMode = function () {
+ g.playerCount = 2;
+ g.createChrome();
+ g.createPlayfield();
+ g.createActors();
+ g.startGameplay()
+ };
+ g.insertCoin = function () {
+ g.gameplayMode == 8 || g.gameplayMode == 14 ? g.newGame() : g.initiateDoubleMode()
+ };
+ g.createKillScreenElement = function (b, c, d, f, h) {
+ var j = document.createElement("div");
+ j.style.left = b + "px";
+ j.style.top = c + "px";
+ j.style.width = d + "px";
+ j.style.height = f + "px";
+ j.style.zIndex = 119;
+ if (h) {
+ j.style.background = "url(src/pacman10-hp-sprite.png) -" + g.killScreenTileX + "px -" + g.killScreenTileY + "px no-repeat";
+ g.killScreenTileY += 8
+ } else j.style.background = "black";
+ g.playfieldEl.appendChild(j)
+ };
+ g.killScreen = function () {
+ g.seed(0);
+ g.canvasEl.style.visibility = "";
+ g.createKillScreenElement(272, 0, 200, 80, e);
+ g.createKillScreenElement(280, 80, 192, 56, e);
+ g.killScreenTileX = 80;
+ g.killScreenTileY = 0;
+ for (var b = 280; b <= 472; b += 8) for (var c = 0; c <= 136; c += 8) {
+ if (g.rand() < 0.03) {
+ g.killScreenTileX = Math.floor(g.rand() * 25) * 10;
+ g.killScreenTileY = Math.floor(g.rand() * 2) * 10
+ }
+ g.createKillScreenElement(b, c, 8, 8, a)
+ }
+ g.changeGameplayMode(14)
+ };
+ g.newLevel = function (b) {
+ g.level++;
+ g.levels = g.level >= z.length ? z[z.length - 1] : z[g.level];
+ g.levels.frightTime = Math.round(g.levels.frightTime * D);
+ g.levels.frightTotalTime = g.levels.frightTime + g.timing[1] * (g.levels.frightBlinkCount * 2 - 1);
+ for (var c in g.actors) g.actors[c].dotCount = 0;
+ g.alternatePenLeavingScheme = e;
+ g.lostLifeOnThisLevel = e;
+ g.updateChrome();
+ g.resetPlayfield();
+ g.restartGameplay(b);
+ g.level == 256 && g.killScreen()
+ };
+ g.newLife = function () {
+ g.lostLifeOnThisLevel = a;
+ g.alternatePenLeavingScheme = a;
+ g.alternateDotCount = 0;
+ g.lives--;
+ g.updateChromeLives();
+ g.lives == -1 ? g.changeGameplayMode(8) : g.restartGameplay(e)
+ };
+ g.switchMainGhostMode = function (b, c) {
+ if (b == 4 && g.levels.frightTime == 0) for (var d in g.actors) {
+ var f = g.actors[d];