Advertisement
Guest User

Untitled

a guest
May 21st, 2010
28,664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "pcm-bpcm"
  2.                     },
  3.                     {
  4.                         dir: 8,
  5.                         speed: 0.8,
  6.                         mode: 4
  7.                     }]
  8.                 }]
  9.             },
  10.             2: {
  11.                 actors: [{
  12.                     ghost: e,
  13.                     x: 64,
  14.                     y: 9,
  15.                     id: 0
  16.                 },
  17.                 {
  18.                     ghost: a,
  19.                     x: 70.2,
  20.                     y: 9,
  21.                     id: 1
  22.                 },
  23.                 {
  24.                     ghost: a,
  25.                     x: 32,
  26.                     y: 9.5,
  27.                     id: 2
  28.                 }],
  29.                 sequence: [{
  30.                     time: 2.7,
  31.                     moves: [{
  32.                         dir: 4,
  33.                         speed: 0.75 * 0.8 * 2
  34.                     },
  35.                     {
  36.                         dir: 4,
  37.                         speed: 0.78 * 0.8 * 2
  38.                     },
  39.                     {
  40.                         dir: 0,
  41.                         speed: 0,
  42.                         elId: "pcm-stck"
  43.                     }]
  44.                 },
  45.                 {
  46.                     time: 1,
  47.                     moves: [{
  48.                         dir: 4,
  49.                         speed: 0.75 * 0.8 * 2
  50.                     },
  51.                     {
  52.                         dir: 4,
  53.                         speed: 0.1 * 0.8
  54.                     },
  55.                     {
  56.                         dir: 0,
  57.                         speed: 0,
  58.                         elId: "pcm-stck"
  59.                     }]
  60.                 },
  61.                 {
  62.                     time: 1.3,
  63.                     moves: [{
  64.                         dir: 4,
  65.                         speed: 0.75 * 0.8 * 2
  66.                     },
  67.                     {
  68.                         dir: 4,
  69.                         speed: 0
  70.                     },
  71.                     {
  72.                         dir: 0,
  73.                         speed: 0,
  74.                         elId: "pcm-stck"
  75.                     }]
  76.                 },
  77.                 {
  78.                     time: 1,
  79.                     moves: [{
  80.                         dir: 4,
  81.                         speed: 0.75 * 0.8 * 2
  82.                     },
  83.                     {
  84.                         dir: 4,
  85.                         speed: 0,
  86.                         elId: "pcm-ghfa"
  87.                     },
  88.                     {
  89.                         dir: 0,
  90.                         speed: 0,
  91.                         elId: "pcm-stck"
  92.                     }]
  93.                 },
  94.                 {
  95.                     time: 2.5,
  96.                     moves: [{
  97.                         dir: 4,
  98.                         speed: 0.75 * 0.8 * 2
  99.                     },
  100.                     {
  101.                         dir: 4,
  102.                         speed: 0,
  103.                         elId: "pcm-ghfa"
  104.                     },
  105.                     {
  106.                         dir: 0,
  107.                         speed: 0,
  108.                         elId: "pcm-stck"
  109.                     }]
  110.                 }]
  111.             },
  112.             3: {
  113.                 actors: [{
  114.                     ghost: e,
  115.                     x: 64,
  116.                     y: 9,
  117.                     id: 0
  118.                 },
  119.                 {
  120.                     ghost: a,
  121.                     x: 70.2,
  122.                     y: 9,
  123.                     id: 2
  124.                 }],
  125.                 sequence: [{
  126.                     time: 5.3,
  127.                     moves: [{
  128.                         dir: 4,
  129.                         speed: 0.75 * 0.8 * 2
  130.                     },
  131.                     {
  132.                         dir: 4,
  133.                         speed: 0.78 * 0.8 * 2,
  134.                         elId: "pcm-ghin"
  135.                     }]
  136.                 },
  137.                 {
  138.                     time: 5.3,
  139.                     moves: [{
  140.                         dir: 4,
  141.                         speed: 0
  142.                     },
  143.                     {
  144.                         dir: 8,
  145.                         speed: 0.78 * 0.8 * 2,
  146.                         elId: "pcm-gbug"
  147.                     }]
  148.                 }]
  149.             }
  150.         },
  151.         C = [90, 45, 30],
  152.         D = C[0];
  153.  
  154.     function E(b) {
  155.         this.id = b
  156.     }
  157.     E.prototype.A = function () {
  158.         var b = r[g.playerCount][this.id];
  159.         this.pos = [b.y * 8, b.x * 8];
  160.         this.posDelta = [0, 0];
  161.         this.tilePos = [b.y * 8, b.x * 8];
  162.         this.targetPos = [b.scatterY * 8, b.scatterX * 8];
  163.         this.scatterPos = [b.scatterY * 8, b.scatterX * 8];
  164.         this.lastActiveDir = this.dir = b.dir;
  165.         this.physicalSpeed = this.requestedDir = this.nextDir = 0;
  166.         this.c(0);
  167.         this.reverseDirectionsNext = this.freeToLeavePen = this.modeChangedWhileInPen = this.eatenInThisFrightMode = e;
  168.         this.l()
  169.     };
  170.     E.prototype.createElement = function () {
  171.         this.el = document.createElement("div");
  172.         this.el.className = "pcm-ac";
  173.         this.el.id = "actor" + this.id;
  174.         g.prepareElement(this.el, 0, 0);
  175.         g.playfieldEl.appendChild(this.el);
  176.         this.elPos = [0, 0];
  177.         this.elBackgroundPos = [0, 0]
  178.     };
  179.     E.prototype.a = function (b) {
  180.         var c = this.mode;
  181.         this.mode = b;
  182.         if (this.id == g.playerCount + 3 && (b == 16 || c == 16)) g.updateCruiseElroySpeed();
  183.         switch (c) {
  184.         case 32:
  185.             g.ghostExitingPenNow = e;
  186.             break;
  187.         case 8:
  188.             g.ghostEyesCount > 0 && g.ghostEyesCount--;
  189.             g.ghostEyesCount == 0 && g.playAmbientSound();
  190.             break
  191.         }
  192.         switch (b) {
  193.         case 4:
  194.             this.fullSpeed = g.levels.ghostFrightSpeed * 0.8;
  195.             this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
  196.             this.followingRoutine = e;
  197.             break;
  198.         case 1:
  199.             this.fullSpeed = g.levels.ghostSpeed * 0.8;
  200.             this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
  201.             this.followingRoutine =
  202.             e;
  203.             break;
  204.         case 2:
  205.             this.targetPos = this.scatterPos;
  206.             this.fullSpeed = g.levels.ghostSpeed * 0.8;
  207.             this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
  208.             this.followingRoutine = e;
  209.             break;
  210.         case 8:
  211.             this.tunnelSpeed = this.fullSpeed = 1.6;
  212.             this.targetPos = [s[0], s[1]];
  213.             this.freeToLeavePen = this.followingRoutine = e;
  214.             break;
  215.         case 16:
  216.             this.l();
  217.             this.followingRoutine = a;
  218.             this.routineMoveId = -1;
  219.             switch (this.id) {
  220.             case g.playerCount + 1:
  221.                 this.routineToFollow = 2;
  222.                 break;
  223.             case g.playerCount + 2:
  224.                 this.routineToFollow = 1;
  225.                 break;
  226.             case g.playerCount + 3:
  227.                 this.routineToFollow =
  228.                 3;
  229.                 break
  230.             }
  231.             break;
  232.         case 32:
  233.             this.followingRoutine = a;
  234.             this.routineMoveId = -1;
  235.             switch (this.id) {
  236.             case g.playerCount + 1:
  237.                 this.routineToFollow = 5;
  238.                 break;
  239.             case g.playerCount + 2:
  240.                 this.routineToFollow = 4;
  241.                 break;
  242.             case g.playerCount + 3:
  243.                 this.routineToFollow = 6;
  244.                 break
  245.             }
  246.             g.ghostExitingPenNow = a;
  247.             break;
  248.         case 64:
  249.             this.followingRoutine = a;
  250.             this.routineMoveId = -1;
  251.             switch (this.id) {
  252.             case g.playerCount:
  253.             case g.playerCount + 1:
  254.                 this.routineToFollow = 8;
  255.                 break;
  256.             case g.playerCount + 2:
  257.                 this.routineToFollow = 7;
  258.                 break;
  259.             case g.playerCount + 3:
  260.                 this.routineToFollow = 9;
  261.                 break
  262.             }
  263.             break;
  264.         case 128:
  265.             this.followingRoutine = a;
  266.             this.routineMoveId = -1;
  267.             switch (this.id) {
  268.             case g.playerCount:
  269.             case g.playerCount + 1:
  270.                 this.routineToFollow = 11;
  271.                 break;
  272.             case g.playerCount + 2:
  273.                 this.routineToFollow = 10;
  274.                 break;
  275.             case g.playerCount + 3:
  276.                 this.routineToFollow = 12;
  277.                 break
  278.             }
  279.             break
  280.         }
  281.         this.d()
  282.     };
  283.     E.prototype.l = function () {
  284.         if (this.id >= g.playerCount) this.targetPlayerId = Math.floor(g.rand() * g.playerCount)
  285.     };
  286.     E.prototype.z = function (b) {
  287.         if (this.dir == g.oppositeDirections[b]) {
  288.             this.dir = b;
  289.             this.posDelta = [0, 0];
  290.             this.currentSpeed != 2 && this.c(0);
  291.             if (this.dir != 0) this.lastActiveDir = this.dir;
  292.             this.nextDir = 0
  293.         } else if (this.dir != b) if (this.dir == 0) {
  294.             if (g.playfield[this.pos[0]][this.pos[1]].allowedDir & b) this.dir = b
  295.         } else {
  296.             var c = g.playfield[this.tilePos[0]][this.tilePos[1]];
  297.             if (c && c.allowedDir & b) {
  298.                 c = l[this.dir];
  299.                 var d = [this.pos[0], this.pos[1]];
  300.                 d[c.axis] -= c.increment;
  301.                 var f = 0;
  302.                 if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) f = 1;
  303.                 else {
  304.                     d[c.axis] -= c.increment;
  305.                     if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) f = 2
  306.                 }
  307.                 if (f) {
  308.                     this.dir = b;
  309.                     this.pos[0] = this.tilePos[0];
  310.                     this.pos[1] = this.tilePos[1];
  311.                     c = l[this.dir];
  312.                     this.pos[c.axis] += c.increment * f;
  313.                     return
  314.                 }
  315.             }
  316.             this.nextDir = b;
  317.             this.posDelta = [0, 0]
  318.         }
  319.     };
  320.     E.prototype.i = function (b) {
  321.         var c = this.tilePos,
  322.             d = l[this.dir],
  323.             f = [c[0], c[1]];
  324.         f[d.axis] += d.increment * 8;
  325.         var h = g.playfield[f[0]][f[1]];
  326.         if (b && !h.intersection) h = g.playfield[c[0]][c[1]];
  327.         if (h.intersection) switch (this.mode) {
  328.         case 2:
  329.         case 1:
  330.         case 8:
  331.             if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) this.nextDir = g.oppositeDirections[this.dir];
  332.             else {
  333.                 b = 99999999999;
  334.                 c = 0;
  335.                 for (var j in i) {
  336.                     var k = i[j];
  337.                     if (h.allowedDir & k && this.dir != g.oppositeDirections[k]) {
  338.                         d = l[k];
  339.                         var x = [f[0], f[1]];
  340.                         x[d.axis] += d.increment;
  341.                         d = g.getDistance(x, [this.targetPos[0], this.targetPos[1]]);
  342.                         if (d < b) {
  343.                             b = d;
  344.                             c = k
  345.                         }
  346.                     }
  347.                 }
  348.                 if (c) this.nextDir = c
  349.             }
  350.             break;
  351.         case 4:
  352.             if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) this.nextDir = g.oppositeDirections[this.dir];
  353.             else {
  354.                 do f = i[Math.floor(g.rand() * 4)];
  355.                 while ((f & h.allowedDir) == 0 || f == g.oppositeDirections[this.dir]);
  356.                 this.nextDir = f
  357.             }
  358.             break
  359.         }
  360.     };
  361.     E.prototype.p = function (b) {
  362.         g.tilesChanged = a;
  363.         if (this.reverseDirectionsNext) {
  364.             this.dir = g.oppositeDirections[this.dir];
  365.             this.nextDir = 0;
  366.             this.reverseDirectionsNext = e;
  367.             this.i(a)
  368.         }
  369.         if (!this.ghost && !g.playfield[b[0]][b[1]].path) {
  370.             this.pos[0] = this.lastGoodTilePos[0];
  371.             this.pos[1] = this.lastGoodTilePos[1];
  372.             b[0] = this.lastGoodTilePos[0];
  373.             b[1] = this.lastGoodTilePos[1];
  374.             this.dir = 0
  375.         } else this.lastGoodTilePos = [b[0], b[1]];
  376.         g.playfield[b[0]][b[1]].type == 1 && this.mode != 8 ? this.c(2) : this.c(0);
  377.         !this.ghost && g.playfield[b[0]][b[1]].dot && g.dotEaten(this.id, b);
  378.         this.tilePos[0] = b[0];
  379.         this.tilePos[1] = b[1]
  380.     };
  381.     E.prototype.t = function () {
  382.         var b = this.tilePos;
  383.         switch (this.dir) {
  384.         case 1:
  385.             var c = [b[0], b[1]],
  386.                 d = [b[0] + 3.6, b[1]];
  387.             break;
  388.         case 2:
  389.             c = [b[0] - 4, b[1]];
  390.             d = [b[0], b[1]];
  391.             break;
  392.         case 4:
  393.             c = [b[0], b[1]];
  394.             d = [b[0], b[1] + 3.6];
  395.             break;
  396.         case 8:
  397.             c = [b[0], b[1] - 4];
  398.             d = [b[0], b[1]];
  399.             break
  400.         }
  401.         if (this.pos[0] >= c[0] && this.pos[0] <= d[0] && this.pos[1] >= c[1] && this.pos[1] <= d[1]) {
  402.             b = l[this.nextDir];
  403.             this.posDelta[b.axis] += b.increment
  404.         }
  405.     };
  406.     E.prototype.n = function () {
  407.         if (this.pos[0] == q[0].y * 8 && this.pos[1] == q[0].x * 8) {
  408.             this.pos[0] = q[1].y * 8;
  409.             this.pos[1] = (q[1].x - 1) * 8
  410.         } else if (this.pos[0] == q[1].y * 8 && this.pos[1] == q[1].x * 8) {
  411.             this.pos[0] = q[0].y * 8;
  412.             this.pos[1] = (q[0].x + 1) * 8
  413.         }
  414.         this.mode == 8 && this.pos[0] == s[0] && this.pos[1] == s[1] && this.a(64);
  415.         if (!this.ghost && this.pos[0] == v[0] && (this.pos[1] == v[1] || this.pos[1] == v[1] + 8)) g.eatFruit(this.id)
  416.     };
  417.     E.prototype.u = function () {
  418.         this.n();
  419.         this.ghost && this.i(e);
  420.         var b = g.playfield[this.pos[0]][this.pos[1]];
  421.         if (b.intersection) if (this.nextDir && this.nextDir & b.allowedDir) {
  422.             if (this.dir != 0) this.lastActiveDir = this.dir;
  423.             this.dir = this.nextDir;
  424.             this.nextDir = 0;
  425.             if (!this.ghost) {
  426.                 this.pos[0] += this.posDelta[0];
  427.                 this.pos[1] += this.posDelta[1];
  428.                 this.posDelta = [0, 0]
  429.             }
  430.         } else if ((this.dir & b.allowedDir) == 0) {
  431.             if (this.dir != 0) this.lastActiveDir = this.dir;
  432.             this.nextDir = this.dir = 0;
  433.             this.c(0)
  434.         }
  435.     };
  436.     E.prototype.o = function () {
  437.         var b = this.pos[0] / 8,
  438.             c = this.pos[1] / 8,
  439.             d = [Math.round(b) * 8, Math.round(c) * 8];
  440.         if (d[0] != this.tilePos[0] || d[1] != this.tilePos[1]) this.p(d);
  441.         else {
  442.             b = [Math.floor(b) * 8, Math.floor(c) * 8];
  443.             this.pos[1] == b[1] && this.pos[0] == b[0] && this.u()
  444.         }!this.ghost && this.nextDir && g.playfield[d[0]][d[1]].intersection && this.nextDir & g.playfield[d[0]][d[1]].allowedDir && this.t()
  445.     };
  446.     E.prototype.B = function () {
  447.         if (this.id == g.playerCount && g.dotsRemaining < g.levels.elroyDotsLeftPart1 && this.mode == 2 && (!g.lostLifeOnThisLevel || g.actors[g.playerCount + 3].mode != 16)) {
  448.             var b = g.actors[this.targetPlayerId];
  449.             this.targetPos = [b.tilePos[0], b.tilePos[1]]
  450.         } else if (this.ghost && this.mode == 1) {
  451.             b = g.actors[this.targetPlayerId];
  452.             switch (this.id) {
  453.             case g.playerCount:
  454.                 this.targetPos = [b.tilePos[0], b.tilePos[1]];
  455.                 break;
  456.             case g.playerCount + 1:
  457.                 this.targetPos = [b.tilePos[0], b.tilePos[1]];
  458.                 var c = l[b.dir];
  459.                 this.targetPos[c.axis] += 32 * c.increment;
  460.                 if (b.dir == 1) this.targetPos[1] -= 32;
  461.                 break;
  462.             case g.playerCount + 2:
  463.                 var d = g.actors[g.playerCount],
  464.                     f = [b.tilePos[0], b.tilePos[1]];
  465.                 c = l[b.dir];
  466.                 f[c.axis] += 16 * c.increment;
  467.                 if (b.dir == 1) f[1] -= 16;
  468.                 this.targetPos[0] = f[0] * 2 - d.tilePos[0];
  469.                 this.targetPos[1] = f[1] * 2 - d.tilePos[1];
  470.                 break;
  471.             case g.playerCount + 3:
  472.                 c = g.getDistance(b.tilePos, this.tilePos);
  473.                 this.targetPos = c > 64 ? [b.tilePos[0], b.tilePos[1]] : this.scatterPos;
  474.                 break
  475.             }
  476.         }
  477.     };
  478.     E.prototype.v = function () {
  479.         this.routineMoveId++;
  480.         if (this.routineMoveId == A[this.routineToFollow].length) if (this.mode == 16 && this.freeToLeavePen && !g.ghostExitingPenNow) {
  481.             this.eatenInThisFrightMode ? this.a(128) : this.a(32);
  482.             return
  483.         } else if (this.mode == 32 || this.mode == 128) {
  484.             this.pos = [s[0], s[1] + 4];
  485.             this.dir = this.modeChangedWhileInPen ? 8 : 4;
  486.             var b = g.mainGhostMode;
  487.             if (this.mode == 128 && b == 4) b = g.lastMainGhostMode;
  488.             this.a(b);
  489.             return
  490.         } else if (this.mode == 64) {
  491.             if (this.id == g.playerCount || this.freeToLeavePen) this.a(128);
  492.             else {
  493.                 this.eatenInThisFrightMode =
  494.                 a;
  495.                 this.a(16)
  496.             }
  497.             return
  498.         } else this.routineMoveId = 0;
  499.         b = A[this.routineToFollow][this.routineMoveId];
  500.         this.pos[0] = b.y * 8;
  501.         this.pos[1] = b.x * 8;
  502.         this.dir = b.dir;
  503.         this.physicalSpeed = 0;
  504.         this.speedIntervals = g.getSpeedIntervals(b.speed);
  505.         this.proceedToNextRoutineMove = e;
  506.         this.b()
  507.     };
  508.     E.prototype.m = function () {
  509.         var b = A[this.routineToFollow][this.routineMoveId];
  510.         if (b) if (this.speedIntervals[g.intervalTime]) {
  511.             var c = l[this.dir];
  512.             this.pos[c.axis] += c.increment;
  513.             switch (this.dir) {
  514.             case 1:
  515.             case 4:
  516.                 if (this.pos[c.axis] < b.dest * 8) {
  517.                     this.pos[c.axis] = b.dest * 8;
  518.                     this.proceedToNextRoutineMove = a
  519.                 }
  520.                 break;
  521.             case 2:
  522.             case 8:
  523.                 if (this.pos[c.axis] > b.dest * 8) {
  524.                     this.pos[c.axis] = b.dest * 8;
  525.                     this.proceedToNextRoutineMove = a
  526.                 }
  527.                 break
  528.             }
  529.             this.b()
  530.         }
  531.     };
  532.     E.prototype.j = function () {
  533.         if (this.routineMoveId == -1 || this.proceedToNextRoutineMove) this.v();
  534.         this.m()
  535.     };
  536.     E.prototype.d = function () {
  537.         switch (this.currentSpeed) {
  538.         case 0:
  539.             var b = this.id == g.playerCount && (this.mode == 2 || this.mode == 1) ? g.cruiseElroySpeed : this.fullSpeed;
  540.             break;
  541.         case 1:
  542.             b = this.dotEatingSpeed;
  543.             break;
  544.         case 2:
  545.             b = this.tunnelSpeed;
  546.             break
  547.         }
  548.         if (this.physicalSpeed != b) {
  549.             this.physicalSpeed = b;
  550.             this.speedIntervals = g.getSpeedIntervals(this.physicalSpeed)
  551.         }
  552.     };
  553.     E.prototype.c = function (b) {
  554.         this.currentSpeed = b;
  555.         this.d()
  556.     };
  557.     E.prototype.e = function () {
  558.         if (this.dir) if (this.speedIntervals[g.intervalTime]) {
  559.             var b = l[this.dir];
  560.             this.pos[b.axis] += b.increment;
  561.             this.o();
  562.             this.b()
  563.         }
  564.     };
  565.     E.prototype.move = function () {
  566.         if (g.gameplayMode == 0 || this.ghost && g.gameplayMode == 1 && (this.mode == 8 || this.mode == 64)) {
  567.             if (this.requestedDir != 0) {
  568.                 this.z(this.requestedDir);
  569.                 this.requestedDir = 0
  570.             }
  571.             if (this.followingRoutine) {
  572.                 this.j();
  573.                 this.mode == 64 && this.j()
  574.             } else {
  575.                 this.e();
  576.                 this.mode == 8 && this.e()
  577.             }
  578.         }
  579.     };
  580.     E.prototype.k = function () {
  581.         var b = g.getPlayfieldX(this.pos[1] + this.posDelta[1]),
  582.             c = g.getPlayfieldY(this.pos[0] + this.posDelta[0]);
  583.         if (this.elPos[0] != c || this.elPos[1] != b) {
  584.             this.elPos[0] = c;
  585.             this.elPos[1] = b;
  586.             this.el.style.left = b + "px";
  587.             this.el.style.top = c + "px"
  588.         }
  589.     };
  590.     E.prototype.s = function () {
  591.         var b = 0,
  592.             c = 0,
  593.             d = this.dir;
  594.         if (d == 0) d = this.lastActiveDir;
  595.         if (g.gameplayMode == 1 && this.id == g.playerEatingGhostId) {
  596.             b = 3;
  597.             c = 0
  598.         } else if ((g.gameplayMode == 9 || g.gameplayMode == 10) && this.id == 0) {
  599.             b = 2;
  600.             c = 0
  601.         } else if (g.gameplayMode == 4 || g.gameplayMode == 5 || g.gameplayMode == 7) {
  602.             b = this.id == 0 ? 2 : 4;
  603.             c = 0
  604.         } else if (g.gameplayMode == 3) if (this.id == g.playerDyingId) {
  605.             d = 20 - Math.floor(g.gameplayModeTime / g.timing[4] * 21);
  606.             if (this.id == 0) {
  607.                 b = d - 1;
  608.                 switch (b) {
  609.                 case -1:
  610.                     b = 0;
  611.                     break;
  612.                 case 11:
  613.                     b = 10;
  614.                     break;
  615.                 case 12:
  616.                 case 13:
  617.                 case 14:
  618.                 case 15:
  619.                 case 16:
  620.                 case 17:
  621.                 case 18:
  622.                 case 19:
  623.                 case 20:
  624.                     b =
  625.                     11;
  626.                     break
  627.                 }
  628.                 c = 12
  629.             } else switch (d) {
  630.             case 0:
  631.             case 1:
  632.             case 2:
  633.             case 6:
  634.             case 10:
  635.                 b = 4;
  636.                 c = 3;
  637.                 break;
  638.             case 3:
  639.             case 7:
  640.             case 11:
  641.                 b = 4;
  642.                 c = 0;
  643.                 break;
  644.             case 4:
  645.             case 8:
  646.             case 12:
  647.             case 13:
  648.             case 14:
  649.             case 15:
  650.             case 16:
  651.             case 17:
  652.             case 18:
  653.             case 19:
  654.             case 20:
  655.                 b = 4;
  656.                 c = 2;
  657.                 break;
  658.             case 5:
  659.             case 9:
  660.                 b = 4;
  661.                 c = 1;
  662.                 break
  663.             }
  664.         } else {
  665.             b = 3;
  666.             c = 0
  667.         } else if (this.el.id == "pcm-bpcm") {
  668.             b = 14;
  669.             c = 0;
  670.             d = Math.floor(g.globalTime * 0.2) % 4;
  671.             if (d == 3) d = 1;
  672.             c += 2 * d
  673.         } else {
  674.             switch (d) {
  675.             case 4:
  676.                 c = 0;
  677.                 break;
  678.             case 8:
  679.                 c = 1;
  680.                 break;
  681.             case 1:
  682.                 c = 2;
  683.                 break;
  684.             case 2:
  685.                 c = 3;
  686.                 break
  687.             }
  688.             if (g.gameplayMode != 2) b = Math.floor(g.globalTime * 0.3) % 4;
  689.             if (b == 3 && this.dir == 0) b = 0;
  690.             if (b == 2 && this.id == 0) b = 0;
  691.             if (b == 3) {
  692.                 b = 2;
  693.                 if (this.id == 0) c = 0
  694.             }
  695.             if (this.id == 1) b += 4
  696.         }
  697.         return [c, b]
  698.     };
  699.     E.prototype.r = function () {
  700.         var b = 0,
  701.             c = 0;
  702.         if (g.gameplayMode == 10 || g.gameplayMode == 4 || g.gameplayMode == 3) {
  703.             b = 3;
  704.             c = 0
  705.         } else if (g.gameplayMode == 1 && this.id == g.ghostBeingEatenId) {
  706.             switch (g.modeScoreMultiplier) {
  707.             case 2:
  708.                 b = 0;
  709.                 break;
  710.             case 4:
  711.                 b = 1;
  712.                 break;
  713.             case 8:
  714.                 b = 2;
  715.                 break;
  716.             case 16:
  717.                 b = 3;
  718.                 break
  719.             }
  720.             c = 11;
  721.             this.el.className = "pcm-ac pcm-n"
  722.         } else if (this.mode == 4 || (this.mode == 16 || this.mode == 32) && g.mainGhostMode == 4 && !this.eatenInThisFrightMode) {
  723.             b = 0;
  724.             c = 8;
  725.             if (g.frightModeTime < g.levels.frightTotalTime - g.levels.frightTime && Math.floor(g.frightModeTime / g.timing[1]) % 2 == 0) b += 2;
  726.             b += Math.floor(g.globalTime / 16) % 2
  727.         } else if (this.mode == 8 || this.mode == 64) {
  728.             c = this.nextDir;
  729.             if (!c) c = this.dir;
  730.             switch (c) {
  731.             case 4:
  732.                 b = 2;
  733.                 break;
  734.             case 8:
  735.                 b = 3;
  736.                 break;
  737.             case 1:
  738.                 b = 0;
  739.                 break;
  740.             case 2:
  741.                 b = 1;
  742.                 break
  743.             }
  744.             c = 10
  745.         } else if (this.el.id == "pcm-ghin") {
  746.             b = 6;
  747.             c = 8;
  748.             b += Math.floor(g.globalTime / 16) % 2
  749.         } else if (this.el.id == "pcm-gbug") {
  750.             b = 6;
  751.             c = 9;
  752.             c += Math.floor(g.globalTime / 16) % 2
  753.         } else if (this.el.id == "pcm-ghfa") {
  754.             b = g.cutsceneSequenceId == 3 ? 6 : 7;
  755.             c = 11
  756.         } else if (this.el.id == "pcm-stck") {
  757.             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;
  758.             c = 13
  759.         } else {
  760.             c = this.nextDir;
  761.             if (!c || g.playfield[this.tilePos[0]][this.tilePos[1]].type == 1) c = this.dir;
  762.             switch (c) {
  763.             case 4:
  764.                 b = 4;
  765.                 break;
  766.             case 8:
  767.                 b = 6;
  768.                 break;
  769.             case 1:
  770.                 b = 0;
  771.                 break;
  772.             case 2:
  773.                 b = 2;
  774.                 break
  775.             }
  776.             c = 4 + this.id - g.playerCount;
  777.             if (this.speed > 0 || g.gameplayMode != 13) b += Math.floor(g.globalTime / 16) % 2
  778.         }
  779.         return [c, b]
  780.     };
  781.     E.prototype.b = function () {
  782.         this.k();
  783.         var b = [0, 0];
  784.         b = g.gameplayMode == 8 || g.gameplayMode == 14 ? [0, 3] : this.ghost ? this.r() : this.s();
  785.         if (this.elBackgroundPos[0] != b[0] || this.elBackgroundPos[1] != b[1]) {
  786.             this.elBackgroundPos[0] = b[0];
  787.             this.elBackgroundPos[1] = b[1];
  788.             b[0] *= 16;
  789.             b[1] *= 16;
  790.             g.changeElementBkPos(this.el, b[1], b[0], a)
  791.         }
  792.     };
  793.     g.rand = function () {
  794.         var b = 4294967296,
  795.             c = 134775813;
  796.         c = c * g.randSeed + 1;
  797.         return (g.randSeed = c % b) / b
  798.     };
  799.     g.seed = function (b) {
  800.         g.randSeed = b
  801.     };
  802.     g.getDistance = function (b, c) {
  803.         return Math.sqrt((c[1] - b[1]) * (c[1] - b[1]) + (c[0] - b[0]) * (c[0] - b[0]))
  804.     };
  805.     g.getPlayfieldX = function (b) {
  806.         return b + -32
  807.     };
  808.     g.getPlayfieldY = function (b) {
  809.         return b + 0
  810.     };
  811.     g.getCorrectedSpritePos = function (b) {
  812.         return b / 8 * 10 + 2
  813.     };
  814.     g.getDotElementId = function (b, c) {
  815.         return "pcm-d" + b + "-" + c
  816.     };
  817.     g.showElementById = function (b, c) {
  818.         var d = document.getElementById(b);
  819.         if (d) d.style.visibility = c ? "visible" : "hidden"
  820.     };
  821.     g.getAbsoluteElPos = function (b) {
  822.         var c = [0, 0];
  823.         do {
  824.             c[0] += b.offsetTop;
  825.             c[1] += b.offsetLeft
  826.         } while (b = b.offsetParent);
  827.         return c
  828.     };
  829.     g.prepareElement = function (b, c, d) {
  830.         c = g.getCorrectedSpritePos(parseInt(c, 10));
  831.         d = g.getCorrectedSpritePos(parseInt(d, 10));
  832.         if (g.useCss) {
  833.             b.style.backgroundImage = "url(/logos/pacman10-hp-sprite.png)";
  834.             b.style.backgroundPosition = -c + "px " + -d + "px";
  835.             b.style.backgroundRepeat = "no-repeat"
  836.         } else {
  837.             b.style.overflow = "hidden";
  838.             c = "display: block; position: relative; left: " + -c + "px; top: " + -d + "px";
  839.             b.innerHTML = '<img style="' + c + '" src="/logos/pacman10-hp-sprite.png">'
  840.         }
  841.     };
  842.     g.changeElementBkPos = function (b, c, d, f) {
  843.         if (f) {
  844.             c = g.getCorrectedSpritePos(c);
  845.             d = g.getCorrectedSpritePos(d)
  846.         }
  847.         if (g.useCss) b.style.backgroundPosition = -c + "px " + -d + "px";
  848.         else if (b.childNodes[0]) {
  849.             b.childNodes[0].style.left = -c + "px";
  850.             b.childNodes[0].style.top = -d + "px"
  851.         }
  852.     };
  853.     g.determinePlayfieldDimensions = function () {
  854.         g.playfieldWidth = 0;
  855.         g.playfieldHeight = 0;
  856.         for (var b in n) {
  857.             var c = n[b];
  858.             if (c.w) {
  859.                 c = c.x + c.w - 1;
  860.                 if (c > g.playfieldWidth) g.playfieldWidth = c
  861.             } else {
  862.                 c = c.y + c.h - 1;
  863.                 if (c > g.playfieldHeight) g.playfieldHeight = c
  864.             }
  865.         }
  866.     };
  867.     g.preparePlayfield = function () {
  868.         g.playfield = [];
  869.         for (var b = 0; b <= g.playfieldHeight + 1; b++) {
  870.             g.playfield[b * 8] = [];
  871.             for (var c = -2; c <= g.playfieldWidth + 1; c++) g.playfield[b * 8][c * 8] = {
  872.                 path: 0,
  873.                 dot: 0,
  874.                 intersection: 0
  875.             }
  876.         }
  877.     };
  878.     g.preparePaths = function () {
  879.         for (var b in n) {
  880.             var c = n[b],
  881.                 d = c.type;
  882.             if (c.w) {
  883.                 for (var f = c.y * 8, h = c.x * 8; h <= (c.x + c.w - 1) * 8; h += 8) {
  884.                     g.playfield[f][h].path = a;
  885.                     if (g.playfield[f][h].dot == 0) {
  886.                         g.playfield[f][h].dot = 1;
  887.                         g.dotsRemaining++
  888.                     }
  889.                     g.playfield[f][h].type = !d || h != c.x * 8 && h != (c.x + c.w - 1) * 8 ? d : 0
  890.                 }
  891.                 g.playfield[f][c.x * 8].intersection = a;
  892.                 g.playfield[f][(c.x + c.w - 1) * 8].intersection = a
  893.             } else {
  894.                 h = c.x * 8;
  895.                 for (f = c.y * 8; f <= (c.y + c.h - 1) * 8; f += 8) {
  896.                     if (g.playfield[f][h].path) g.playfield[f][h].intersection = a;
  897.                     g.playfield[f][h].path = a;
  898.                     if (g.playfield[f][h].dot == 0) {
  899.                         g.playfield[f][h].dot = 1;
  900.                         g.dotsRemaining++
  901.                     }
  902.                     g.playfield[f][h].type = !d || f != c.y * 8 && f != (c.y + c.h - 1) * 8 ? d : 0
  903.                 }
  904.                 g.playfield[c.y * 8][h].intersection = a;
  905.                 g.playfield[(c.y + c.h - 1) * 8][h].intersection = a
  906.             }
  907.         }
  908.         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) {
  909.             g.playfield[o[b].y * 8][h].dot = 0;
  910.             g.dotsRemaining--
  911.         } else for (f = o[b].y * 8; f <= (o[b].y + o[b].h - 1) * 8; f += 8) {
  912.             g.playfield[f][o[b].x * 8].dot = 0;
  913.             g.dotsRemaining--
  914.         }
  915.     };
  916.     g.prepareAllowedDirections = function () {
  917.         for (var b = 8; b <= g.playfieldHeight * 8; b += 8) for (var c = 8; c <= g.playfieldWidth * 8; c += 8) {
  918.             g.playfield[b][c].allowedDir = 0;
  919.             if (g.playfield[b - 8][c].path) g.playfield[b][c].allowedDir += 1;
  920.             if (g.playfield[b + 8][c].path) g.playfield[b][c].allowedDir += 2;
  921.             if (g.playfield[b][c - 8].path) g.playfield[b][c].allowedDir += 4;
  922.             if (g.playfield[b][c + 8].path) g.playfield[b][c].allowedDir += 8
  923.         }
  924.     };
  925.     g.createDotElements = function () {
  926.         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) {
  927.             var d = document.createElement("div");
  928.             d.className = "pcm-d";
  929.             d.id = g.getDotElementId(b, c);
  930.             d.style.left = c + -32 + "px";
  931.             d.style.top = b + 0 + "px";
  932.             g.playfieldEl.appendChild(d)
  933.         }
  934.     };
  935.     g.createEnergizerElements = function () {
  936.         for (var b in p) {
  937.             var c = p[b],
  938.                 d = g.getDotElementId(c.y * 8, c.x * 8);
  939.             document.getElementById(d).className = "pcm-e";
  940.             g.prepareElement(document.getElementById(d), 0, 144);
  941.             g.playfield[c.y * 8][c.x * 8].dot = 2
  942.         }
  943.     };
  944.     g.createFruitElement = function () {
  945.         g.fruitEl = document.createElement("div");
  946.         g.fruitEl.id = "pcm-f";
  947.         g.fruitEl.style.left = g.getPlayfieldX(v[1]) + "px";
  948.         g.fruitEl.style.top = g.getPlayfieldY(v[0]) + "px";
  949.         g.prepareElement(g.fruitEl, -32, -16);
  950.         g.playfieldEl.appendChild(g.fruitEl)
  951.     };
  952.     g.createPlayfieldElements = function () {
  953.         g.doorEl = document.createElement("div");
  954.         g.doorEl.id = "pcm-do";
  955.         g.doorEl.style.display = "none";
  956.         g.playfieldEl.appendChild(g.doorEl);
  957.         g.createDotElements();
  958.         g.createEnergizerElements();
  959.         g.createFruitElement()
  960.     };
  961.     g.createActors = function () {
  962.         g.actors = [];
  963.         for (var b = 0; b < g.playerCount + 4; b++) {
  964.             g.actors[b] = new E(b);
  965.             if (b < g.playerCount) {
  966.                 g.actors[b].ghost = e;
  967.                 g.actors[b].mode = 1
  968.             } else g.actors[b].ghost = a
  969.         }
  970.     };
  971.     g.restartActors = function () {
  972.         for (var b in g.actors) g.actors[b].A()
  973.     };
  974.     g.createActorElements = function () {
  975.         for (var b in g.actors) g.actors[b].createElement()
  976.     };
  977.     g.createPlayfield = function () {
  978.         g.playfieldEl = document.createElement("div");
  979.         g.playfieldEl.id = "pcm-p";
  980.         g.canvasEl.appendChild(g.playfieldEl)
  981.     };
  982.     g.resetPlayfield = function () {
  983.         g.dotsRemaining = 0;
  984.         g.dotsEaten = 0;
  985.         g.playfieldEl.innerHTML = "";
  986.         g.prepareElement(g.playfieldEl, 256, 0);
  987.         g.determinePlayfieldDimensions();
  988.         g.preparePlayfield();
  989.         g.preparePaths();
  990.         g.prepareAllowedDirections();
  991.         g.createPlayfieldElements();
  992.         g.createActorElements()
  993.     };
  994.     g.keyPressed = function (b) {
  995.         var c = e;
  996.         switch (b) {
  997.         case 37:
  998.             g.actors[0].requestedDir = 4;
  999.             c = a;
  1000.             break;
  1001.         case 38:
  1002.             g.actors[0].requestedDir = 1;
  1003.             c = a;
  1004.             break;
  1005.         case 39:
  1006.             g.actors[0].requestedDir = 8;
  1007.             c = a;
  1008.             break;
  1009.         case 40:
  1010.             g.actors[0].requestedDir = 2;
  1011.             c = a;
  1012.             break;
  1013.         case 65:
  1014.             if (g.playerCount == 2) {
  1015.                 g.actors[1].requestedDir = 4;
  1016.                 c = a
  1017.             }
  1018.             break;
  1019.         case 83:
  1020.             if (g.playerCount == 2) {
  1021.                 g.actors[1].requestedDir = 2;
  1022.                 c = a
  1023.             }
  1024.             break;
  1025.         case 68:
  1026.             if (g.playerCount == 2) {
  1027.                 g.actors[1].requestedDir = 8;
  1028.                 c = a
  1029.             }
  1030.             break;
  1031.         case 87:
  1032.             if (g.playerCount == 2) {
  1033.                 g.actors[1].requestedDir = 1;
  1034.                 c = a
  1035.             }
  1036.             break
  1037.         }
  1038.         return c
  1039.     };
  1040.     g.handleKeyDown = function (b) {
  1041.         if (!b) b = window.event;
  1042.         if (g.keyPressed(b.keyCode)) if (b.preventDefault) b.preventDefault();
  1043.         else b.returnValue = e
  1044.     };
  1045.     g.canvasClicked = function (b, c) {
  1046.         var d = g.getAbsoluteElPos(g.canvasEl);
  1047.         b -= d[1] - -32;
  1048.         c -= d[0] - 0;
  1049.         d = g.actors[0];
  1050.         var f = g.getPlayfieldX(d.pos[1] + d.posDelta[1]) + 16,
  1051.             h = g.getPlayfieldY(d.pos[0] + d.posDelta[0]) + 32,
  1052.             j = Math.abs(b - f),
  1053.             k = Math.abs(c - h);
  1054.         if (j > 8 && k < j) d.requestedDir = b > f ? 8 : 4;
  1055.         else if (k > 8 && j < k) d.requestedDir = c > h ? 2 : 1
  1056.     };
  1057.     g.handleClick = function (b) {
  1058.         if (!b) b = window.event;
  1059.         g.canvasClicked(b.clientX, b.clientY)
  1060.     };
  1061.     g.registerTouch = function () {
  1062.         document.body.addEventListener("touchstart", g.handleTouchStart, a);
  1063.         g.canvasEl.addEventListener("touchstart", g.handleTouchStart, a);
  1064.         document.f && document.f.q && document.f.q.addEventListener("touchstart", g.handleTouchStart, a)
  1065.     };
  1066.     g.handleTouchStart = function (b) {
  1067.         g.touchDX = 0;
  1068.         g.touchDY = 0;
  1069.         if (b.touches.length == 1) {
  1070.             g.touchStartX = b.touches[0].pageX;
  1071.             g.touchStartY = b.touches[0].pageY;
  1072.             document.body.addEventListener("touchmove", g.handleTouchMove, a);
  1073.             document.body.addEventListener("touchend", g.handleTouchEnd, a)
  1074.         }
  1075.         b.preventDefault();
  1076.         b.stopPropagation()
  1077.     };
  1078.     g.handleTouchMove = function (b) {
  1079.         if (b.touches.length > 1) g.cancelTouch();
  1080.         else {
  1081.             g.touchDX = b.touches[0].pageX - g.touchStartX;
  1082.             g.touchDY = b.touches[0].pageY - g.touchStartY
  1083.         }
  1084.         b.preventDefault();
  1085.         b.stopPropagation()
  1086.     };
  1087.     g.handleTouchEnd = function (b) {
  1088.         if (g.touchDX == 0 && g.touchDY == 0) g.canvasClicked(g.touchStartX, g.touchStartY);
  1089.         else {
  1090.             var c = Math.abs(g.touchDX),
  1091.                 d = Math.abs(g.touchDY);
  1092.             if (c < 8 && d < 8) g.canvasClicked(g.touchStartX, g.touchStartY);
  1093.             else if (c > 15 && d < c * 2 / 3) g.actors[0].requestedDir = g.touchDX > 0 ? 8 : 4;
  1094.             else if (d > 15 && c < d * 2 / 3) g.actors[0].requestedDir = g.touchDY > 0 ? 2 : 1
  1095.         }
  1096.         b.preventDefault();
  1097.         b.stopPropagation();
  1098.         g.cancelTouch()
  1099.     };
  1100.     g.cancelTouch = function () {
  1101.         document.body.removeEventListener("touchmove", g.handleTouchMove, a);
  1102.         document.body.removeEventListener("touchend", g.handleTouchEnd, a);
  1103.         g.touchStartX = null;
  1104.         g.touchStartY = null
  1105.     };
  1106.     g.addEventListeners = function () {
  1107.         if (window.addEventListener) {
  1108.             window.addEventListener("keydown", g.handleKeyDown, e);
  1109.             g.canvasEl.addEventListener("click", g.handleClick, e);
  1110.             g.registerTouch()
  1111.         } else {
  1112.             document.body.attachEvent("onkeydown", g.handleKeyDown);
  1113.             g.canvasEl.attachEvent("onclick", g.handleClick)
  1114.         }
  1115.     };
  1116.     g.startGameplay = function () {
  1117.         g.score = [0, 0];
  1118.         g.extraLifeAwarded = [e, e];
  1119.         g.lives = 3;
  1120.         g.level = 0;
  1121.         g.paused = e;
  1122.         g.globalTime = 0;
  1123.         g.newLevel(a)
  1124.     };
  1125.     g.restartGameplay = function (b) {
  1126.         g.seed(0);
  1127.         g.frightModeTime = 0;
  1128.         g.intervalTime = 0;
  1129.         g.gameplayModeTime = 0;
  1130.         g.fruitTime = 0;
  1131.         g.ghostModeSwitchPos = 0;
  1132.         g.ghostModeTime = g.levels.ghostModeSwitchTimes[0] * D;
  1133.         g.ghostExitingPenNow = e;
  1134.         g.ghostEyesCount = 0;
  1135.         g.tilesChanged = e;
  1136.         g.updateCruiseElroySpeed();
  1137.         g.hideFruit();
  1138.         g.resetForcePenLeaveTime();
  1139.         g.restartActors();
  1140.         g.updateActorPositions();
  1141.         g.switchMainGhostMode(2, a);
  1142.         for (var c = g.playerCount + 1; c < g.playerCount + 4; c++) g.actors[c].a(16);
  1143.         g.dotEatingChannel = [0, 0];
  1144.         g.dotEatingSoundPart = [1, 1];
  1145.         g.clearDotEatingNow();
  1146.         b ? g.changeGameplayMode(4) : g.changeGameplayMode(6)
  1147.     };
  1148.     g.initiateDoubleMode = function () {
  1149.         if (g.playerCount != 2) {
  1150.             g.stopAllAudio();
  1151.             g.changeGameplayMode(12)
  1152.         }
  1153.     };
  1154.     g.newGame = function () {
  1155.         g.playerCount = 1;
  1156.         g.createChrome();
  1157.         g.createPlayfield();
  1158.         g.createActors();
  1159.         g.startGameplay()
  1160.     };
  1161.     g.switchToDoubleMode = function () {
  1162.         g.playerCount = 2;
  1163.         g.createChrome();
  1164.         g.createPlayfield();
  1165.         g.createActors();
  1166.         g.startGameplay()
  1167.     };
  1168.     g.insertCoin = function () {
  1169.         g.gameplayMode == 8 || g.gameplayMode == 14 ? g.newGame() : g.initiateDoubleMode()
  1170.     };
  1171.     g.createKillScreenElement = function (b, c, d, f, h) {
  1172.         var j = document.createElement("div");
  1173.         j.style.left = b + "px";
  1174.         j.style.top = c + "px";
  1175.         j.style.width = d + "px";
  1176.         j.style.height = f + "px";
  1177.         j.style.zIndex = 119;
  1178.         if (h) {
  1179.             j.style.background = "url(/logos/pacman10-hp-sprite.png) -" + g.killScreenTileX + "px -" + g.killScreenTileY + "px no-repeat";
  1180.             g.killScreenTileY += 8
  1181.         } else j.style.background = "black";
  1182.         g.playfieldEl.appendChild(j)
  1183.     };
  1184.     g.killScreen = function () {
  1185.         g.seed(0);
  1186.         g.canvasEl.style.visibility = "";
  1187.         g.createKillScreenElement(272, 0, 200, 80, e);
  1188.         g.createKillScreenElement(280, 80, 192, 56, e);
  1189.         g.killScreenTileX = 80;
  1190.         g.killScreenTileY = 0;
  1191.         for (var b = 280; b <= 472; b += 8) for (var c = 0; c <= 136; c += 8) {
  1192.             if (g.rand() < 0.03) {
  1193.                 g.killScreenTileX = Math.floor(g.rand() * 25) * 10;
  1194.                 g.killScreenTileY = Math.floor(g.rand() * 2) * 10
  1195.             }
  1196.             g.createKillScreenElement(b, c, 8, 8, a)
  1197.         }
  1198.         g.changeGameplayMode(14)
  1199.     };
  1200.     g.newLevel = function (b) {
  1201.         g.level++;
  1202.         g.levels = g.level >= z.length ? z[z.length - 1] : z[g.level];
  1203.         g.levels.frightTime = Math.round(g.levels.frightTime * D);
  1204.         g.levels.frightTotalTime = g.levels.frightTime + g.timing[1] * (g.levels.frightBlinkCount * 2 - 1);
  1205.         for (var c in g.actors) g.actors[c].dotCount = 0;
  1206.         g.alternatePenLeavingScheme = e;
  1207.         g.lostLifeOnThisLevel = e;
  1208.         g.updateChrome();
  1209.         g.resetPlayfield();
  1210.         g.restartGameplay(b);
  1211.         g.level == 256 && g.killScreen()
  1212.     };
  1213.     g.newLife = function () {
  1214.         g.lostLifeOnThisLevel = a;
  1215.         g.alternatePenLeavingScheme = a;
  1216.         g.alternateDotCount = 0;
  1217.         g.lives--;
  1218.         g.updateChromeLives();
  1219.         g.lives == -1 ? g.changeGameplayMode(8) : g.restartGameplay(e)
  1220.     };
  1221.     g.switchMainGhostMode = function (b, c) {
  1222.         if (b == 4 && g.levels.frightTime == 0) for (var d in g.actors) {
  1223.             var f = g.actors[d];
  1224.             if (f.ghost) f.reverseDirectionsNext = a
  1225.         } else {
  1226.             f = g.mainGhostMode;
  1227.             if (b == 4 && g.mainGhostMode != 4) g.lastMainGhostMode = g.mainGhostMode;
  1228.             g.mainGhostMode = b;
  1229.             if (b == 4 || f == 4) g.playAmbientSound();
  1230.             switch (b) {
  1231.             case 1:
  1232.             case 2:
  1233.                 g.currentPlayerSpeed = g.levels.playerSpeed * 0.8;
  1234.                 g.currentDotEatingSpeed = g.levels.dotEatingSpeed * 0.8;
  1235.                 break;
  1236.             case 4:
  1237.                 g.currentPlayerSpeed = g.levels.playerFrightSpeed * 0.8;
  1238.                 g.currentDotEatingSpeed = g.levels.dotEatingFrightSpeed * 0.8;
  1239.                 g.frightModeTime = g.levels.frightTotalTime;
  1240.                 g.modeScoreMultiplier = 1;
  1241.                 break
  1242.             }
  1243.             for (d in g.actors) {
  1244.                 f = g.actors[d];
  1245.                 if (f.ghost) {
  1246.                     if (b != 64 && !c) f.modeChangedWhileInPen = a;
  1247.                     if (b == 4) f.eatenInThisFrightMode = e;
  1248.                     if (f.mode != 8 && f.mode != 16 && f.mode != 32 && f.mode != 128 && f.mode != 64 || c) {
  1249.                         if (!c && f.mode != 4 && f.mode != b) f.reverseDirectionsNext = a;
  1250.                         f.a(b)
  1251.                     }
  1252.                 } else {
  1253.                     f.fullSpeed = g.currentPlayerSpeed;
  1254.                     f.dotEatingSpeed = g.currentDotEatingSpeed;
  1255.                     f.tunnelSpeed = g.currentPlayerSpeed;
  1256.                     f.d()
  1257.                 }
  1258.             }
  1259.         }
  1260.     };
  1261.     g.figureOutPenLeaving = function () {
  1262.         if (g.alternatePenLeavingScheme) {
  1263.             g.alternateDotCount++;
  1264.             switch (g.alternateDotCount) {
  1265.             case m[1]:
  1266.                 g.actors[g.playerCount + 1].freeToLeavePen = a;
  1267.                 break;
  1268.             case m[2]:
  1269.                 g.actors[g.playerCount + 2].freeToLeavePen = a;
  1270.                 break;
  1271.             case m[3]:
  1272.                 if (g.actors[g.playerCount + 3].mode == 16) g.alternatePenLeavingScheme = e;
  1273.                 break
  1274.             }
  1275.         } else if (g.actors[g.playerCount + 1].mode == 16 || g.actors[g.playerCount + 1].mode == 8) {
  1276.             g.actors[g.playerCount + 1].dotCount++;
  1277.             if (g.actors[g.playerCount + 1].dotCount >= g.levels.penLeavingLimits[1]) g.actors[g.playerCount + 1].freeToLeavePen = a
  1278.         } else if (g.actors[g.playerCount + 2].mode == 16 || g.actors[g.playerCount + 2].mode == 8) {
  1279.             g.actors[g.playerCount + 2].dotCount++;
  1280.             if (g.actors[g.playerCount + 2].dotCount >= g.levels.penLeavingLimits[2]) g.actors[g.playerCount + 2].freeToLeavePen = a
  1281.         } else if (g.actors[g.playerCount + 3].mode == 16 || g.actors[g.playerCount + 3].mode == 8) {
  1282.             g.actors[g.playerCount + 3].dotCount++;
  1283.             if (g.actors[g.playerCount + 3].dotCount >= g.levels.penLeavingLimits[3]) g.actors[g.playerCount + 3].freeToLeavePen = a
  1284.         }
  1285.     };
  1286.     g.resetForcePenLeaveTime = function () {
  1287.         g.forcePenLeaveTime = g.levels.penForceTime * D
  1288.     };
  1289.     g.dotEaten = function (b, c) {
  1290.         g.dotsRemaining--;
  1291.         g.dotsEaten++;
  1292.         g.actors[b].c(1);
  1293.         g.playDotEatingSound(b);
  1294.         if (g.playfield[c[0]][c[1]].dot == 2) {
  1295.             g.switchMainGhostMode(4, e);
  1296.             g.addToScore(50, b)
  1297.         } else g.addToScore(10, b);
  1298.         var d = document.getElementById(g.getDotElementId(c[0], c[1]));
  1299.         d.style.display = "none";
  1300.         g.playfield[c[0]][c[1]].dot = 0;
  1301.         g.updateCruiseElroySpeed();
  1302.         g.resetForcePenLeaveTime();
  1303.         g.figureOutPenLeaving();
  1304.         if (g.dotsEaten == 70 || g.dotsEaten == 170) g.showFruit();
  1305.         g.dotsRemaining == 0 && g.finishLevel();
  1306.         g.playAmbientSound()
  1307.     };
  1308.     g.getFruitSprite = function (b) {
  1309.         var c = b <= 4 ? 128 : 160;
  1310.         b = 128 + 16 * ((b - 1) % 4);
  1311.         return [c, b]
  1312.     };
  1313.     g.getFruitScoreSprite = function (b) {
  1314.         var c = 128;
  1315.         b = 16 * (b - 1);
  1316.         return [c, b]
  1317.     };
  1318.     g.hideFruit = function () {
  1319.         g.fruitShown = e;
  1320.         g.changeElementBkPos(g.fruitEl, 32, 16, a)
  1321.     };
  1322.     g.showFruit = function () {
  1323.         g.fruitShown = a;
  1324.         var b = g.getFruitSprite(g.levels.fruit);
  1325.         g.changeElementBkPos(g.fruitEl, b[0], b[1], a);
  1326.         g.fruitTime = g.timing[15] + (g.timing[16] - g.timing[15]) * g.rand()
  1327.     };
  1328.     g.eatFruit = function (b) {
  1329.         if (g.fruitShown) {
  1330.             g.playSound("fruit", 0);
  1331.             g.fruitShown = e;
  1332.             var c = g.getFruitScoreSprite(g.levels.fruit);
  1333.             g.changeElementBkPos(g.fruitEl, c[0], c[1], a);
  1334.             g.fruitTime = g.timing[14];
  1335.             g.addToScore(g.levels.fruitScore, b)
  1336.         }
  1337.     };
  1338.     g.updateActorTargetPositions = function () {
  1339.         for (var b = g.playerCount; b < g.playerCount + 4; b++) g.actors[b].B()
  1340.     };
  1341.     g.moveActors = function () {
  1342.         for (var b in g.actors) g.actors[b].move()
  1343.     };
  1344.     g.ghostDies = function (b, c) {
  1345.         g.playSound("eating-ghost", 0);
  1346.         g.addToScore(200 * g.modeScoreMultiplier, c);
  1347.         g.modeScoreMultiplier *= 2;
  1348.         g.ghostBeingEatenId = b;
  1349.         g.playerEatingGhostId = c;
  1350.         g.changeGameplayMode(1)
  1351.     };
  1352.     g.playerDies = function (b) {
  1353.         g.playerDyingId = b;
  1354.         g.changeGameplayMode(2)
  1355.     };
  1356.     g.detectCollisions = function () {
  1357.         g.tilesChanged = e;
  1358.         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) {
  1359.             g.ghostDies(b, c);
  1360.             return
  1361.         } 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)
  1362.     };
  1363.     g.updateCruiseElroySpeed = function () {
  1364.         var b = g.levels.ghostSpeed * 0.8;
  1365.         if (!g.lostLifeOnThisLevel || g.actors[g.playerCount + 3].mode != 16) {
  1366.             var c = g.levels;
  1367.             if (g.dotsRemaining < c.elroyDotsLeftPart2) b = c.elroySpeedPart2 * 0.8;
  1368.             else if (g.dotsRemaining < c.elroyDotsLeftPart1) b = c.elroySpeedPart1 * 0.8
  1369.         }
  1370.         if (b != g.cruiseElroySpeed) {
  1371.             g.cruiseElroySpeed = b;
  1372.             g.actors[g.playerCount].d()
  1373.         }
  1374.     };
  1375.     g.getSpeedIntervals = function (b) {
  1376.         if (!g.speedIntervals[b]) {
  1377.             var c = 0,
  1378.                 d = 0;
  1379.             g.speedIntervals[b] = [];
  1380.             for (var f = 0; f < D; f++) {
  1381.                 c += b;
  1382.                 if (Math.floor(c) > d) {
  1383.                     g.speedIntervals[b].push(a);
  1384.                     d = Math.floor(c)
  1385.                 } else g.speedIntervals[b].push(e)
  1386.             }
  1387.         }
  1388.         return g.speedIntervals[b]
  1389.     };
  1390.     g.finishLevel = function () {
  1391.         g.changeGameplayMode(9)
  1392.     };
  1393.     g.changeGameplayMode = function (b) {
  1394.         g.gameplayMode = b;
  1395.         if (b != 13) for (var c = 0; c < g.playerCount + 4; c++) g.actors[c].b();
  1396.         switch (b) {
  1397.         case 0:
  1398.             g.playAmbientSound();
  1399.             break;
  1400.         case 2:
  1401.             g.stopAllAudio();
  1402.             g.gameplayModeTime = g.timing[3];
  1403.             break;
  1404.         case 3:
  1405.             g.playerDyingId == 0 ? g.playSound("death", 0) : g.playSound("death-double", 0);
  1406.             g.gameplayModeTime = g.timing[4];
  1407.             break;
  1408.         case 6:
  1409.             g.canvasEl.style.visibility = "hidden";
  1410.             g.gameplayModeTime = g.timing[5];
  1411.             break;
  1412.         case 7:
  1413.             g.stopAllAudio();
  1414.             g.canvasEl.style.visibility = "";
  1415.             g.doorEl.style.display = "block";
  1416.             b = document.createElement("div");
  1417.             b.id = "pcm-re";
  1418.             g.prepareElement(b, 160, 0);
  1419.             g.playfieldEl.appendChild(b);
  1420.             g.gameplayModeTime = g.timing[6];
  1421.             break;
  1422.         case 4:
  1423.             g.doorEl.style.display = "block";
  1424.             b = document.createElement("div");
  1425.             b.id = "pcm-re";
  1426.             g.prepareElement(b, 160, 0);
  1427.             g.playfieldEl.appendChild(b);
  1428.             g.gameplayModeTime = g.timing[7];
  1429.             g.stopAllAudio();
  1430.             g.playerCount == 2 ? g.playSound("start-music-double", 0, a) : g.playSound("start-music", 0, a);
  1431.             break;
  1432.         case 5:
  1433.             g.lives--;
  1434.             g.updateChromeLives();
  1435.             g.gameplayModeTime = g.timing[8];
  1436.             break;
  1437.         case 8:
  1438.         case 14:
  1439.             b = document.getElementById("pcm-re");
  1440.             google.dom.remove(b);
  1441.             g.stopAllAudio();
  1442.             b = document.createElement("div");
  1443.             b.id = "pcm-go";
  1444.             g.prepareElement(b, 8, 152);
  1445.             g.playfieldEl.appendChild(b);
  1446.             g.gameplayModeTime = g.timing[9];
  1447.             break;
  1448.         case 9:
  1449.             g.stopAllAudio();
  1450.             g.gameplayModeTime = g.timing[10];
  1451.             break;
  1452.         case 10:
  1453.             g.doorEl.style.display = "none";
  1454.             g.gameplayModeTime = g.timing[11];
  1455.             break;
  1456.         case 11:
  1457.             g.canvasEl.style.visibility = "hidden";
  1458.             g.gameplayModeTime = g.timing[12];
  1459.             break;
  1460.         case 12:
  1461.             g.playfieldEl.style.visibility = "hidden";
  1462.             g.gameplayModeTime = g.timing[13];
  1463.             break;
  1464.         case 1:
  1465.             g.gameplayModeTime =
  1466.             g.timing[2];
  1467.             break;
  1468.         case 13:
  1469.             g.startCutscene();
  1470.             break
  1471.         }
  1472.     };
  1473.     g.showChrome = function (b) {
  1474.         g.showElementById("pcm-sc-1-l", b);
  1475.         g.showElementById("pcm-sc-2-l", b);
  1476.         g.showElementById("pcm-sc-1", b);
  1477.         g.showElementById("pcm-sc-2", b);
  1478.         g.showElementById("pcm-li", b);
  1479.         g.showElementById("pcm-so", b)
  1480.     };
  1481.     g.startCutscene = function () {
  1482.         g.playfieldEl.style.visibility = "hidden";
  1483.         g.canvasEl.style.visibility = "";
  1484.         g.showChrome(e);
  1485.         g.cutsceneCanvasEl = document.createElement("div");
  1486.         g.cutsceneCanvasEl.id = "pcm-cc";
  1487.         g.canvasEl.appendChild(g.cutsceneCanvasEl);
  1488.         g.cutscene = B[g.cutsceneId];
  1489.         g.cutsceneSequenceId = -1;
  1490.         g.frightModeTime = g.levels.frightTotalTime;
  1491.         g.cutsceneActors = [];
  1492.         for (var b in g.cutscene.actors) {
  1493.             var c = g.cutscene.actors[b].id;
  1494.             if (c > 0) c += g.playerCount - 1;
  1495.             var d = document.createElement("div");
  1496.             d.className = "pcm-ac";
  1497.             d.id = "actor" + c;
  1498.             g.prepareElement(d, 0, 0);
  1499.             c = new E(c);
  1500.             c.el = d;
  1501.             c.elBackgroundPos = [0, 0];
  1502.             c.elPos = [0, 0];
  1503.             c.pos = [g.cutscene.actors[b].y * 8, g.cutscene.actors[b].x * 8];
  1504.             c.posDelta = [0, 0];
  1505.             c.ghost = g.cutscene.actors[b].ghost;
  1506.             g.cutsceneCanvasEl.appendChild(d);
  1507.             g.cutsceneActors.push(c)
  1508.         }
  1509.         g.cutsceneNextSequence();
  1510.         g.stopAllAudio();
  1511.         g.playAmbientSound()
  1512.     };
  1513.     g.stopCutscene = function () {
  1514.         g.playfieldEl.style.visibility = "";
  1515.         google.dom.remove(g.cutsceneCanvasEl);
  1516.         g.showChrome(a);
  1517.         g.newLevel(e)
  1518.     };
  1519.     g.cutsceneNextSequence = function () {
  1520.         g.cutsceneSequenceId++;
  1521.         if (g.cutscene.sequence.length == g.cutsceneSequenceId) g.stopCutscene();
  1522.         else {
  1523.             var b = g.cutscene.sequence[g.cutsceneSequenceId];
  1524.             g.cutsceneTime = b.time * D;
  1525.             for (var c in g.cutsceneActors) {
  1526.                 var d = g.cutsceneActors[c];
  1527.                 d.dir = b.moves[c].dir;
  1528.                 d.speed = b.moves[c].speed;
  1529.                 if (b.moves[c].elId) d.el.id = b.moves[c].elId;
  1530.                 if (b.moves[c].mode) d.mode = b.moves[c].mode;
  1531.                 d.b()
  1532.             }
  1533.         }
  1534.     };
  1535.     g.checkCutscene = function () {
  1536.         g.cutsceneTime <= 0 && g.cutsceneNextSequence()
  1537.     };
  1538.     g.advanceCutscene = function () {
  1539.         for (var b in g.cutsceneActors) {
  1540.             var c = g.cutsceneActors[b],
  1541.                 d = l[c.dir];
  1542.             c.pos[d.axis] += d.increment * c.speed;
  1543.             c.b()
  1544.         }
  1545.         g.cutsceneTime--
  1546.     };
  1547.     g.updateActorPositions = function () {
  1548.         for (var b in g.actors) g.actors[b].k()
  1549.     };
  1550.     g.blinkEnergizers = function () {
  1551.         switch (g.gameplayMode) {
  1552.         case 4:
  1553.         case 5:
  1554.         case 6:
  1555.         case 7:
  1556.         case 9:
  1557.         case 10:
  1558.         case 11:
  1559.         case 12:
  1560.             g.playfieldEl.className = "";
  1561.             break;
  1562.         case 8:
  1563.         case 14:
  1564.             g.playfieldEl.className = "blk";
  1565.             break;
  1566.         default:
  1567.             if (g.globalTime % (g.timing[0] * 2) == 0) g.playfieldEl.className = "";
  1568.             else if (g.globalTime % (g.timing[0] * 2) == g.timing[0]) g.playfieldEl.className = "blk";
  1569.             break
  1570.         }
  1571.     };
  1572.     g.blinkScoreLabels = function () {
  1573.         if (g.gameplayMode != 13) {
  1574.             var b = "";
  1575.             if (g.globalTime % (g.timing[17] * 2) == 0) b = "visible";
  1576.             else if (g.globalTime % (g.timing[17] * 2) == g.timing[17]) b = "hidden";
  1577.             if (b) for (var c = 0; c < g.playerCount; c++) g.scoreLabelEl[c].style.visibility = b
  1578.         }
  1579.     };
  1580.     g.finishFrightMode = function () {
  1581.         g.switchMainGhostMode(g.lastMainGhostMode, e)
  1582.     };
  1583.     g.handleGameplayModeTimer = function () {
  1584.         if (g.gameplayModeTime) {
  1585.             g.gameplayModeTime--;
  1586.             switch (g.gameplayMode) {
  1587.             case 2:
  1588.             case 3:
  1589.                 for (var b = 0; b < g.playerCount + 4; b++) g.actors[b].b();
  1590.                 break;
  1591.             case 10:
  1592.                 Math.floor(g.gameplayModeTime / (g.timing[11] / 8)) % 2 == 0 ? g.changeElementBkPos(g.playfieldEl, 322, 2, e) : g.changeElementBkPos(g.playfieldEl, 322, 138, e)
  1593.             }
  1594.             if (g.gameplayModeTime <= 0) {
  1595.                 g.gameplayModeTime = 0;
  1596.                 switch (g.gameplayMode) {
  1597.                 case 1:
  1598.                     g.changeGameplayMode(0);
  1599.                     g.ghostEyesCount++;
  1600.                     g.playAmbientSound();
  1601.                     g.actors[g.ghostBeingEatenId].el.className = "pcm-ac";
  1602.                     g.actors[g.ghostBeingEatenId].a(8);
  1603.                     var c = e;
  1604.                     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) {
  1605.                         c = a;
  1606.                         break
  1607.                     }
  1608.                     c || g.finishFrightMode();
  1609.                     break;
  1610.                 case 2:
  1611.                     g.changeGameplayMode(3);
  1612.                     break;
  1613.                 case 3:
  1614.                     g.newLife();
  1615.                     break;
  1616.                 case 4:
  1617.                     g.changeGameplayMode(5);
  1618.                     break;
  1619.                 case 6:
  1620.                     g.changeGameplayMode(7);
  1621.                     break;
  1622.                 case 7:
  1623.                 case 5:
  1624.                     b = document.getElementById("pcm-re");
  1625.                     google.dom.remove(b);
  1626.                     g.changeGameplayMode(0);
  1627.                     break;
  1628.                 case 8:
  1629.                     b = document.getElementById("pcm-go");
  1630.                     google.dom.remove(b);
  1631.                     google.pacManQuery && google.pacManQuery();
  1632.                     break;
  1633.                 case 9:
  1634.                     g.changeGameplayMode(10);
  1635.                     break;
  1636.                 case 10:
  1637.                     g.changeGameplayMode(11);
  1638.                     break;
  1639.                 case 11:
  1640.                     if (g.levels.cutsceneId) {
  1641.                         g.cutsceneId = g.levels.cutsceneId;
  1642.                         g.changeGameplayMode(13)
  1643.                     } else {
  1644.                         g.canvasEl.style.visibility = "";
  1645.                         g.newLevel(e)
  1646.                     }
  1647.                     break;
  1648.                 case 12:
  1649.                     g.playfieldEl.style.visibility = "";
  1650.                     g.canvasEl.style.visibility = "";
  1651.                     g.switchToDoubleMode();
  1652.                     break
  1653.                 }
  1654.             }
  1655.         }
  1656.     };
  1657.     g.handleFruitTimer = function () {
  1658.         if (g.fruitTime) {
  1659.             g.fruitTime--;
  1660.             g.fruitTime <= 0 && g.hideFruit()
  1661.         }
  1662.     };
  1663.     g.handleGhostModeTimer = function () {
  1664.         if (g.frightModeTime) {
  1665.             g.frightModeTime--;
  1666.             if (g.frightModeTime <= 0) {
  1667.                 g.frightModeTime = 0;
  1668.                 g.finishFrightMode()
  1669.             }
  1670.         } else if (g.ghostModeTime > 0) {
  1671.             g.ghostModeTime--;
  1672.             if (g.ghostModeTime <= 0) {
  1673.                 g.ghostModeTime = 0;
  1674.                 g.ghostModeSwitchPos++;
  1675.                 if (g.levels.ghostModeSwitchTimes[g.ghostModeSwitchPos]) {
  1676.                     g.ghostModeTime = g.levels.ghostModeSwitchTimes[g.ghostModeSwitchPos] * D;
  1677.                     switch (g.mainGhostMode) {
  1678.                     case 2:
  1679.                         g.switchMainGhostMode(1, e);
  1680.                         break;
  1681.                     case 1:
  1682.                         g.switchMainGhostMode(2, e);
  1683.                         break
  1684.                     }
  1685.                 }
  1686.             }
  1687.         }
  1688.     };
  1689.     g.handleForcePenLeaveTimer = function () {
  1690.         if (g.forcePenLeaveTime) {
  1691.             g.forcePenLeaveTime--;
  1692.             if (g.forcePenLeaveTime <= 0) {
  1693.                 for (var b = 1; b <= 3; b++) if (g.actors[g.playerCount + b].mode == 16) {
  1694.                     g.actors[g.playerCount + b].freeToLeavePen = a;
  1695.                     break
  1696.                 }
  1697.                 g.resetForcePenLeaveTime()
  1698.             }
  1699.         }
  1700.     };
  1701.     g.handleTimers = function () {
  1702.         if (g.gameplayMode == 0) {
  1703.             g.handleForcePenLeaveTimer();
  1704.             g.handleFruitTimer();
  1705.             g.handleGhostModeTimer()
  1706.         }
  1707.         g.handleGameplayModeTimer()
  1708.     };
  1709.     g.tick = function () {
  1710.         var b = (new Date).getTime();
  1711.         g.lastTimeDelta += b - g.lastTime - g.tickInterval;
  1712.         if (g.lastTimeDelta > 100) g.lastTimeDelta = 100;
  1713.         if (g.canDecreaseFps && g.lastTimeDelta > 50) {
  1714.             g.lastTimeSlownessCount++;
  1715.             g.lastTimeSlownessCount == 20 && g.decreaseFps()
  1716.         }
  1717.         var c = 0;
  1718.         if (g.lastTimeDelta > g.tickInterval) {
  1719.             c = Math.floor(g.lastTimeDelta / g.tickInterval);
  1720.             g.lastTimeDelta -= g.tickInterval * c
  1721.         }
  1722.         g.lastTime = b;
  1723.         if (g.gameplayMode == 13) {
  1724.             for (b = 0; b < g.tickMultiplier + c; b++) {
  1725.                 g.advanceCutscene();
  1726.                 g.intervalTime = (g.intervalTime + 1) % D;
  1727.                 g.globalTime++
  1728.             }
  1729.             g.checkCutscene();
  1730.             g.blinkScoreLabels()
  1731.         } else for (b = 0; b < g.tickMultiplier + c; b++) {
  1732.             g.moveActors();
  1733.             if (g.gameplayMode == 0) if (g.tilesChanged) {
  1734.                 g.detectCollisions();
  1735.                 g.updateActorTargetPositions()
  1736.             }
  1737.             g.globalTime++;
  1738.             g.intervalTime = (g.intervalTime + 1) % D;
  1739.             g.blinkEnergizers();
  1740.             g.blinkScoreLabels();
  1741.             g.handleTimers()
  1742.         }
  1743.     };
  1744.     g.extraLife = function (b) {
  1745.         g.playSound("extra-life", 0);
  1746.         g.extraLifeAwarded[b] = a;
  1747.         g.lives++;
  1748.         if (g.lives > 5) g.lives = 5;
  1749.         g.updateChromeLives()
  1750.     };
  1751.     g.addToScore = function (b, c) {
  1752.         g.score[c] += b;
  1753.         !g.extraLifeAwarded[c] && g.score[c] > 1E4 && g.extraLife(c);
  1754.         g.updateChromeScore(c)
  1755.     };
  1756.     g.updateChrome = function () {
  1757.         g.updateChromeLevel();
  1758.         g.updateChromeLives();
  1759.         for (var b = 0; b < g.playerCount; b++) g.updateChromeScore(b)
  1760.     };
  1761.     g.updateChromeScore = function (b) {
  1762.         var c = g.score[b].toString();
  1763.         if (c.length > g.scoreDigits) c = c.substr(c.length - g.scoreDigits, g.scoreDigits);
  1764.         for (var d = 0; d < g.scoreDigits; d++) {
  1765.             var f = document.getElementById("pcm-sc-" + (b + 1) + "-" + d),
  1766.                 h = c.substr(d, 1);
  1767.             h ? g.changeElementBkPos(f, 8 + 8 * parseInt(h, 10), 144, a) : g.changeElementBkPos(f, 48, 0, a)
  1768.         }
  1769.     };
  1770.     g.updateChromeLives = function () {
  1771.         g.livesEl.innerHTML = "";
  1772.         for (var b = 0; b < g.lives; b++) {
  1773.             var c = document.createElement("div");
  1774.             c.className = "pcm-lif";
  1775.             g.prepareElement(c, 64, 129);
  1776.             g.livesEl.appendChild(c)
  1777.         }
  1778.     };
  1779.     g.updateChromeLevel = function () {
  1780.         g.levelEl.innerHTML = "";
  1781.         for (var b = g.level; b >= Math.max(g.level - 4 + 1, 1); b--) {
  1782.             var c = b >= z.length ? z[z.length - 1].fruit : z[b].fruit,
  1783.                 d = document.createElement("div");
  1784.             c = g.getFruitSprite(c);
  1785.             g.prepareElement(d, c[0], c[1]);
  1786.             g.levelEl.appendChild(d)
  1787.         }
  1788.         g.levelEl.style.marginTop = (4 - Math.min(g.level, 4)) * 16 + "px"
  1789.     };
  1790.     g.createChrome = function () {
  1791.         g.canvasEl.innerHTML = "";
  1792.         g.scoreDigits = g.playerCount == 1 ? 10 : 5;
  1793.         g.scoreLabelEl = [];
  1794.         g.scoreLabelEl[0] = document.createElement("div");
  1795.         g.scoreLabelEl[0].id = "pcm-sc-1-l";
  1796.         g.prepareElement(g.scoreLabelEl[0], 160, 56);
  1797.         g.canvasEl.appendChild(g.scoreLabelEl[0]);
  1798.         g.scoreEl = [];
  1799.         g.scoreEl[0] = document.createElement("div");
  1800.         g.scoreEl[0].id = "pcm-sc-1";
  1801.         for (var b = 0; b < g.scoreDigits; b++) {
  1802.             var c = document.createElement("div");
  1803.             c.id = "pcm-sc-1-" + b;
  1804.             c.style.top = b * 8 + "px";
  1805.             c.style.left = 0;
  1806.             c.style.position = "absolute";
  1807.             c.style.width = "8px";
  1808.             c.style.height = "8px";
  1809.             g.prepareElement(c, 48, 0);
  1810.             g.scoreEl[0].appendChild(c)
  1811.         }
  1812.         g.canvasEl.appendChild(g.scoreEl[0]);
  1813.         g.livesEl = document.createElement("div");
  1814.         g.livesEl.id = "pcm-li";
  1815.         g.canvasEl.appendChild(g.livesEl);
  1816.         g.levelEl = document.createElement("div");
  1817.         g.levelEl.id = "pcm-le";
  1818.         g.canvasEl.appendChild(g.levelEl);
  1819.         if (g.playerCount == 2) {
  1820.             g.scoreLabelEl[1] = document.createElement("div");
  1821.             g.scoreLabelEl[1].id = "pcm-sc-2-l";
  1822.             g.prepareElement(g.scoreLabelEl[1], 160, 64);
  1823.             g.canvasEl.appendChild(g.scoreLabelEl[1]);
  1824.             g.scoreEl[1] = document.createElement("div");
  1825.             g.scoreEl[1].id = "pcm-sc-2";
  1826.             for (b = 0; b < g.scoreDigits; b++) {
  1827.                 c = document.createElement("div");
  1828.                 c.id = "pcm-sc-2-" + b;
  1829.                 c.style.top = b * 8 + "px";
  1830.                 c.style.left = 0;
  1831.                 c.style.position = "absolute";
  1832.                 c.style.width = "8px";
  1833.                 c.style.height = "8px";
  1834.                 g.prepareElement(c, 48, 0);
  1835.                 g.scoreEl[1].appendChild(c)
  1836.             }
  1837.             g.canvasEl.appendChild(g.scoreEl[1])
  1838.         }
  1839.     };
  1840.     g.clearDotEatingNow = function () {
  1841.         g.dotEatingNow = [e, e];
  1842.         g.dotEatingNext = [e, e]
  1843.     };
  1844.     g.playSound = function (b, c, d) {
  1845.         if (!(!g.soundAvailable || !g.soundEnabled || g.paused)) {
  1846.             d || g.stopSoundChannel(c);
  1847.             try {
  1848.                 g.flashSoundPlayer.playTrack(b, c)
  1849.             } catch (f) {
  1850.                 g.soundAvailable = e
  1851.             }
  1852.         }
  1853.     };
  1854.     g.stopSoundChannel = function (b) {
  1855.         if (g.soundAvailable && g.soundEnabled) try {
  1856.             g.flashSoundPlayer.stopChannel(b)
  1857.         } catch (c) {
  1858.             g.soundAvailable = e
  1859.         }
  1860.     };
  1861.     g.stopAllAudio = function () {
  1862.         if (g.soundAvailable && g.soundEnabled) {
  1863.             try {
  1864.                 g.flashSoundPlayer.stopAmbientTrack()
  1865.             } catch (b) {
  1866.                 g.soundAvailable = e
  1867.             }
  1868.             for (var c = 0; c < 5; c++) g.stopSoundChannel(c)
  1869.         }
  1870.     };
  1871.     g.playDotEatingSound = function (b) {
  1872.         if (g.soundAvailable && g.soundEnabled) if (g.gameplayMode == 0) if (g.dotEatingNow[b]) g.dotEatingNext[b] = a;
  1873.         else {
  1874.             if (b == 0) {
  1875.                 var c = g.dotEatingSoundPart[b] == 1 ? "eating-dot-1" : "eating-dot-2";
  1876.                 g.playSound(c, 1 + g.dotEatingChannel[b], a);
  1877.                 g.dotTimer = window.setInterval(g.repeatDotEatingSoundPacMan, 150)
  1878.             } else {
  1879.                 g.playSound("eating-dot-double", 3 + g.dotEatingChannel[b], a);
  1880.                 g.dotTimerMs = window.setInterval(g.repeatDotEatingSoundMsPacMan, 150)
  1881.             }
  1882.             g.dotEatingChannel[b] = (g.dotEatingChannel[b] + 1) % 2;
  1883.             g.dotEatingSoundPart[b] =
  1884.             3 - g.dotEatingSoundPart[b]
  1885.         }
  1886.     };
  1887.     g.repeatDotEatingSound = function (b) {
  1888.         g.dotEatingNow[b] = e;
  1889.         if (g.dotEatingNext[b]) {
  1890.             g.dotEatingNext[b] = e;
  1891.             g.playDotEatingSound(b)
  1892.         }
  1893.     };
  1894.     g.repeatDotEatingSoundPacMan = function () {
  1895.         g.repeatDotEatingSound(0)
  1896.     };
  1897.     g.repeatDotEatingSoundMsPacMan = function () {
  1898.         g.repeatDotEatingSound(1)
  1899.     };
  1900.     g.playAmbientSound = function () {
  1901.         if (g.soundAvailable && g.soundEnabled) {
  1902.             var b = 0;
  1903.             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";
  1904.             else if (g.gameplayMode == 13) b = "cutscene";
  1905.             if (b) try {
  1906.                 g.flashSoundPlayer.playAmbientTrack(b)
  1907.             } catch (c) {
  1908.                 g.soundAvailable = e
  1909.             }
  1910.         }
  1911.     };
  1912.     g.initializeTickTimer = function () {
  1913.         window.clearInterval(g.tickTimer);
  1914.         g.fps = C[g.fpsChoice];
  1915.         g.tickInterval = 1E3 / g.fps;
  1916.         g.tickMultiplier = D / g.fps;
  1917.         g.timing = {};
  1918.         for (var b in w) {
  1919.             var c = !g.soundEnabled && (b == 7 || b == 8) ? 1 : w[b];
  1920.             g.timing[b] = Math.round(c * D)
  1921.         }
  1922.         g.lastTime = (new Date).getTime();
  1923.         g.lastTimeDelta = 0;
  1924.         g.lastTimeSlownessCount = 0;
  1925.         g.tickTimer = window.setInterval(g.tick, g.tickInterval)
  1926.     };
  1927.     g.decreaseFps = function () {
  1928.         if (g.fpsChoice < C.length - 1) {
  1929.             g.fpsChoice++;
  1930.             g.initializeTickTimer();
  1931.             if (g.fpsChoice == C.length - 1) g.canDecreaseFps = e
  1932.         }
  1933.     };
  1934.     g.addCss = function () {
  1935.         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;}";
  1936.         g.styleElement =
  1937.         document.createElement("style");
  1938.         g.styleElement.type = "text/css";
  1939.         if (g.styleElement.styleSheet) g.styleElement.styleSheet.cssText = b;
  1940.         else g.styleElement.appendChild(document.createTextNode(b));
  1941.         document.getElementsByTagName("head")[0].appendChild(g.styleElement)
  1942.     };
  1943.     g.createCanvasElement = function () {
  1944.         g.canvasEl = document.createElement("div");
  1945.         g.canvasEl.id = "pcm-c";
  1946.         g.canvasEl.hideFocus = a;
  1947.         document.getElementById("logo").appendChild(g.canvasEl);
  1948.         g.canvasEl.tabIndex = 0;
  1949.         g.canvasEl.focus()
  1950.     };
  1951.     g.everythingIsReady = function () {
  1952.         if (!g.ready) {
  1953.             g.ready = a;
  1954.             var b = document.getElementById("logo-l");
  1955.             google.dom.remove(b);
  1956.             document.getElementById("logo").style.background = "black";
  1957.             g.addCss();
  1958.             g.createCanvasElement();
  1959.             g.speedIntervals = [];
  1960.             g.oppositeDirections = [];
  1961.             g.oppositeDirections[1] = 2;
  1962.             g.oppositeDirections[2] = 1;
  1963.             g.oppositeDirections[4] = 8;
  1964.             g.oppositeDirections[8] = 4;
  1965.             g.addEventListeners();
  1966.             g.fpsChoice = 0;
  1967.             g.canDecreaseFps = a;
  1968.             g.initializeTickTimer();
  1969.             g.newGame()
  1970.         }
  1971.     };
  1972.     g.checkIfEverythingIsReady = function () {
  1973.         if (g.soundReady || g.graphicsReady) g.updateLoadingProgress(0.67);
  1974.         if (g.soundReady && g.graphicsReady) {
  1975.             g.updateLoadingProgress(1);
  1976.             g.everythingIsReady()
  1977.         }
  1978.     };
  1979.     g.preloadImage = function (b) {
  1980.         var c = new Image,
  1981.             d = google.browser.engine.IE;
  1982.         if (!d) c.onload = g.imageLoaded;
  1983.         c.src = b;
  1984.         d && g.imageLoaded()
  1985.     };
  1986.     g.imageLoaded = function () {
  1987.         g.graphicsReady = a;
  1988.         g.checkIfEverythingIsReady()
  1989.     };
  1990.     g.prepareGraphics = function () {
  1991.         g.graphicsReady = e;
  1992.         g.preloadImage("/logos/pacman10-hp-sprite.png")
  1993.     };
  1994.     g.trimString = function (b) {
  1995.         return b.replace(/^[\s\xa0]+|[\s\xa0]+$/g, "")
  1996.     };
  1997.     g.g = function (b, c) {
  1998.         if (b < c) return -1;
  1999.         else if (b > c) return 1;
  2000.         return 0
  2001.     };
  2002.     g.compareVersions = function (b, c) {
  2003.         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++) {
  2004.             var x = f[k] || "",
  2005.                 F = h[k] || "",
  2006.                 G = new RegExp("(\\d*)(\\D*)", "g"),
  2007.                 H = new RegExp("(\\d*)(\\D*)", "g");
  2008.             do {
  2009.                 var t = G.exec(x) || ["", "", ""],
  2010.                     u = H.exec(F) || ["", "", ""];
  2011.                 if (t[0].length == 0 && u[0].length == 0) break;
  2012.                 d = t[1].length == 0 ? 0 : parseInt(t[1], 10);
  2013.                 var I = u[1].length == 0 ? 0 : parseInt(u[1], 10);
  2014.                 d = g.g(d, I) || g.g(t[2].length == 0, u[2].length == 0) || g.g(t[2], u[2])
  2015.             } while (d == 0)
  2016.         }
  2017.         return d
  2018.     };
  2019.     g.getFlashVersion = function (b) {
  2020.         b = b.match(/[\d]+/g);
  2021.         b.length = 3;
  2022.         return b.join(".")
  2023.     };
  2024.     g.detectFlash = function () {
  2025.         var b = e,
  2026.             c = "";
  2027.         if (navigator.plugins && navigator.plugins.length) {
  2028.             var d = navigator.plugins["Shockwave Flash"];
  2029.             if (d) {
  2030.                 b = a;
  2031.                 if (d.description) c = g.getFlashVersion(d.description)
  2032.             }
  2033.             if (navigator.plugins["Shockwave Flash 2.0"]) {
  2034.                 b = a;
  2035.                 c = "2.0.0.11"
  2036.             }
  2037.         } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
  2038.             if (b = (d = navigator.mimeTypes["application/x-shockwave-flash"]) && d.enabledPlugin) {
  2039.                 c = d.enabledPlugin.description;
  2040.                 c = g.getFlashVersion(c)
  2041.             }
  2042.         } else try {
  2043.             d = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  2044.             b = a;
  2045.             c = g.getFlashVersion(d.GetVariable("$version"))
  2046.         } catch (f) {
  2047.             try {
  2048.                 d = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  2049.                 b = a;
  2050.                 c = "6.0.21"
  2051.             } catch (h) {
  2052.                 try {
  2053.                     d = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  2054.                     b = a;
  2055.                     c = g.getFlashVersion(d.GetVariable("$version"))
  2056.                 } catch (j) {}
  2057.             }
  2058.         }
  2059.         g.hasFlash = b;
  2060.         g.flashVersion = c
  2061.     };
  2062.     g.isFlashVersion = function (b) {
  2063.         return g.compareVersions(g.flashVersion, b) >= 0
  2064.     };
  2065.     g.prepareSound = function () {
  2066.         g.soundAvailable = e;
  2067.         g.soundEnabled = e;
  2068.         g.soundReady = e;
  2069.         g.detectFlash();
  2070.         if (!g.hasFlash || !g.isFlashVersion("9.0.0.0")) {
  2071.             g.soundReady = a;
  2072.             g.checkIfEverythingIsReady()
  2073.         } else {
  2074.             g.flashIframe = document.createElement("iframe");
  2075.             g.flashIframe.name = "pm-sound";
  2076.             g.flashIframe.style.position = "absolute";
  2077.             g.flashIframe.style.top = "-150px";
  2078.             g.flashIframe.style.border = 0;
  2079.             g.flashIframe.style.width = "100px";
  2080.             g.flashIframe.style.height = "100px";
  2081.             google.dom.append(g.flashIframe);
  2082.             g.flashIframeDoc = g.flashIframe.contentDocument;
  2083.             if (g.flashIframeDoc == undefined || g.flashIframeDoc == null) g.flashIframeDoc = g.flashIframe.contentWindow.document;
  2084.             g.flashIframeDoc.open();
  2085.             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="logos/swf/pacman10-hp-sound.swf"> <param name="allowScriptAccess" value="always"> <object id="pacman-sound-player-2"  type="application/x-shockwave-flash" data="logos/swf/pacman10-hp-sound.swf" width="0" height="0"><param name="allowScriptAccess" value="always"> </object></object></body></html>');
  2086.             g.flashIframeDoc.close();
  2087.             window.setTimeout(g.flashNotReady, 3E3)
  2088.         }
  2089.     };
  2090.     g.flashNotReady = function () {
  2091.         if (!g.ready) {
  2092.             g.soundAvailable = e;
  2093.             g.soundEnabled = e;
  2094.             g.soundReady = a;
  2095.             g.checkIfEverythingIsReady()
  2096.         }
  2097.     };
  2098.     g.flashReady = function (b) {
  2099.         g.flashSoundPlayer = b;
  2100.         g.soundAvailable = a;
  2101.         g.soundEnabled = a;
  2102.         g.soundReady = a;
  2103.         g.checkIfEverythingIsReady()
  2104.     };
  2105.     g.flashLoaded = function () {
  2106.         if (g.flashIframeDoc) {
  2107.             var b = g.flashIframeDoc.getElementById("pacman-sound-player");
  2108.             if (b && b.playTrack) {
  2109.                 g.flashReady(b);
  2110.                 return
  2111.             } else if ((b = g.flashIframeDoc.getElementById("pacman-sound-player-2")) && b.playTrack) {
  2112.                 g.flashReady(b);
  2113.                 return
  2114.             }
  2115.         }
  2116.         g.flashNotReady()
  2117.     };
  2118.     g.destroy = function () {
  2119.         if (google.pacman) {
  2120.             g.stopAllAudio();
  2121.             window.clearInterval(g.tickTimer);
  2122.             window.clearInterval(g.dotTimer);
  2123.             window.clearInterval(g.dotTimerMs);
  2124.             google.dom.remove(g.styleElement);
  2125.             google.dom.remove(g.flashIframe);
  2126.             google.dom.remove(g.canvasEl);
  2127.             google.pacman = undefined
  2128.         }
  2129.     };
  2130.     g.exportFunctionCalls = function () {
  2131.         google.pacman = {};
  2132.         google.pacman.insertCoin = g.insertCoin;
  2133.         google.pacman.flashLoaded = g.flashLoaded;
  2134.         google.pacman.destroy = g.destroy
  2135.     };
  2136.     g.updateLoadingProgress = function (b) {
  2137.         b = Math.round(b * 200);
  2138.         document.getElementById("logo-b").style.width = b + "px"
  2139.     };
  2140.     g.init = function () {
  2141.         g.ready = e;
  2142.         document.getElementById("logo").title = "";
  2143.         g.updateLoadingProgress(0.33);
  2144.         g.exportFunctionCalls();
  2145.         g.useCss = navigator.userAgent.indexOf("MSIE 5.") != -1 || navigator.userAgent.indexOf("MSIE 6.") != -1 || navigator.userAgent.indexOf("MSIE 7.") != -1 ? e : a;
  2146.         g.prepareGraphics();
  2147.         g.prepareSound()
  2148.     };
  2149.     g.init();
  2150. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement