`
yonlist
  • 浏览: 84455 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

google主页吃豆人的代码

阅读更多

为纪念PAC-MAN诞生30年,google主页logo换成了吃豆人小游戏,js做的

 

google.pacman || function () {
	var a = true, e = false, g = {}, i = [1, 4, 2, 8], l = {0:{axis:0, increment:0}, 1:{axis:0, increment:-1}, 2:{axis:0, increment:+1}, 4:{axis:1, increment:-1}, 8:{axis:1, increment:+1}}, m = [0, 7, 17, 32], n = [{x:5, y:1, w:56}, {x:5, y:4, w:5}, {x:5, y:1, h:4}, {x:9, y:1, h:12}, {x:5, y:12, h:4}, {x:10, y:12, h:4}, {x:5, y:15, w:16}, {x:5, y:12, w:31}, {x:60, y:1, h:4}, {x:54, y:1, h:4}, {x:19, y:1, h:12}, {x:19, y:4, w:26}, {x:13, y:5, w:7}, {x:13, y:5, h:4}, {x:13, y:8, w:3}, {x:56, y:4, h:9}, {x:48, y:4, w:13}, {x:48, y:1, h:12}, {x:60, y:12, h:4}, {x:44, y:15, w:17}, {x:54, y:12, h:4}, {x:44, y:12, w:17}, {x:44, y:1, h:15}, {x:41, y:13, w:4}, {x:41, y:13, h:3}, {x:38, y:13, h:3}, {x:38, y:15, w:4}, {x:35, y:10, w:10}, {x:35, y:1, h:15}, {x:35, y:13, w:4}, {x:21, y:12, h:4}, {x:24, y:12, h:4}, {x:24, y:15, w:12}, {x:27, y:4, h:9}, {x:52, y:9, w:5}, {x:56, y:8, w:10, type:1}, {x:1, y:8, w:9, type:1}], o = [{x:1, y:8, w:8}, {x:57, y:8, w:9}, {x:44, y:2, h:10}, {x:35, y:5, h:7}, {x:36, y:4, w:8}, {x:36, y:10, w:8}, {x:39, y:15, w:2}], p = [{x:5, y:15}, {x:5, y:3}, {x:15, y:8}, {x:60, y:3}, {x:60, y:15}], q = [{x:2, y:8}, {x:63, y:8}], r = {1:[{x:39.5, y:15, dir:4}, {x:39.5, y:4, dir:4, scatterX:57, scatterY:-4}, {x:39.5, y:7, dir:2, scatterX:0, scatterY:-4}, {x:37.625, y:7, dir:1, scatterX:57, scatterY:20}, {x:41.375, y:7, dir:1, scatterX:0, scatterY:20}], 2:[{x:40.25, y:15, dir:8}, {x:38.75, y:15, dir:4}, {x:39.5, y:4, dir:4, scatterX:57, scatterY:-4}, {x:39.5, y:7, dir:2, scatterX:0, scatterY:-4}, {x:37.625, y:7, dir:1, scatterX:57, scatterY:20}, {x:41.375, y:7, dir:1, scatterX:0, scatterY:20}]}, s = [32, 312], v = [80, 312], w = {0:0.16, 1:0.23, 2:1, 3:1, 4:2.23, 5:0.3, 6:1.9, 7:2.23, 8:1.9, 9:5, 10:1.9, 11:1.18, 12:0.3, 13:0.5, 14:1.9, 15:9, 16:10, 17:0.26}, y = 0.8 * 0.4, z = [{}, {ghostSpeed:0.75, ghostTunnelSpeed:0.4, playerSpeed:0.8, dotEatingSpeed:0.71, ghostFrightSpeed:0.5, playerFrightSpeed:0.9, dotEatingFrightSpeed:0.79, elroyDotsLeftPart1:20, elroySpeedPart1:0.8, elroyDotsLeftPart2:10, elroySpeedPart2:0.85, frightTime:6, frightBlinkCount:5, fruit:1, fruitScore:100, ghostModeSwitchTimes:[7, 20, 7, 20, 5, 20, 5, 1], penForceTime:4, penLeavingLimits:[0, 0, 30, 60]}, {ghostSpeed:0.85, ghostTunnelSpeed:0.45, playerSpeed:0.9, dotEatingSpeed:0.79, ghostFrightSpeed:0.55, playerFrightSpeed:0.95, dotEatingFrightSpeed:0.83, elroyDotsLeftPart1:30, elroySpeedPart1:0.9, elroyDotsLeftPart2:15, elroySpeedPart2:0.95, frightTime:5, frightBlinkCount:5, fruit:2, fruitScore:300, ghostModeSwitchTimes:[7, 20, 7, 20, 5, 1033, 1 / 60, 1], penForceTime:4, penLeavingLimits:[0, 0, 0, 50], cutsceneId:1}, {ghostSpeed:0.85, ghostTunnelSpeed:0.45, playerSpeed:0.9, dotEatingSpeed:0.79, ghostFrightSpeed:0.55, playerFrightSpeed:0.95, dotEatingFrightSpeed:0.83, elroyDotsLeftPart1:40, elroySpeedPart1:0.9, elroyDotsLeftPart2:20, elroySpeedPart2:0.95, frightTime:4, frightBlinkCount:5, fruit:3, fruitScore:500, ghostModeSwitchTimes:[7, 20, 7, 20, 5, 1033, 1 / 60, 1], penForceTime:4, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.85, ghostTunnelSpeed:0.45, playerSpeed:0.9, dotEatingSpeed:0.79, ghostFrightSpeed:0.55, playerFrightSpeed:0.95, dotEatingFrightSpeed:0.83, elroyDotsLeftPart1:40, elroySpeedPart1:0.9, elroyDotsLeftPart2:20, elroySpeedPart2:0.95, frightTime:3, frightBlinkCount:5, fruit:3, fruitScore:500, ghostModeSwitchTimes:[7, 20, 7, 20, 5, 1033, 1 / 60, 1], penForceTime:4, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:40, elroySpeedPart1:1, elroyDotsLeftPart2:20, elroySpeedPart2:1.05, frightTime:2, frightBlinkCount:5, fruit:4, fruitScore:700, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0], cutsceneId:2}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:50, elroySpeedPart1:1, elroyDotsLeftPart2:25, elroySpeedPart2:1.05, frightTime:5, frightBlinkCount:5, fruit:4, fruitScore:700, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:50, elroySpeedPart1:1, elroyDotsLeftPart2:25, elroySpeedPart2:1.05, frightTime:2, frightBlinkCount:5, fruit:5, fruitScore:1000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:50, elroySpeedPart1:1, elroyDotsLeftPart2:25, elroySpeedPart2:1.05, frightTime:2, frightBlinkCount:5, fruit:5, fruitScore:1000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:60, elroySpeedPart1:1, elroyDotsLeftPart2:30, elroySpeedPart2:1.05, frightTime:1, frightBlinkCount:3, fruit:6, fruitScore:2000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0], cutsceneId:3}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:60, elroySpeedPart1:1, elroyDotsLeftPart2:30, elroySpeedPart2:1.05, frightTime:5, frightBlinkCount:5, fruit:6, fruitScore:2000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:60, elroySpeedPart1:1, elroyDotsLeftPart2:30, elroySpeedPart2:1.05, frightTime:2, frightBlinkCount:5, fruit:7, fruitScore:3000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:80, elroySpeedPart1:1, elroyDotsLeftPart2:40, elroySpeedPart2:1.05, frightTime:1, frightBlinkCount:3, fruit:7, fruitScore:3000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:80, elroySpeedPart1:1, elroyDotsLeftPart2:40, elroySpeedPart2:1.05, frightTime:1, frightBlinkCount:3, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0], cutsceneId:3}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:80, elroySpeedPart1:1, elroyDotsLeftPart2:40, elroySpeedPart2:1.05, frightTime:3, frightBlinkCount:5, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:100, elroySpeedPart1:1, elroyDotsLeftPart2:50, elroySpeedPart2:1.05, frightTime:1, frightBlinkCount:3, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:100, elroySpeedPart1:1, elroyDotsLeftPart2:50, elroySpeedPart2:1.05, frightTime:1, frightBlinkCount:3, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:100, elroySpeedPart1:1, elroyDotsLeftPart2:50, elroySpeedPart2:1.05, frightTime:0, frightBlinkCount:0, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0], cutsceneId:3}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:100, elroySpeedPart1:1, elroyDotsLeftPart2:50, elroySpeedPart2:1.05, frightTime:1, frightBlinkCount:3, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:120, elroySpeedPart1:1, elroyDotsLeftPart2:60, elroySpeedPart2:1.05, frightTime:0, frightBlinkCount:0, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:1, dotEatingSpeed:0.87, ghostFrightSpeed:0.6, playerFrightSpeed:1, dotEatingFrightSpeed:0.87, elroyDotsLeftPart1:120, elroySpeedPart1:1, elroyDotsLeftPart2:60, elroySpeedPart2:1.05, frightTime:0, frightBlinkCount:0, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}, {ghostSpeed:0.95, ghostTunnelSpeed:0.5, playerSpeed:0.9, dotEatingSpeed:0.79, ghostFrightSpeed:0.75, playerFrightSpeed:0.9, dotEatingFrightSpeed:0.79, elroyDotsLeftPart1:120, elroySpeedPart1:1, elroyDotsLeftPart2:60, elroySpeedPart2:1.05, frightTime:0, frightBlinkCount:0, fruit:8, fruitScore:5000, ghostModeSwitchTimes:[5, 20, 5, 20, 5, 1037, 1 / 60, 1], penForceTime:3, penLeavingLimits:[0, 0, 0, 0]}], A = {1:[{x:37.6, y:7, dir:1, dest:6.375, speed:0.48}, {x:37.6, y:6.375, dir:2, dest:7.625, speed:0.48}, {x:37.6, y:7.625, dir:1, dest:7, speed:0.48}], 2:[{x:39.5, y:7, dir:2, dest:7.625, speed:0.48}, {x:39.5, y:7.625, dir:1, dest:6.375, speed:0.48}, {x:39.5, y:6.375, dir:2, dest:7, speed:0.48}], 3:[{x:41.4, y:7, dir:1, dest:6.375, speed:0.48}, {x:41.4, y:6.375, dir:2, dest:7.625, speed:0.48}, {x:41.4, y:7.625, dir:1, dest:7, speed:0.48}], 4:[{x:37.6, y:7, dir:8, dest:39.5, speed:y}, {x:39.5, y:7, dir:1, dest:4, speed:y}], 5:[{x:39.5, y:7, dir:1, dest:4, speed:y}], 6:[{x:41.4, y:7, dir:4, dest:39.5, speed:y}, {x:39.5, y:7, dir:1, dest:4, speed:y}], 7:[{x:39.5, y:4, dir:2, dest:7, speed:1.6}, {x:39.5, y:7, dir:4, dest:37.625, speed:1.6}], 8:[{x:39.5, y:4, dir:2, dest:7, speed:1.6}], 9:[{x:39.5, y:4, dir:2, dest:7, speed:1.6}, {x:39.5, y:7, dir:8, dest:41.375, speed:1.6}], 10:[{x:37.6, y:7, dir:8, dest:39.5, speed:y}, {x:39.5, y:7, dir:1, dest:4, speed:y}], 11:[{x:39.5, y:7, dir:1, dest:4, speed:y}], 12:[{x:41.4, y:7, dir:4, dest:39.5, speed:y}, {x:39.5, y:7, dir:1, dest:4, speed:y}]}, B = {1:{actors:[{ghost:e, x:64, y:9, id:0}, {ghost:a, x:68.2, y:9, id:1}], sequence:[{time:5.5, moves:[{dir:4, speed:0.75 * 0.8 * 2}, {dir:4, speed:0.78 * 0.8 * 2}]}, {time:0.1, moves:[{dir:4, speed:32}, {dir:4, speed:0}]}, {time:9, moves:[{dir:8, speed:0.75 * 0.8 * 2, elId:"pcm-bpcm"}, {dir:8, speed:0.8, mode:4}]}]}, 2:{actors:[{ghost:e, x:64, y:9, id:0}, {ghost:a, x:70.2, y:9, id:1}, {ghost:a, x:32, y:9.5, id:2}], sequence:[{time:2.7, moves:[{dir:4, speed:0.75 * 0.8 * 2}, {dir:4, speed:0.78 * 0.8 * 2}, {dir:0, speed:0, elId:"pcm-stck"}]}, {time:1, moves:[{dir:4, speed:0.75 * 0.8 * 2}, {dir:4, speed:0.1 * 0.8}, {dir:0, speed:0, elId:"pcm-stck"}]}, {time:1.3, moves:[{dir:4, speed:0.75 * 0.8 * 2}, {dir:4, speed:0}, {dir:0, speed:0, elId:"pcm-stck"}]}, {time:1, moves:[{dir:4, speed:0.75 * 0.8 * 2}, {dir:4, speed:0, elId:"pcm-ghfa"}, {dir:0, speed:0, elId:"pcm-stck"}]}, {time:2.5, moves:[{dir:4, speed:0.75 * 0.8 * 2}, {dir:4, speed:0, elId:"pcm-ghfa"}, {dir:0, speed:0, elId:"pcm-stck"}]}]}, 3:{actors:[{ghost:e, x:64, y:9, id:0}, {ghost:a, x:70.2, y:9, id:2}], sequence:[{time:5.3, moves:[{dir:4, speed:0.75 * 0.8 * 2}, {dir:4, speed:0.78 * 0.8 * 2, elId:"pcm-ghin"}]}, {time:5.3, moves:[{dir:4, speed:0}, {dir:8, speed:0.78 * 0.8 * 2, elId:"pcm-gbug"}]}]}}, C = [90, 45, 30], D = C[0];
	function E(b) {
		this.id = b;
	}
	E.prototype.A = function () {
		var b = r[g.playerCount][this.id];
		this.pos = [b.y * 8, b.x * 8];
		this.posDelta = [0, 0];
		this.tilePos = [b.y * 8, b.x * 8];
		this.targetPos = [b.scatterY * 8, b.scatterX * 8];
		this.scatterPos = [b.scatterY * 8, b.scatterX * 8];
		this.lastActiveDir = this.dir = b.dir;
		this.physicalSpeed = this.requestedDir = this.nextDir = 0;
		this.c(0);
		this.reverseDirectionsNext = this.freeToLeavePen = this.modeChangedWhileInPen = this.eatenInThisFrightMode = e;
		this.l();
	};
	E.prototype.createElement = function () {
		this.el = document.createElement("div");
		this.el.className = "pcm-ac";
		this.el.id = "actor" + this.id;
		g.prepareElement(this.el, 0, 0);
		g.playfieldEl.appendChild(this.el);
		this.elPos = [0, 0];
		this.elBackgroundPos = [0, 0];
	};
	E.prototype.a = function (b) {
		var c = this.mode;
		this.mode = b;
		if (this.id == g.playerCount + 3 && (b == 16 || c == 16)) {
			g.updateCruiseElroySpeed();
		}
		switch (c) {
		  case 32:
			g.ghostExitingPenNow = e;
			break;
		  case 8:
			g.ghostEyesCount > 0 && g.ghostEyesCount--;
			g.ghostEyesCount == 0 && g.playAmbientSound();
			break;
		}
		switch (b) {
		  case 4:
			this.fullSpeed = g.levels.ghostFrightSpeed * 0.8;
			this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
			this.followingRoutine = e;
			break;
		  case 1:
			this.fullSpeed = g.levels.ghostSpeed * 0.8;
			this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
			this.followingRoutine = e;
			break;
		  case 2:
			this.targetPos = this.scatterPos;
			this.fullSpeed = g.levels.ghostSpeed * 0.8;
			this.tunnelSpeed = g.levels.ghostTunnelSpeed * 0.8;
			this.followingRoutine = e;
			break;
		  case 8:
			this.tunnelSpeed = this.fullSpeed = 1.6;
			this.targetPos = [s[0], s[1]];
			this.freeToLeavePen = this.followingRoutine = e;
			break;
		  case 16:
			this.l();
			this.followingRoutine = a;
			this.routineMoveId = -1;
			switch (this.id) {
			  case g.playerCount + 1:
				this.routineToFollow = 2;
				break;
			  case g.playerCount + 2:
				this.routineToFollow = 1;
				break;
			  case g.playerCount + 3:
				this.routineToFollow = 3;
				break;
			}
			break;
		  case 32:
			this.followingRoutine = a;
			this.routineMoveId = -1;
			switch (this.id) {
			  case g.playerCount + 1:
				this.routineToFollow = 5;
				break;
			  case g.playerCount + 2:
				this.routineToFollow = 4;
				break;
			  case g.playerCount + 3:
				this.routineToFollow = 6;
				break;
			}
			g.ghostExitingPenNow = a;
			break;
		  case 64:
			this.followingRoutine = a;
			this.routineMoveId = -1;
			switch (this.id) {
			  case g.playerCount:
			  case g.playerCount + 1:
				this.routineToFollow = 8;
				break;
			  case g.playerCount + 2:
				this.routineToFollow = 7;
				break;
			  case g.playerCount + 3:
				this.routineToFollow = 9;
				break;
			}
			break;
		  case 128:
			this.followingRoutine = a;
			this.routineMoveId = -1;
			switch (this.id) {
			  case g.playerCount:
			  case g.playerCount + 1:
				this.routineToFollow = 11;
				break;
			  case g.playerCount + 2:
				this.routineToFollow = 10;
				break;
			  case g.playerCount + 3:
				this.routineToFollow = 12;
				break;
			}
			break;
		}
		this.d();
	};
	E.prototype.l = function () {
		if (this.id >= g.playerCount) {
			this.targetPlayerId = Math.floor(g.rand() * g.playerCount);
		}
	};
	E.prototype.z = function (b) {
		if (!g.userDisabledSound) {
			google.pacManSound = a;
			g.updateSoundIcon();
		}
		if (this.dir == g.oppositeDirections[b]) {
			this.dir = b;
			this.posDelta = [0, 0];
			this.currentSpeed != 2 && this.c(0);
			if (this.dir != 0) {
				this.lastActiveDir = this.dir;
			}
			this.nextDir = 0;
		} else {
			if (this.dir != b) {
				if (this.dir == 0) {
					if (g.playfield[this.pos[0]][this.pos[1]].allowedDir & b) {
						this.dir = b;
					}
				} else {
					var c = g.playfield[this.tilePos[0]][this.tilePos[1]];
					if (c && c.allowedDir & b) {
						c = l[this.dir];
						var d = [this.pos[0], this.pos[1]];
						d[c.axis] -= c.increment;
						var f = 0;
						if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) {
							f = 1;
						} else {
							d[c.axis] -= c.increment;
							if (d[0] == this.tilePos[0] && d[1] == this.tilePos[1]) {
								f = 2;
							}
						}
						if (f) {
							this.dir = b;
							this.pos[0] = this.tilePos[0];
							this.pos[1] = this.tilePos[1];
							c = l[this.dir];
							this.pos[c.axis] += c.increment * f;
							return;
						}
					}
					this.nextDir = b;
					this.posDelta = [0, 0];
				}
			}
		}
	};
	E.prototype.i = function (b) {
		var c = this.tilePos, d = l[this.dir], f = [c[0], c[1]];
		f[d.axis] += d.increment * 8;
		var h = g.playfield[f[0]][f[1]];
		if (b && !h.intersection) {
			h = g.playfield[c[0]][c[1]];
		}
		if (h.intersection) {
			switch (this.mode) {
			  case 2:
			  case 1:
			  case 8:
				if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) {
					this.nextDir = g.oppositeDirections[this.dir];
				} else {
					b = 99999999999;
					c = 0;
					for (var j in i) {
						var k = i[j];
						if (h.allowedDir & k && this.dir != g.oppositeDirections[k]) {
							d = l[k];
							var x = [f[0], f[1]];
							x[d.axis] += d.increment;
							d = g.getDistance(x, [this.targetPos[0], this.targetPos[1]]);
							if (d < b) {
								b = d;
								c = k;
							}
						}
					}
					if (c) {
						this.nextDir = c;
					}
				}
				break;
			  case 4:
				if ((this.dir & h.allowedDir) == 0 && h.allowedDir == g.oppositeDirections[this.dir]) {
					this.nextDir = g.oppositeDirections[this.dir];
				} else {
					do {
						f = i[Math.floor(g.rand() * 4)];
					} while ((f & h.allowedDir) == 0 || f == g.oppositeDirections[this.dir]);
					this.nextDir = f;
				}
				break;
			}
		}
	};
	E.prototype.p = function (b) {
		g.tilesChanged = a;
		if (this.reverseDirectionsNext) {
			this.dir = g.oppositeDirections[this.dir];
			this.nextDir = 0;
			this.reverseDirectionsNext = e;
			this.i(a);
		}
		if (!this.ghost && !g.playfield[b[0]][b[1]].path) {
			this.pos[0] = this.lastGoodTilePos[0];
			this.pos[1] = this.lastGoodTilePos[1];
			b[0] = this.lastGoodTilePos[0];
			b[1] = this.lastGoodTilePos[1];
			this.dir = 0;
		} else {
			this.lastGoodTilePos = [b[0], b[1]];
		}
		g.playfield[b[0]][b[1]].type == 1 && this.mode != 8 ? this.c(2) : this.c(0);
		!this.ghost && g.playfield[b[0]][b[1]].dot && g.dotEaten(this.id, b);
		this.tilePos[0] = b[0];
		this.tilePos[1] = b[1];
	};
	E.prototype.t = function () {
		var b = this.tilePos;
		switch (this.dir) {
		  case 1:
			var c = [b[0], b[1]], d = [b[0] + 3.6, b[1]];
			break;
		  case 2:
			c = [b[0] - 4, b[1]];
			d = [b[0], b[1]];
			break;
		  case 4:
			c = [b[0], b[1]];
			d = [b[0], b[1] + 3.6];
			break;
		  case 8:
			c = [b[0], b[1] - 4];
			d = [b[0], b[1]];
			break;
		}
		if (this.pos[0] >= c[0] && this.pos[0] <= d[0] && this.pos[1] >= c[1] && this.pos[1] <= d[1]) {
			b = l[this.nextDir];
			this.posDelta[b.axis] += b.increment;
		}
	};
	E.prototype.n = function () {
		if (this.pos[0] == q[0].y * 8 && this.pos[1] == q[0].x * 8) {
			this.pos[0] = q[1].y * 8;
			this.pos[1] = (q[1].x - 1) * 8;
		} else {
			if (this.pos[0] == q[1].y * 8 && this.pos[1] == q[1].x * 8) {
				this.pos[0] = q[0].y * 8;
				this.pos[1] = (q[0].x + 1) * 8;
			}
		}
		this.mode == 8 && this.pos[0] == s[0] && this.pos[1] == s[1] && this.a(64);
		if (!this.ghost && this.pos[0] == v[0] && (this.pos[1] == v[1] || this.pos[1] == v[1] + 8)) {
			g.eatFruit(this.id);
		}
	};
	E.prototype.u = function () {
		this.n();
		this.ghost && this.i(e);
		var b = g.playfield[this.pos[0]][this.pos[1]];
		if (b.intersection) {
			if (this.nextDir && this.nextDir & b.allowedDir) {
				if (this.dir != 0) {
					this.lastActiveDir = this.dir;
				}
				this.dir = this.nextDir;
				this.nextDir = 0;
				if (!this.ghost) {
					this.pos[0] += this.posDelta[0];
					this.pos[1] += this.posDelta[1];
					this.posDelta = [0, 0];
				}
			} else {
				if ((this.dir & b.allowedDir) == 0) {
					if (this.dir != 0) {
						this.lastActiveDir = this.dir;
					}
					this.nextDir = this.dir = 0;
					this.c(0);
				}
			}
		}
	};
	E.prototype.o = function () {
		var b = this.pos[0] / 8, c = this.pos[1] / 8, d = [Math.round(b) * 8, Math.round(c) * 8];
		if (d[0] != this.tilePos[0] || d[1] != this.tilePos[1]) {
			this.p(d);
		} else {
			b = [Math.floor(b) * 8, Math.floor(c) * 8];
			this.pos[1] == b[1] && this.pos[0] == b[0] && this.u();
		}
		!this.ghost && this.nextDir && g.playfield[d[0]][d[1]].intersection && this.nextDir & g.playfield[d[0]][d[1]].allowedDir && this.t();
	};
	E.prototype.B = function () {
		if (this.id == g.playerCount && g.dotsRemaining < g.levels.elroyDotsLeftPart1 && this.mode == 2 && (!g.lostLifeOnThisLevel || g.actors[g.playerCount + 3].mode != 16)) {
			var b = g.actors[this.targetPlayerId];
			this.targetPos = [b.tilePos[0], b.tilePos[1]];
		} else {
			if (this.ghost && this.mode == 1) {
				b = g.actors[this.targetPlayerId];
				switch (this.id) {
				  case g.playerCount:
					this.targetPos = [b.tilePos[0], b.tilePos[1]];
					break;
				  case g.playerCount + 1:
					this.targetPos = [b.tilePos[0], b.tilePos[1]];
					var c = l[b.dir];
					this.targetPos[c.axis] += 32 * c.increment;
					if (b.dir == 1) {
						this.targetPos[1] -= 32;
					}
					break;
				  case g.playerCount + 2:
					var d = g.actors[g.playerCount], f = [b.tilePos[0], b.tilePos[1]];
					c = l[b.dir];
					f[c.axis] += 16 * c.increment;
					if (b.dir == 1) {
						f[1] -= 16;
					}
					this.targetPos[0] = f[0] * 2 - d.tilePos[0];
					this.targetPos[1] = f[1] * 2 - d.tilePos[1];
					break;
				  case g.playerCount + 3:
					c = g.getDistance(b.tilePos, this.tilePos);
					this.targetPos = c > 64 ? [b.tilePos[0], b.tilePos[1]] : this.scatterPos;
					break;
				}
			}
		}
	};
	E.prototype.v = function () {
		this.routineMoveId++;
		if (this.routineMoveId == A[this.routineToFollow].length) {
			if (this.mode == 16 && this.freeToLeavePen && !g.ghostExitingPenNow) {
				this.eatenInThisFrightMode ? this.a(128) : this.a(32);
				return;
			} else {
				if (this.mode == 32 || this.mode == 128) {
					this.pos = [s[0], s[1] + 4];
					this.dir = this.modeChangedWhileInPen ? 8 : 4;
					var b = g.mainGhostMode;
					if (this.mode == 128 && b == 4) {
						b = g.lastMainGhostMode;
					}
					this.a(b);
					return;
				} else {
					if (this.mode == 64) {
						if (this.id == g.playerCount || this.freeToLeavePen) {
							this.a(128);
						} else {
							this.eatenInThisFrightMode = a;
							this.a(16);
						}
						return;
					} else {
						this.routineMoveId = 0;
					}
				}
			}
		}
		b = A[this.routineToFollow][this.routineMoveId];
		this.pos[0] = b.y * 8;
		this.pos[1] = b.x * 8;
		this.dir = b.dir;
		this.physicalSpeed = 0;
		this.speedIntervals = g.getSpeedIntervals(b.speed);
		this.proceedToNextRoutineMove = e;
		this.b();
	};
	E.prototype.m = function () {
		var b = A[this.routineToFollow][this.routineMoveId];
		if (b) {
			if (this.speedIntervals[g.intervalTime]) {
				var c = l[this.dir];
				this.pos[c.axis] += c.increment;
				switch (this.dir) {
				  case 1:
				  case 4:
					if (this.pos[c.axis] < b.dest * 8) {
						this.pos[c.axis] = b.dest * 8;
						this.proceedToNextRoutineMove = a;
					}
					break;
				  case 2:
				  case 8:
					if (this.pos[c.axis] > b.dest * 8) {
						this.pos[c.axis] = b.dest * 8;
						this.proceedToNextRoutineMove = a;
					}
					break;
				}
				this.b();
			}
		}
	};
	E.prototype.j = function () {
		if (this.routineMoveId == -1 || this.proceedToNextRoutineMove) {
			this.v();
		}
		this.m();
	};
	E.prototype.d = function () {
		switch (this.currentSpeed) {
		  case 0:
			var b = this.id == g.playerCount && (this.mode == 2 || this.mode == 1) ? g.cruiseElroySpeed : this.fullSpeed;
			break;
		  case 1:
			b = this.dotEatingSpeed;
			break;
		  case 2:
			b = this.tunnelSpeed;
			break;
		}
		if (this.physicalSpeed != b) {
			this.physicalSpeed = b;
			this.speedIntervals = g.getSpeedIntervals(this.physicalSpeed);
		}
	};
	E.prototype.c = function (b) {
		this.currentSpeed = b;
		this.d();
	};
	E.prototype.e = function () {
		if (this.dir) {
			if (this.speedIntervals[g.intervalTime]) {
				var b = l[this.dir];
				this.pos[b.axis] += b.increment;
				this.o();
				this.b();
			}
		}
	};
	E.prototype.move = function () {
		if (g.gameplayMode == 0 || this.ghost && g.gameplayMode == 1 && (this.mode == 8 || this.mode == 64)) {
			if (this.requestedDir != 0) {
				this.z(this.requestedDir);
				this.requestedDir = 0;
			}
			if (this.followingRoutine) {
				this.j();
				this.mode == 64 && this.j();
			} else {
				this.e();
				this.mode == 8 && this.e();
			}
		}
	};
	E.prototype.k = function () {
		var b = g.getPlayfieldX(this.pos[1] + this.posDelta[1]), c = g.getPlayfieldY(this.pos[0] + this.posDelta[0]);
		if (this.elPos[0] != c || this.elPos[1] != b) {
			this.elPos[0] = c;
			this.elPos[1] = b;
			this.el.style.left = b + "px";
			this.el.style.top = c + "px";
		}
	};
	E.prototype.s = function () {
		var b = 0, c = 0, d = this.dir;
		if (d == 0) {
			d = this.lastActiveDir;
		}
		if (g.gameplayMode == 1 && this.id == g.playerEatingGhostId) {
			b = 3;
			c = 0;
		} else {
			if ((g.gameplayMode == 9 || g.gameplayMode == 10) && this.id == 0) {
				b = 2;
				c = 0;
			} else {
				if (g.gameplayMode == 4 || g.gameplayMode == 5 || g.gameplayMode == 7) {
					b = this.id == 0 ? 2 : 4;
					c = 0;
				} else {
					if (g.gameplayMode == 3) {
						if (this.id == g.playerDyingId) {
							d = 20 - Math.floor(g.gameplayModeTime / g.timing[4] * 21);
							if (this.id == 0) {
								b = d - 1;
								switch (b) {
								  case -1:
									b = 0;
									break;
								  case 11:
									b = 10;
									break;
								  case 12:
								  case 13:
								  case 14:
								  case 15:
								  case 16:
								  case 17:
								  case 18:
								  case 19:
								  case 20:
									b = 11;
									break;
								}
								c = 12;
							} else {
								switch (d) {
								  case 0:
								  case 1:
								  case 2:
								  case 6:
								  case 10:
									b = 4;
									c = 3;
									break;
								  case 3:
								  case 7:
								  case 11:
									b = 4;
									c = 0;
									break;
								  case 4:
								  case 8:
								  case 12:
								  case 13:
								  case 14:
								  case 15:
								  case 16:
								  case 17:
								  case 18:
								  case 19:
								  case 20:
									b = 4;
									c = 2;
									break;
								  case 5:
								  case 9:
									b = 4;
									c = 1;
									break;
								}
							}
						} else {
							b = 3;
							c = 0;
						}
					} else {
						if (this.el.id == "pcm-bpcm") {
							b = 14;
							c = 0;
							d = Math.floor(g.globalTime * 0.2) % 4;
							if (d == 3) {
								d = 1;
							}
							c += 2 * d;
						} else {
							switch (d) {
							  case 4:
								c = 0;
								break;
							  case 8:
								c = 1;
								break;
							  case 1:
								c = 2;
								break;
							  case 2:
								c = 3;
								break;
							}
							if (g.gameplayMode != 2) {
								b = Math.floor(g.globalTime * 0.3) % 4;
							}
							if (b == 3 && this.dir == 0) {
								b = 0;
							}
							if (b == 2 && this.id == 0) {
								b = 0;
							}
							if (b == 3) {
								b = 2;
								if (this.id == 0) {
									c = 0;
								}
							}
							if (this.id == 1) {
								b += 4;
							}
						}
					}
				}
			}
		}
		return [c, b];
	};
	E.prototype.r = function () {
		var b = 0, c = 0;
		if (g.gameplayMode == 10 || g.gameplayMode == 4 || g.gameplayMode == 3) {
			b = 3;
			c = 0;
		} else {
			if (g.gameplayMode == 1 && this.id == g.ghostBeingEatenId) {
				switch (g.modeScoreMultiplier) {
				  case 2:
					b = 0;
					break;
				  case 4:
					b = 1;
					break;
				  case 8:
					b = 2;
					break;
				  case 16:
					b = 3;
					break;
				}
				c = 11;
				this.el.className = "pcm-ac pcm-n";
			} else {
				if (this.mode == 4 || (this.mode == 16 || this.mode == 32) && g.mainGhostMode == 4 && !this.eatenInThisFrightMode) {
					b = 0;
					c = 8;
					if (g.frightModeTime < g.levels.frightTotalTime - g.levels.frightTime && Math.floor(g.frightModeTime / g.timing[1]) % 2 == 0) {
						b += 2;
					}
					b += Math.floor(g.globalTime / 16) % 2;
				} else {
					if (this.mode == 8 || this.mode == 64) {
						c = this.nextDir;
						if (!c) {
							c = this.dir;
						}
						switch (c) {
						  case 4:
							b = 2;
							break;
						  case 8:
							b = 3;
							break;
						  case 1:
							b = 0;
							break;
						  case 2:
							b = 1;
							break;
						}
						c = 10;
					} else {
						if (this.el.id == "pcm-ghin") {
							b = 6;
							c = 8;
							b += Math.floor(g.globalTime / 16) % 2;
						} else {
							if (this.el.id == "pcm-gbug") {
								b = 6;
								c = 9;
								c += Math.floor(g.globalTime / 16) % 2;
							} else {
								if (this.el.id == "pcm-ghfa") {
									b = g.cutsceneSequenceId == 3 ? 6 : 7;
									c = 11;
								} else {
									if (this.el.id == "pcm-stck") {
										b = g.cutsceneSequenceId == 1 ? g.cutsceneTime > 60 ? 1 : g.cutsceneTime > 45 ? 2 : 3 : g.cutsceneSequenceId == 2 ? 3 : g.cutsceneSequenceId == 3 || g.cutsceneSequenceId == 4 ? 4 : 0;
										c = 13;
									} else {
										c = this.nextDir;
										if (!c || g.playfield[this.tilePos[0]][this.tilePos[1]].type == 1) {
											c = this.dir;
										}
										switch (c) {
										  case 4:
											b = 4;
											break;
										  case 8:
											b = 6;
											break;
										  case 1:
											b = 0;
											break;
										  case 2:
											b = 2;
											break;
										}
										c = 4 + this.id - g.playerCount;
										if (this.speed > 0 || g.gameplayMode != 13) {
											b += Math.floor(g.globalTime / 16) % 2;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		return [c, b];
	};
	E.prototype.b = function () {
		this.k();
		var b = [0, 0];
		b = g.gameplayMode == 8 || g.gameplayMode == 14 ? [0, 3] : this.ghost ? this.r() : this.s();
		if (this.elBackgroundPos[0] != b[0] || this.elBackgroundPos[1] != b[1]) {
			this.elBackgroundPos[0] = b[0];
			this.elBackgroundPos[1] = b[1];
			b[0] *= 16;
			b[1] *= 16;
			g.changeElementBkPos(this.el, b[1], b[0], a);
		}
	};
	g.rand = function () {
		var b = 4294967296, c = 134775813;
		c = c * g.randSeed + 1;
		return (g.randSeed = c % b) / b;
	};
	g.seed = function (b) {
		g.randSeed = b;
	};
	g.getDistance = function (b, c) {
		return Math.sqrt((c[1] - b[1]) * (c[1] - b[1]) + (c[0] - b[0]) * (c[0] - b[0]));
	};
	g.getPlayfieldX = function (b) {
		return b + -32;
	};
	g.getPlayfieldY = function (b) {
		return b + 0;
	};
	g.getCorrectedSpritePos = function (b) {
		return b / 8 * 10 + 2;
	};
	g.getDotElementId = function (b, c) {
		return "pcm-d" + b + "-" + c;
	};
	g.showElementById = function (b, c) {
		var d = document.getElementById(b);
		if (d) {
			d.style.visibility = c ? "visible" : "hidden";
		}
	};
	g.getAbsoluteElPos = function (b) {
		var c = [0, 0];
		do {
			c[0] += b.offsetTop;
			c[1] += b.offsetLeft;
		} while (b = b.offsetParent);
		return c;
	};
	g.prepareElement = function (b, c, d) {
		c = g.getCorrectedSpritePos(parseInt(c, 10));
		d = g.getCorrectedSpritePos(parseInt(d, 10));
		if (g.useCss) {
			b.style.backgroundImage = "url(/logos/pacman10-hp-sprite-2.png)";
			b.style.backgroundPosition = -c + "px " + -d + "px";
			b.style.backgroundRepeat = "no-repeat";
		} else {
			b.style.overflow = "hidden";
			c = "display: block; position: relative; left: " + -c + "px; top: " + -d + "px";
			b.innerHTML = "<img style=\"" + c + "\" src=\"/logos/pacman10-hp-sprite.png\">";
		}
	};
	g.changeElementBkPos = function (b, c, d, f) {
		if (f) {
			c = g.getCorrectedSpritePos(c);
			d = g.getCorrectedSpritePos(d);
		}
		if (g.useCss) {
			b.style.backgroundPosition = -c + "px " + -d + "px";
		} else {
			if (b.childNodes[0]) {
				b.childNodes[0].style.left = -c + "px";
				b.childNodes[0].style.top = -d + "px";
			}
		}
	};
	g.determinePlayfieldDimensions = function () {
		g.playfieldWidth = 0;
		g.playfieldHeight = 0;
		for (var b in n) {
			var c = n[b];
			if (c.w) {
				c = c.x + c.w - 1;
				if (c > g.playfieldWidth) {
					g.playfieldWidth = c;
				}
			} else {
				c = c.y + c.h - 1;
				if (c > g.playfieldHeight) {
					g.playfieldHeight = c;
				}
			}
		}
	};
	g.preparePlayfield = function () {
		g.playfield = [];
		for (var b = 0; b <= g.playfieldHeight + 1; b++) {
			g.playfield[b * 8] = [];
			for (var c = -2; c <= g.playfieldWidth + 1; c++) {
				g.playfield[b * 8][c * 8] = {path:0, dot:0, intersection:0};
			}
		}
	};
	g.preparePaths = function () {
		for (var b in n) {
			var c = n[b], d = c.type;
			if (c.w) {
				for (var f = c.y * 8, h = c.x * 8; h <= (c.x + c.w - 1) * 8; h += 8) {
					g.playfield[f][h].path = a;
					if (g.playfield[f][h].dot == 0) {
						g.playfield[f][h].dot = 1;
						g.dotsRemaining++;
					}
					g.playfield[f][h].type = !d || h != c.x * 8 && h != (c.x + c.w - 1) * 8 ? d : 0;
				}
				g.playfield[f][c.x * 8].intersection = a;
				g.playfield[f][(c.x + c.w - 1) * 8].intersection = a;
			} else {
				h = c.x * 8;
				for (f = c.y * 8; f <= (c.y + c.h - 1) * 8; f += 8) {
					if (g.playfield[f][h].path) {
						g.playfield[f][h].intersection = a;
					}
					g.playfield[f][h].path = a;
					if (g.playfield[f][h].dot == 0) {
						g.playfield[f][h].dot = 1;
						g.dotsRemaining++;
					}
					g.playfield[f][h].type = !d || f != c.y * 8 && f != (c.y + c.h - 1) * 8 ? d : 0;
				}
				g.playfield[c.y * 8][h].intersection = a;
				g.playfield[(c.y + c.h - 1) * 8][h].intersection = a;
			}
		}
		for (b in o) {
			if (o[b].w) {
				for (h = o[b].x * 8; h <= (o[b].x + o[b].w - 1) * 8; h += 8) {
					g.playfield[o[b].y * 8][h].dot = 0;
					g.dotsRemaining--;
				}
			} else {
				for (f = o[b].y * 8; f <= (o[b].y + o[b].h - 1) * 8; f += 8) {
					g.playfield[f][o[b].x * 8].dot = 0;
					g.dotsRemaining--;
				}
			}
		}
	};
	g.prepareAllowedDirections = function () {
		for (var b = 8; b <= g.playfieldHeight * 8; b += 8) {
			for (var c = 8; c <= g.playfieldWidth * 8; c += 8) {
				g.playfield[b][c].allowedDir = 0;
				if (g.playfield[b - 8][c].path) {
					g.playfield[b][c].allowedDir += 1;
				}
				if (g.playfield[b + 8][c].path) {
					g.playfield[b][c].allowedDir += 2;
				}
				if (g.playfield[b][c - 8].path) {
					g.playfield[b][c].allowedDir += 4;
				}
				if (g.playfield[b][c + 8].path) {
					g.playfield[b][c].allowedDir += 8;
				}
			}
		}
	};
	g.createDotElements = function () {
		for (var b = 8; b <= g.playfieldHeight * 8; b += 8) {
			for (var c = 8; c <= g.playfieldWidth * 8; c += 8) {
				if (g.playfield[b][c].dot) {
					var d = document.createElement("div");
					d.className = "pcm-d";
					d.id = g.getDotElementId(b, c);
					d.style.left = c + -32 + "px";
					d.style.top = b + 0 + "px";
					g.playfieldEl.appendChild(d);
				}
			}
		}
	};
	g.createEnergizerElements = function () {
		for (var b in p) {
			var c = p[b], d = g.getDotElementId(c.y * 8, c.x * 8);
			document.getElementById(d).className = "pcm-e";
			g.prepareElement(document.getElementById(d), 0, 144);
			g.playfield[c.y * 8][c.x * 8].dot = 2;
		}
	};
	g.createFruitElement = function () {
		g.fruitEl = document.createElement("div");
		g.fruitEl.id = "pcm-f";
		g.fruitEl.style.left = g.getPlayfieldX(v[1]) + "px";
		g.fruitEl.style.top = g.getPlayfieldY(v[0]) + "px";
		g.prepareElement(g.fruitEl, -32, -16);
		g.playfieldEl.appendChild(g.fruitEl);
	};
	g.createPlayfieldElements = function () {
		g.doorEl = document.createElement("div");
		g.doorEl.id = "pcm-do";
		g.doorEl.style.display = "none";
		g.playfieldEl.appendChild(g.doorEl);
		g.createDotElements();
		g.createEnergizerElements();
		g.createFruitElement();
	};
	g.createActors = function () {
		g.actors = [];
		for (var b = 0; b < g.playerCount + 4; b++) {
			g.actors[b] = new E(b);
			if (b < g.playerCount) {
				g.actors[b].ghost = e;
				g.actors[b].mode = 1;
			} else {
				g.actors[b].ghost = a;
			}
		}
	};
	g.restartActors = function () {
		for (var b in g.actors) {
			g.actors[b].A();
		}
	};
	g.createActorElements = function () {
		for (var b in g.actors) {
			g.actors[b].createElement();
		}
	};
	g.createPlayfield = function () {
		g.playfieldEl = document.createElement("div");
		g.playfieldEl.id = "pcm-p";
		g.canvasEl.appendChild(g.playfieldEl);
	};
	g.resetPlayfield = function () {
		g.dotsRemaining = 0;
		g.dotsEaten = 0;
		g.playfieldEl.innerHTML = "";
		g.prepareElement(g.playfieldEl, 256, 0);
		g.determinePlayfieldDimensions();
		g.preparePlayfield();
		g.preparePaths();
		g.prepareAllowedDirections();
		g.createPlayfieldElements();
		g.createActorElements();
	};
	g.keyPressed = function (b) {
		var c = e;
		switch (b) {
		  case 37:
			g.actors[0].requestedDir = 4;
			c = a;
			break;
		  case 38:
			g.actors[0].requestedDir = 1;
			c = a;
			break;
		  case 39:
			g.actors[0].requestedDir = 8;
			c = a;
			break;
		  case 40:
			g.actors[0].requestedDir = 2;
			c = a;
			break;
		  case 65:
			if (g.playerCount == 2) {
				g.actors[1].requestedDir = 4;
				c = a;
			}
			break;
		  case 83:
			if (g.playerCount == 2) {
				g.actors[1].requestedDir = 2;
				c = a;
			}
			break;
		  case 68:
			if (g.playerCount == 2) {
				g.actors[1].requestedDir = 8;
				c = a;
			}
			break;
		  case 87:
			if (g.playerCount == 2) {
				g.actors[1].requestedDir = 1;
				c = a;
			}
			break;
		}
		return c;
	};
	g.handleKeyDown = function (b) {
		if (!b) {
			b = window.event;
		}
		if (g.keyPressed(b.keyCode)) {
			if (b.preventDefault) {
				b.preventDefault();
			} else {
				b.returnValue = e;
			}
		}
	};
	g.canvasClicked = function (b, c) {
		var d = g.getAbsoluteElPos(g.canvasEl);
		b -= d[1] - -32;
		c -= d[0] - 0;
		d = g.actors[0];
		var f = g.getPlayfieldX(d.pos[1] + d.posDelta[1]) + 16, h = g.getPlayfieldY(d.pos[0] + d.posDelta[0]) + 32, j = Math.abs(b - f), k = Math.abs(c - h);
		if (j > 8 && k < j) {
			d.requestedDir = b > f ? 8 : 4;
		} else {
			if (k > 8 && j < k) {
				d.requestedDir = c > h ? 2 : 1;
			}
		}
	};
	g.handleClick = function (b) {
		if (!b) {
			b = window.event;
		}
		g.canvasClicked(b.clientX, b.clientY);
	};
	g.registerTouch = function () {
		document.body.addEventListener("touchstart", g.handleTouchStart, a);
		g.canvasEl.addEventListener("touchstart", g.handleTouchStart, a);
		document.f && document.f.q && document.f.q.addEventListener("touchstart", g.handleTouchStart, a);
	};
	g.handleTouchStart = function (b) {
		g.touchDX = 0;
		g.touchDY = 0;
		if (b.touches.length == 1) {
			g.touchStartX = b.touches[0].pageX;
			g.touchStartY = b.touches[0].pageY;
			document.body.addEventListener("touchmove", g.handleTouchMove, a);
			document.body.addEventListener("touchend", g.handleTouchEnd, a);
		}
		b.preventDefault();
		b.stopPropagation();
	};
	g.handleTouchMove = function (b) {
		if (b.touches.length > 1) {
			g.cancelTouch();
		} else {
			g.touchDX = b.touches[0].pageX - g.touchStartX;
			g.touchDY = b.touches[0].pageY - g.touchStartY;
		}
		b.preventDefault();
		b.stopPropagation();
	};
	g.handleTouchEnd = function (b) {
		if (g.touchDX == 0 && g.touchDY == 0) {
			g.canvasClicked(g.touchStartX, g.touchStartY);
		} else {
			var c = Math.abs(g.touchDX), d = Math.abs(g.touchDY);
			if (c < 8 && d < 8) {
				g.canvasClicked(g.touchStartX, g.touchStartY);
			} else {
				if (c > 15 && d < c * 2 / 3) {
					g.actors[0].requestedDir = g.touchDX > 0 ? 8 : 4;
				} else {
					if (d > 15 && c < d * 2 / 3) {
						g.actors[0].requestedDir = g.touchDY > 0 ? 2 : 1;
					}
				}
			}
		}
		b.preventDefault();
		b.stopPropagation();
		g.cancelTouch();
	};
	g.cancelTouch = function () {
		document.body.removeEventListener("touchmove", g.handleTouchMove, a);
		document.body.removeEventListener("touchend", g.handleTouchEnd, a);
		g.touchStartX = null;
		g.touchStartY = null;
	};
	g.addEventListeners = function () {
		if (window.addEventListener) {
			window.addEventListener("keydown", g.handleKeyDown, e);
			g.canvasEl.addEventListener("click", g.handleClick, e);
			g.registerTouch();
		} else {
			document.body.attachEvent("onkeydown", g.handleKeyDown);
			g.canvasEl.attachEvent("onclick", g.handleClick);
		}
	};
	g.startGameplay = function () {
		g.score = [0, 0];
		g.extraLifeAwarded = [e, e];
		g.lives = 3;
		g.level = 0;
		g.paused = e;
		g.globalTime = 0;
		g.newLevel(a);
	};
	g.restartGameplay = function (b) {
		g.seed(0);
		g.frightModeTime = 0;
		g.intervalTime = 0;
		g.gameplayModeTime = 0;
		g.fruitTime = 0;
		g.ghostModeSwitchPos = 0;
		g.ghostModeTime = g.levels.ghostModeSwitchTimes[0] * D;
		g.ghostExitingPenNow = e;
		g.ghostEyesCount = 0;
		g.tilesChanged = e;
		g.updateCruiseElroySpeed();
		g.hideFruit();
		g.resetForcePenLeaveTime();
		g.restartActors();
		g.updateActorPositions();
		g.switchMainGhostMode(2, a);
		for (var c = g.playerCount + 1; c < g.playerCount + 4; c++) {
			g.actors[c].a(16);
		}
		g.dotEatingChannel = [0, 0];
		g.dotEatingSoundPart = [1, 1];
		g.clearDotEatingNow();
		b ? g.changeGameplayMode(4) : g.changeGameplayMode(6);
	};
	g.initiateDoubleMode = function () {
		if (g.playerCount != 2) {
			g.stopAllAudio();
			g.changeGameplayMode(12);
		}
	};
	g.newGame = function () {
		g.playerCount = 1;
		g.createChrome();
		g.createPlayfield();
		g.createActors();
		g.startGameplay();
	};
	g.switchToDoubleMode = function () {
		g.playerCount = 2;
		g.createChrome();
		g.createPlayfield();
		g.createActors();
		g.startGameplay();
	};
	g.insertCoin = function () {
		g.gameplayMode == 8 || g.gameplayMode == 14 ? g.newGame() : g.initiateDoubleMode();
	};
	g.createKillScreenElement = function (b, c, d, f, h) {
		var j = document.createElement("div");
		j.style.left = b + "px";
		j.style.top = c + "px";
		j.style.width = d + "px";
		j.style.height = f + "px";
		j.style.zIndex = 119;
		if (h) {
			j.style.background = "url(/logos/pacman10-hp-sprite.png) -" + g.killScreenTileX + "px -" + g.killScreenTileY + "px no-repeat";
			g.killScreenTileY += 8;
		} else {
			j.style.background = "black";
		}
		g.playfieldEl.appendChild(j);
	};
	g.killScreen = function () {
		g.seed(0);
		g.canvasEl.style.visibility = "";
		g.createKillScreenElement(272, 0, 200, 80, e);
		g.createKillScreenElement(280, 80, 192, 56, e);
		g.killScreenTileX = 80;
		g.killScreenTileY = 0;
		for (var b = 280; b <= 472; b += 8) {
			for (var c = 0; c <= 136; c += 8) {
				if (g.rand() < 0.03) {
					g.killScreenTileX = Math.floor(g.rand() * 25) * 10;
					g.killScreenTileY = Math.floor(g.rand() * 2) * 10;
				}
				g.createKillScreenElement(b, c, 8, 8, a);
			}
		}
		g.changeGameplayMode(14);
	};
	g.newLevel = function (b) {
		g.level++;
		g.levels = g.level >= z.length ? z[z.length - 1] : z[g.level];
		g.levels.frightTime = Math.round(g.levels.frightTime * D);
		g.levels.frightTotalTime = g.levels.frightTime + g.timing[1] * (g.levels.frightBlinkCount * 2 - 1);
		for (var c in g.actors) {
			g.actors[c].dotCount = 0;
		}
		g.alternatePenLeavingScheme = e;
		g.lostLifeOnThisLevel = e;
		g.updateChrome();
		g.resetPlayfield();
		g.restartGameplay(b);
		g.level == 256 && g.killScreen();
	};
	g.newLife = function () {
		g.lostLifeOnThisLevel = a;
		g.alternatePenLeavingScheme = a;
		g.alternateDotCount = 0;
		g.lives--;
		g.updateChromeLives();
		g.lives == -1 ? g.changeGameplayMode(8) : g.restartGameplay(e);
	};
	g.switchMainGhostMode = function (b, c) {
		if (b == 4 && g.levels.frightTime == 0) {
			for (var d in g.actors) {
				var f = g.actors[d];
				if (f.ghost) {
					f.reverseDirectionsNext = a;
				}
			}
		} else {
			f = g.mainGhostMode;
			if (b == 4 && g.mainGhostMode != 4) {
				g.lastMainGhostMode = g.mainGhostMode;
			}
			g.mainGhostMode = b;
			if (b == 4 || f == 4) {
				g.playAmbientSound();
			}
			switch (b) {
			  case 1:
			  case 2:
				g.currentPlayerSpeed = g.levels.playerSpeed * 0.8;
				g.currentDotEatingSpeed = g.levels.dotEatingSpeed * 0.8;
				break;
			  case 4:
				g.currentPlayerSpeed = g.levels.playerFrightSpeed * 0.8;
				g.currentDotEatingSpeed = g.levels.dotEatingFrightSpeed * 0.8;
				g.frightModeTime = g.levels.frightTotalTime;
				g.modeScoreMultiplier = 1;
				break;
			}
			for (d in g.actors) {
				f = g.actors[d];
				if (f.ghost) {
					if (b != 64 && !c) {
						f.modeChangedWhileInPen = a;
					}
					if (b == 4) {
						f.eatenInThisFrightMode = e;
					}
					if (f.mode != 8 && f.mode != 16 && f.mode != 32 && f.mode != 128 && f.mode != 64 || c) {
						if (!c && f.mode != 4 && f.mode != b) {
							f.reverseDirectionsNext = a;
						}
						f.a(b);
					}
				} else {
					f.fullSpeed = g.currentPlayerSpeed;
					f.dotEatingSpeed = g.currentDotEatingSpeed;
					f.tunnelSpeed = g.currentPlayerSpeed;
					f.d();
				}
			}
		}
	};
	g.figureOutPenLeaving = function () {
		if (g.alternatePenLeavingScheme) {
			g.alternateDotCount++;
			switch (g.alternateDotCount) {
			  case m[1]:
				g.actors[g.playerCount + 1].freeToLeavePen = a;
				break;
			  case m[2]:
				g.actors[g.playerCount + 2].freeToLeavePen = a;
				break;
			  case m[3]:
				if (g.actors[g.playerCount + 3].mode == 16) {
					g.alternatePenLeavingScheme = e;
				}
				break;
			}
		} else {
			if (g.actors[g.playerCount + 1].mode == 16 || g.actors[g.playerCount + 1].mode == 8) {
				g.actors[g.playerCount + 1].dotCount++;
				if (g.actors[g.playerCount + 1].dotCount >= g.levels.penLeavingLimits[1]) {
					g.actors[g.playerCount + 1].freeToLeavePen = a;
				}
			} else {
				if (g.actors[g.playerCount + 2].mode == 16 || g.actors[g.playerCount + 2].mode == 8) {
					g.actors[g.playerCount + 2].dotCount++;
					if (g.actors[g.playerCount + 2].dotCount >= g.levels.penLeavingLimits[2]) {
						g.actors[g.playerCount + 2].freeToLeavePen = a;
					}
				} else {
					if (g.actors[g.playerCount + 3].mode == 16 || g.actors[g.playerCount + 3].mode == 8) {
						g.actors[g.playerCount + 3].dotCount++;
						if (g.actors[g.playerCount + 3].dotCount >= g.levels.penLeavingLimits[3]) {
							g.actors[g.playerCount + 3].freeToLeavePen = a;
						}
					}
				}
			}
		}
	};
	g.resetForcePenLeaveTime = function () {
		g.forcePenLeaveTime = g.levels.penForceTime * D;
	};
	g.dotEaten = function (b, c) {
		g.dotsRemaining--;
		g.dotsEaten++;
		g.actors[b].c(1);
		g.playDotEatingSound(b);
		if (g.playfield[c[0]][c[1]].dot == 2) {
			g.switchMainGhostMode(4, e);
			g.addToScore(50, b);
		} else {
			g.addToScore(10, b);
		}
		var d = document.getElementById(g.getDotElementId(c[0], c[1]));
		d.style.display = "none";
		g.playfield[c[0]][c[1]].dot = 0;
		g.updateCruiseElroySpeed();
		g.resetForcePenLeaveTime();
		g.figureOutPenLeaving();
		if (g.dotsEaten == 70 || g.dotsEaten == 170) {
			g.showFruit();
		}
		g.dotsRemaining == 0 && g.finishLevel();
		g.playAmbientSound();
	};
	g.getFruitSprite = function (b) {
		var c = b <= 4 ? 128 : 160;
		b = 128 + 16 * ((b - 1) % 4);
		return [c, b];
	};
	g.getFruitScoreSprite = function (b) {
		var c = 128;
		b = 16 * (b - 1);
		return [c, b];
	};
	g.hideFruit = function () {
		g.fruitShown = e;
		g.changeElementBkPos(g.fruitEl, 32, 16, a);
	};
	g.showFruit = function () {
		g.fruitShown = a;
		var b = g.getFruitSprite(g.levels.fruit);
		g.changeElementBkPos(g.fruitEl, b[0], b[1], a);
		g.fruitTime = g.timing[15] + (g.timing[16] - g.timing[15]) * g.rand();
	};
	g.eatFruit = function (b) {
		if (g.fruitShown) {
			g.playSound("fruit", 0);
			g.fruitShown = e;
			var c = g.getFruitScoreSprite(g.levels.fruit);
			g.changeElementBkPos(g.fruitEl, c[0], c[1], a);
			g.fruitTime = g.timing[14];
			g.addToScore(g.levels.fruitScore, b);
		}
	};
	g.updateActorTargetPositions = function () {
		for (var b = g.playerCount; b < g.playerCount + 4; b++) {
			g.actors[b].B();
		}
	};
	g.moveActors = function () {
		for (var b in g.actors) {
			g.actors[b].move();
		}
	};
	g.ghostDies = function (b, c) {
		g.playSound("eating-ghost", 0);
		g.addToScore(200 * g.modeScoreMultiplier, c);
		g.modeScoreMultiplier *= 2;
		g.ghostBeingEatenId = b;
		g.playerEatingGhostId = c;
		g.changeGameplayMode(1);
	};
	g.playerDies = function (b) {
		g.playerDyingId = b;
		g.changeGameplayMode(2);
	};
	g.detectCollisions = function () {
		g.tilesChanged = e;
		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) {
						g.ghostDies(b, c);
						return;
					} 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);
					}
				}
			}
		}
	};
	g.updateCruiseElroySpeed = function () {
		var b = g.levels.ghostSpeed * 0.8;
		if (!g.lostLifeOnThisLevel || g.actors[g.playerCount + 3].mode != 16) {
			var c = g.levels;
			if (g.dotsRemaining < c.elroyDotsLeftPart2) {
				b = c.elroySpeedPart2 * 0.8;
			} else {
				if (g.dotsRemaining < c.elroyDotsLeftPart1) {
					b = c.elroySpeedPart1 * 0.8;
				}
			}
		}
		if (b != g.cruiseElroySpeed) {
			g.cruiseElroySpeed = b;
			g.actors[g.playerCount].d();
		}
	};
	g.getSpeedIntervals = function (b) {
		if (!g.speedIntervals[b]) {
			var c = 0, d = 0;
			g.speedIntervals[b] = [];
			for (var f = 0; f < D; f++) {
				c += b;
				if (Math.floor(c) > d) {
					g.speedIntervals[b].push(a);
					d = Math.floor(c);
				} else {
					g.speedIntervals[b].push(e);
				}
			}
		}
		return g.speedIntervals[b];
	};
	g.finishLevel = function () {
		g.changeGameplayMode(9);
	};
	g.changeGameplayMode = function (b) {
		g.gameplayMode = b;
		if (b != 13) {
			for (var c = 0; c < g.playerCount + 4; c++) {
				g.actors[c].b();
			}
		}
		switch (b) {
		  case 0:
			g.playAmbientSound();
			break;
		  case 2:
			g.stopAllAudio();
			g.gameplayModeTime = g.timing[3];
			break;
		  case 3:
			g.playerDyingId == 0 ? g.playSound("death", 0) : g.playSound("death-double", 0);
			g.gameplayModeTime = g.timing[4];
			break;
		  case 6:
			g.canvasEl.style.visibility = "hidden";
			g.gameplayModeTime = g.timing[5];
			break;
		  case 7:
			g.stopAllAudio();
			g.canvasEl.style.visibility = "";
			g.doorEl.style.display = "block";
			b = document.createElement("div");
			b.id = "pcm-re";
			g.prepareElement(b, 160, 0);
			g.playfieldEl.appendChild(b);
			g.gameplayModeTime = g.timing[6];
			break;
		  case 4:
			g.doorEl.style.display = "block";
			b = document.createElement("div");
			b.id = "pcm-re";
			g.prepareElement(b, 160, 0);
			g.playfieldEl.appendChild(b);
			g.gameplayModeTime = g.timing[7];
			g.stopAllAudio();
			g.playerCount == 2 ? g.playSound("start-music-double", 0, a) : g.playSound("start-music", 0, a);
			break;
		  case 5:
			g.lives--;
			g.updateChromeLives();
			g.gameplayModeTime = g.timing[8];
			break;
		  case 8:
		  case 14:
			b = document.getElementById("pcm-re");
			google.dom.remove(b);
			g.stopAllAudio();
			b = document.createElement("div");
			b.id = "pcm-go";
			g.prepareElement(b, 8, 152);
			g.playfieldEl.appendChild(b);
			g.gameplayModeTime = g.timing[9];
			break;
		  case 9:
			g.stopAllAudio();
			g.gameplayModeTime = g.timing[10];
			break;
		  case 10:
			g.doorEl.style.display = "none";
			g.gameplayModeTime = g.timing[11];
			break;
		  case 11:
			g.canvasEl.style.visibility = "hidden";
			g.gameplayModeTime = g.timing[12];
			break;
		  case 12:
			g.playfieldEl.style.visibility = "hidden";
			g.gameplayModeTime = g.timing[13];
			break;
		  case 1:
			g.gameplayModeTime = g.timing[2];
			break;
		  case 13:
			g.startCutscene();
			break;
		}
	};
	g.showChrome = function (b) {
		g.showElementById("pcm-sc-1-l", b);
		g.showElementById("pcm-sc-2-l", b);
		g.showElementById("pcm-sc-1", b);
		g.showElementById("pcm-sc-2", b);
		g.showElementById("pcm-li", b);
		g.showElementById("pcm-so", b);
	};
	g.toggleSound = function (b) {
		b = window.event || b;
		b.cancelBubble = a;
		if (google.pacManSound) {
			g.userDisabledSound = a;
			g.stopAllAudio();
			google.pacManSound = e;
		} else {
			google.pacManSound = a;
			g.playAmbientSound();
		}
		g.updateSoundIcon();
		return b.returnValue = e;
	};
	g.updateSoundIcon = function () {
		if (g.soundEl) {
			google.pacManSound ? g.changeElementBkPos(g.soundEl, 216, 105, e) : g.changeElementBkPos(g.soundEl, 236, 105, e);
		}
	};
	g.startCutscene = function () {
		g.playfieldEl.style.visibility = "hidden";
		g.canvasEl.style.visibility = "";
		g.showChrome(e);
		g.cutsceneCanvasEl = document.createElement("div");
		g.cutsceneCanvasEl.id = "pcm-cc";
		g.canvasEl.appendChild(g.cutsceneCanvasEl);
		g.cutscene = B[g.cutsceneId];
		g.cutsceneSequenceId = -1;
		g.frightModeTime = g.levels.frightTotalTime;
		g.cutsceneActors = [];
		for (var b in g.cutscene.actors) {
			var c = g.cutscene.actors[b].id;
			if (c > 0) {
				c += g.playerCount - 1;
			}
			var d = document.createElement("div");
			d.className = "pcm-ac";
			d.id = "actor" + c;
			g.prepareElement(d, 0, 0);
			c = new E(c);
			c.el = d;
			c.elBackgroundPos = [0, 0];
			c.elPos = [0, 0];
			c.pos = [g.cutscene.actors[b].y * 8, g.cutscene.actors[b].x * 8];
			c.posDelta = [0, 0];
			c.ghost = g.cutscene.actors[b].ghost;
			g.cutsceneCanvasEl.appendChild(d);
			g.cutsceneActors.push(c);
		}
		g.cutsceneNextSequence();
		g.stopAllAudio();
		g.playAmbientSound();
	};
	g.stopCutscene = function () {
		g.playfieldEl.style.visibility = "";
		google.dom.remove(g.cutsceneCanvasEl);
		g.showChrome(a);
		g.newLevel(e);
	};
	g.cutsceneNextSequence = function () {
		g.cutsceneSequenceId++;
		if (g.cutscene.sequence.length == g.cutsceneSequenceId) {
			g.stopCutscene();
		} else {
			var b = g.cutscene.sequence[g.cutsceneSequenceId];
			g.cutsceneTime = b.time * D;
			for (var c in g.cutsceneActors) {
				var d = g.cutsceneActors[c];
				d.dir = b.moves[c].dir;
				d.speed = b.moves[c].speed;
				if (b.moves[c].elId) {
					d.el.id = b.moves[c].elId;
				}
				if (b.moves[c].mode) {
					d.mode = b.moves[c].mode;
				}
				d.b();
			}
		}
	};
	g.checkCutscene = function () {
		g.cutsceneTime <= 0 && g.cutsceneNextSequence();
	};
	g.advanceCutscene = function () {
		for (var b in g.cutsceneActors) {
			var c = g.cutsceneActors[b], d = l[c.dir];
			c.pos[d.axis] += d.increment * c.speed;
			c.b();
		}
		g.cutsceneTime--;
	};
	g.updateActorPositions = function () {
		for (var b in g.actors) {
			g.actors[b].k();
		}
	};
	g.blinkEnergizers = function () {
		switch (g.gameplayMode) {
		  case 4:
		  case 5:
		  case 6:
		  case 7:
		  case 9:
		  case 10:
		  case 11:
		  case 12:
			g.playfieldEl.className = "";
			break;
		  case 8:
		  case 14:
			g.playfieldEl.className = "blk";
			break;
		  default:
			if (g.globalTime % (g.timing[0] * 2) == 0) {
				g.playfieldEl.className = "";
			} else {
				if (g.globalTime % (g.timing[0] * 2) == g.timing[0]) {
					g.playfieldEl.className = "blk";
				}
			}
			break;
		}
	};
	g.blinkScoreLabels = function () {
		if (g.gameplayMode != 13) {
			var b = "";
			if (g.globalTime % (g.timing[17] * 2) == 0) {
				b = "visible";
			} else {
				if (g.globalTime % (g.timing[17] * 2) == g.timing[17]) {
					b = "hidden";
				}
			}
			if (b) {
				for (var c = 0; c < g.playerCount; c++) {
					g.scoreLabelEl[c].style.visibility = b;
				}
			}
		}
	};
	g.finishFrightMode = function () {
		g.switchMainGhostMode(g.lastMainGhostMode, e);
	};
	g.handleGameplayModeTimer = function () {
		if (g.gameplayModeTime) {
			g.gameplayModeTime--;
			switch (g.gameplayMode) {
			  case 2:
			  case 3:
				for (var b = 0; b < g.playerCount + 4; b++) {
					g.actors[b].b();
				}
				break;
			  case 10:
				Math.floor(g.gameplayModeTime / (g.timing[11] / 8)) % 2 == 0 ? g.changeElementBkPos(g.playfieldEl, 322, 2, e) : g.changeElementBkPos(g.playfieldEl, 322, 138, e);
			}
			if (g.gameplayModeTime <= 0) {
				g.gameplayModeTime = 0;
				switch (g.gameplayMode) {
				  case 1:
					g.changeGameplayMode(0);
					g.ghostEyesCount++;
					g.playAmbientSound();
					g.actors[g.ghostBeingEatenId].el.className = "pcm-ac";
					g.actors[g.ghostBeingEatenId].a(8);
					var c = e;
					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) {
							c = a;
							break;
						}
					}
					c || g.finishFrightMode();
					break;
				  case 2:
					g.changeGameplayMode(3);
					break;
				  case 3:
					g.newLife();
					break;
				  case 4:
					g.changeGameplayMode(5);
					break;
				  case 6:
					g.changeGameplayMode(7);
					break;
				  case 7:
				  case 5:
					b = document.getElementById("pcm-re");
					google.dom.remove(b);
					g.changeGameplayMode(0);
					break;
				  case 8:
					b = document.getElementById("pcm-go");
					google.dom.remove(b);
					google.pacManQuery && google.pacManQuery();
					break;
				  case 9:
					g.changeGameplayMode(10);
					break;
				  case 10:
					g.changeGameplayMode(11);
					break;
				  case 11:
					if (g.levels.cutsceneId) {
						g.cutsceneId = g.levels.cutsceneId;
						g.changeGameplayMode(13);
					} else {
						g.canvasEl.style.visibility = "";
						g.newLevel(e);
					}
					break;
				  case 12:
					g.playfieldEl.style.visibility = "";
					g.canvasEl.style.visibility = "";
					g.switchToDoubleMode();
					break;
				}
			}
		}
	};
	g.handleFruitTimer = function () {
		if (g.fruitTime) {
			g.fruitTime--;
			g.fruitTime <= 0 && g.hideFruit();
		}
	};
	g.handleGhostModeTimer = function () {
		if (g.frightModeTime) {
			g.frightModeTime--;
			if (g.frightModeTime <= 0) {
				g.frightModeTime = 0;
				g.finishFrightMode();
			}
		} else {
			if (g.ghostModeTime > 0) {
				g.ghostModeTime--;
				if (g.ghostModeTime <= 0) {
					g.ghostModeTime = 0;
					g.ghostModeSwitchPos++;
					if (g.levels.ghostModeSwitchTimes[g.ghostModeSwitchPos]) {
						g.ghostModeTime = g.levels.ghostModeSwitchTimes[g.ghostModeSwitchPos] * D;
						switch (g.mainGhostMode) {
						  case 2:
							g.switchMainGhostMode(1, e);
							break;
						  case 1:
							g.switchMainGhostMode(2, e);
							break;
						}
					}
				}
			}
		}
	};
	g.handleForcePenLeaveTimer = function () {
		if (g.forcePenLeaveTime) {
			g.forcePenLeaveTime--;
			if (g.forcePenLeaveTime <= 0) {
				for (var b = 1; b <= 3; b++) {
					if (g.actors[g.playerCount + b].mode == 16) {
						g.actors[g.playerCount + b].freeToLeavePen = a;
						break;
					}
				}
				g.resetForcePenLeaveTime();
			}
		}
	};
	g.handleTimers = function () {
		if (g.gameplayMode == 0) {
			g.handleForcePenLeaveTimer();
			g.handleFruitTimer();
			g.handleGhostModeTimer();
		}
		g.handleGameplayModeTimer();
	};
	g.tick = function () {
		var b = (new Date).getTime();
		g.lastTimeDelta += b - g.lastTime - g.tickInterval;
		if (g.lastTimeDelta > 100) {
			g.lastTimeDelta = 100;
		}
		if (g.canDecreaseFps && g.lastTimeDelta > 50) {
			g.lastTimeSlownessCount++;
			g.lastTimeSlownessCount == 20 && g.decreaseFps();
		}
		var c = 0;
		if (g.lastTimeDelta > g.tickInterval) {
			c = Math.floor(g.lastTimeDelta / g.tickInterval);
			g.lastTimeDelta -= g.tickInterval * c;
		}
		g.lastTime = b;
		if (g.gameplayMode == 13) {
			for (b = 0; b < g.tickMultiplier + c; b++) {
				g.advanceCutscene();
				g.intervalTime = (g.intervalTime + 1) % D;
				g.globalTime++;
			}
			g.checkCutscene();
			g.blinkScoreLabels();
		} else {
			for (b = 0; b < g.tickMultiplier + c; b++) {
				g.moveActors();
				if (g.gameplayMode == 0) {
					if (g.tilesChanged) {
						g.detectCollisions();
						g.updateActorTargetPositions();
					}
				}
				g.globalTime++;
				g.intervalTime = (g.intervalTime + 1) % D;
				g.blinkEnergizers();
				g.blinkScoreLabels();
				g.handleTimers();
			}
		}
	};
	g.extraLife = function (b) {
		g.playSound("extra-life", 0);
		g.extraLifeAwarded[b] = a;
		g.lives++;
		if (g.lives > 5) {
			g.lives = 5;
		}
		g.updateChromeLives();
	};
	g.addToScore = function (b, c) {
		g.score[c] += b;
		!g.extraLifeAwarded[c] && g.score[c] > 10000 && g.extraLife(c);
		g.updateChromeScore(c);
	};
	g.updateChrome = function () {
		g.updateChromeLevel();
		g.updateChromeLives();
		for (var b = 0; b < g.playerCount; b++) {
			g.updateChromeScore(b);
		}
	};
	g.updateChromeScore = function (b) {
		var c = g.score[b].toString();
		if (c.length > g.scoreDigits) {
			c = c.substr(c.length - g.scoreDigits, g.scoreDigits);
		}
		for (var d = 0; d < g.scoreDigits; d++) {
			var f = document.getElementById("pcm-sc-" + (b + 1) + "-" + d), h = c.substr(d, 1);
			h ? g.changeElementBkPos(f, 8 + 8 * parseInt(h, 10), 144, a) : g.changeElementBkPos(f, 48, 0, a);
		}
	};
	g.updateChromeLives = function () {
		g.livesEl.innerHTML = "";
		for (var b = 0; b < g.lives; b++) {
			var c = document.createElement("div");
			c.className = "pcm-lif";
			g.prepareElement(c, 64, 129);
			g.livesEl.appendChild(c);
		}
	};
	g.updateChromeLevel = function () {
		g.levelEl.innerHTML = "";
		for (var b = g.level; b >= Math.max(g.level - 4 + 1, 1); b--) {
			var c = b >= z.length ? z[z.length - 1].fruit : z[b].fruit, d = document.createElement("div");
			c = g.getFruitSprite(c);
			g.prepareElement(d, c[0], c[1]);
			g.levelEl.appendChild(d);
		}
		g.levelEl.style.marginTop = (4 - Math.min(g.level, 4)) * 16 + "px";
	};
	g.createChrome = function () {
		g.canvasEl.innerHTML = "";
		g.scoreDigits = g.playerCount == 1 ? 10 : 5;
		g.scoreLabelEl = [];
		g.scoreLabelEl[0] = document.createElement(

  


  
分享到:
评论

相关推荐

    google吃豆人 js源码

    《谷歌吃豆人游戏的JavaScript实现解析》 谷歌吃豆人,这个经典的街机游戏,以其独特的游戏机制和趣味性,一直以来都深受玩家喜爱。现在,我们可以通过JavaScript语言来实现这个游戏,这为我们提供了深入理解游戏...

    google吃豆人小游戏

    《谷歌吃豆人小游戏》是谷歌为庆祝吃豆人游戏30周年纪念日而特别设计的一款互动Logo。这个游戏源码的公开,对于编程爱好者、游戏开发者以及对谷歌技术感兴趣的朋友们来说,无疑是一份珍贵的学习资源。它展示了谷歌...

    GooglePacMan小游戏吃豆人Logo图标及源代码

    这个小游戏不仅重现了经典的吃豆人游戏玩法,还展示了富有创意的Google Logo设计,巧妙地将游戏元素与搜索引擎的标识相结合。这个项目不仅有趣,还展现了Web开发中的创新精神和技术实力。 **源代码分析** 包含的源...

    谷歌吃豆人30周年logo离线包

    谷歌吃豆人30周年logo离线包是一个纪念性的游戏资源,它反映了互联网巨头谷歌对经典游戏文化的致敬。吃豆人(Pac-Man)作为20世纪80年代诞生的一款街机游戏,以其独特的游戏机制和可爱的形象在全球范围内赢得了广泛...

    HTML5谷歌(Pacman)吃豆人游戏

    HTML5谷歌(Pacman)吃豆人游戏源码,google于5月21日,把主页上加了这个游戏,为了纪念吃豆人30周年,可惜没两天就没了,还没有看到的朋友可以下来看看,看过的也可以收藏下吗,老外那下的。 需要注意的是,这个源...

    google insert coin logo 吃豆人游戏中用到的JS源代码

    google insert coin logo 吃豆人游戏中用到的JS源代码 作研究用

    基于android手机平台的吃豆人游戏设计与开发.doc

    Android是基于Linux内核的开放源代码操作系统,由Google发起并由Open Handset Alliance负责进一步开发和维护。它采用分层架构,包括Linux内核、核心服务层、媒体层和可触摸层。这一平台允许开发者使用Java语言进行...

    参考文档-基于android手机平台的吃豆人游戏设计与开发.zip

    - 角色与敌人行为:编写代码控制吃豆人和鬼魂的移动逻辑,包括碰撞检测和反应机制。 - 音效与音乐:集成音频资源,实现游戏过程中的音效播放。 - 输入处理:监听用户触摸事件,响应角色的移动和旋转操作。 6. **...

    javascript做的谷歌吃豆游戏

    【标题】"javascript做的谷歌吃豆游戏" 描述了一款完全使用JavaScript开发的电子游戏,模仿了经典的“吃豆人”玩法。JavaScript是一种广泛应用于网页和互联网应用开发的编程语言,以其灵活性和强大的功能在创建交互...

    基于android手机平台的吃豆人游戏设计与开发.zip

    在Android手机平台上设计和开发一款基于“吃豆人”(Pac-Man)的经典游戏,是一项融合了移动应用开发、游戏编程、用户界面设计等多方面技术的挑战。本项目主要涵盖了以下几个关键知识点: 1. **Android开发环境搭建...

    毕业论文-基于android手机平台的吃豆人游戏设计与开发.doc

    ### 基于Android手机平台的吃豆人游戏设计与开发 #### 一、选题背景及意义 ##### 1.1 选题背景 随着移动互联网技术的飞速发展和智能终端设备的普及,移动应用开发成为了一个极具前景的研究领域。其中,Android...

    Google PAC-MAN 来源于网络

    PAC-MAN(吃豆人)是一款由日本游戏设计师岩谷彻于1980年开发的经典街机游戏,它在全球范围内产生了深远影响,成为了游戏史上的一个标志性符号。游戏的核心玩法是控制黄色的PAC-MAN角色在迷宫中吃掉所有的点,同时...

    【新品爆款20个python小游戏】pygame小游戏全集,亲测源码可正常运行

    吃豆人小游戏 守护花朵小游戏 连连看小游戏 计算器小游戏 弹球小游戏 小游戏包含以下: 射击达人小游戏 动物对决小游戏 迷宫小游戏 打地鼠小游戏 2048小游戏 贪吃蛇小游戏 扫雷小游戏 滑雪小游戏 飞翔的小鸟小游戏 ...

    webrtc_p2p_pacman:基于webrtc_utils的多人吃豆游戏

    【标题】"webrtc_p2p_pacman"是一款基于`WebRTC`技术的多人在线吃豆游戏,利用了`WebRTC_utils`库来实现实时通信功能。它展示了如何在Dart编程环境中创建一个互动的、P2P(点对点)的网络应用。 【描述】"优步简单...

    Pacman Offline-crx插件

    此外,插件可能还包含了游戏的完整代码和资源,包括音效、图形和逻辑控制,这些都是为了让用户能够在任何环境下都能体验到原汁原味的《吃豆人》。 在技术层面,这款插件可能采用了Chrome扩展程序的API和技术框架,...

    示例:使用案例驱动的示例来使用Puppeteer和无头Chrome

    播放Google吃豆人涂鸦。 将DOM元素转换为PDF。 发现网站上的所有URL并可视化子页面。 并排加载2个或更多页面,以直观地看到页面加载的差异。 可选的桌面视口和限制设置。 执照 :copyright:2018 Google Inc.

    LoadingAnim

    这些动画包括模仿现实世界物体运动的样式,比如齿轮转动,以及一些抽象符号,如WiFi信号图标的变化、吃豆人"EatBean"的趣味动画,甚至知名浏览器Chrome的Logo动态展示。 1. **WiFi信号动画**:这种动画通常用于网络...

    20个pygame小游戏源码大全教学自觉参考使用 保证都能正常运行

    3. **吃豆人**:经典的吃豆游戏,需要理解游戏循环、角色控制和地图导航算法。 4. **守护花朵**:涉及防御机制和敌我目标的智能行为,可能用到简单的AI策略。 5. **连连看**:需要实现图形界面的点击事件处理,...

    Pacfont

    Pacfont这个名字可能源于游戏《吃豆人》(Pac-Man),暗示着这款字体可能带有游戏元素或者复古风格。 在设计领域,Pacfont可能是一种创新的像素艺术字体,用于创建具有复古游戏感觉的设计作品,如海报、T恤图案或者...

Global site tag (gtag.js) - Google Analytics