{"id":54875,"student_id":1976,"content":"redTarget.hidden = false;\nblueTarget.hidden = false;\npinkTarget.hidden = false;\norangeTarget.hidden = false;\n\nvar nextDirection;\nforever(function(){\n if (key.up) nextDirection = 0;\n if (key.right) nextDirection = 90;\n if (key.down) nextDirection = 180;\n if (key.left) nextDirection = 270;\n});\n\n\nplayer.AI = function () {\n var x = player.X;\n var y = player.Y;\n if (map[y - 1][x] == ' ' \u0026\u0026 nextDirection == 0) {\n player.nextDirection = nextDirection;\n }\n else if (map[y][x + 1] == ' ' \u0026\u0026 nextDirection == 90) {\n player.nextDirection = nextDirection;\n }\n else if (map[y + 1][x] == ' ' \u0026\u0026 nextDirection == 180) {\n player.nextDirection = nextDirection;\n }\n else if (map[y][x - 1] == ' ' \u0026\u0026 nextDirection == 270) {\n player.nextDirection = nextDirection;\n }\n else {\n player.nextDirection = player.direction;\n }\n}\n\n/* ========== 預設 AI ========== */\nBlinky.AI = function () {\n var arr = getDirections(Blinky.X, Blinky.Y, Blinky.direction);\n var rand = Math.floor(Math.random()*arr.length);\n Blinky.nextDirection = arr[rand];\n}\n\nPinky.AI = function () {\n var arr = getDirections(Pinky.X, Pinky.Y, Pinky.direction);\n var rand = Math.floor(Math.random()*arr.length);\n Pinky.nextDirection = arr[rand];\n}\n\nInky.AI = function () {\n var arr = getDirections(Inky.X, Inky.Y, Inky.direction);\n var rand = Math.floor(Math.random()*arr.length);\n Inky.nextDirection = arr[rand];\n}\n\nClyde.AI = function () {\n var arr = getDirections(Clyde.X, Clyde.Y, Clyde.direction);\n var rand = Math.floor(Math.random()*arr.length);\n Clyde.nextDirection = arr[rand];\n}\n\n/* ========== 追逐模式下的 AI ========== */\nBlinky.chaseAI = function () {\n redTarget.moveTo(player);\n var arr = getDirections(Blinky.X, Blinky.Y, Blinky.direction);\n Blinky.toward(redTarget);\n Blinky.nextDirection = closest(arr, Blinky.direction);\n}\n\nPinky.chaseAI = function () {\n pinkTarget.moveTo(player);\n pinkTarget.direction = player.direction;\n pinkTarget.stepForward(14*4);\n var arr = getDirections(Pinky.X, Pinky.Y, Pinky.direction);\n Pinky.toward(pinkTarget);\n Pinky.nextDirection = closest(arr, Pinky.direction);\n}\n\nInky.chaseAI = function () {\n blueTarget.moveTo(player);\n blueTarget.direction = player.direction;\n blueTarget.stepForward(14*4);\n blueTarget.toward(Blinky);\n var d = blueTarget.distanceTo(Blinky);\n blueTarget.stepForward(-d);\n var arr = getDirections(Inky.X, Inky.Y, Inky.direction);\n Inky.toward(blueTarget);\n Inky.nextDirection = closest(arr, Inky.direction);\n}\n\nClyde.chaseAI = function () {\n if (Clyde.distanceTo(player) \u003e 8*15) {\n orangeTarget.moveTo(player);\n } else {\n orangeTarget.moveTo(0, 15*33);\n }\n var arr = getDirections(Clyde.X, Clyde.Y, Clyde.direction);\n Clyde.toward(orangeTarget);\n Clyde.nextDirection = closest(arr, Clyde.direction);\n}\n\n/* ========== 巡邏模式下的 AI ========== */\nBlinky.scatterAI = function () {\n redTarget.moveTo(117, 15);\n var arr = getDirections(Blinky.X, Blinky.Y, Blinky.direction);\n Blinky.toward(redTarget);\n Blinky.nextDirection = closest(arr, Blinky.direction);\n}\n\nPinky.scatterAI = function () {\n pinkTarget.moveTo(522, 15);\n var arr = getDirections(Pinky.X, Pinky.Y, Pinky.direction);\n Pinky.toward(pinkTarget);\n Pinky.nextDirection = closest(arr, Pinky.direction);\n}\n\nInky.scatterAI = function () {\n blueTarget.moveTo(117, 465);\n var arr = getDirections(Inky.X, Inky.Y, Inky.direction);\n Inky.toward(blueTarget);\n Inky.nextDirection = closest(arr, Inky.direction);\n}\n\nClyde.scatterAI = function () {\n orangeTarget.moveTo(522, 465);\n var arr = getDirections(Clyde.X, Clyde.Y, Clyde.direction);\n Clyde.toward(orangeTarget);\n Clyde.nextDirection = closest(arr, Clyde.direction);\n}\n\n/* ========== 返回鬼屋模式的 AI ========== */\nBlinky.backToHouseAI = function () {\n redTarget.moveTo(320, 240);\n var arr = getDirections(Blinky.X, Blinky.Y, Blinky.direction);\n Blinky.toward(redTarget);\n Blinky.nextDirection = closest(arr, Blinky.direction);\n}\n\nPinky.backToHouseAI = function () {\n pinkTarget.moveTo(320, 240);\n var arr = getDirections(Pinky.X, Pinky.Y, Pinky.direction);\n Pinky.toward(pinkTarget);\n Pinky.nextDirection = closest(arr, Pinky.direction);\n}\n\nInky.backToHouseAI = function () {\n blueTarget.moveTo(320, 240);\n var arr = getDirections(Inky.X, Inky.Y, Inky.direction);\n Inky.toward(blueTarget);\n Inky.nextDirection = closest(arr, Inky.direction);\n}\n\nClyde.backToHouseAI = function () {\n orangeTarget.moveTo(320, 240);\n var arr = getDirections(Clyde.X, Clyde.Y, Clyde.direction);\n Clyde.toward(orangeTarget);\n Clyde.nextDirection = closest(arr, Clyde.direction);\n}\n\nfunction closest(arr, target) {\n var best;\n var bestDiff = 360;\n for (var i=0; i\u003carr.length; i++) {\n var diff = Math.abs(target - arr[i]);\n if (diff \u003e 180) diff = 360 - diff;\n if (diff \u003c bestDiff) {\n bestDiff = diff;\n best = arr[i];\n }\n }\n return best;\n // arr.sort(function (a, b) {\n // var a = Math.abs(target - a);\n // var b = Math.abs(target - b);\n // if (a \u003e 180) a = 360 - a;\n // if (b \u003e 180) b = 360 - b;\n // return a - b;\n // });\n // return arr[0];\n}\n\nfunction getDirections(x, y, direction) {\n var arr = [];\n if (map[y - 1][x] == ' ' \u0026\u0026 direction != 180) arr.push(0);\n if (map[y][x + 1] == ' ' \u0026\u0026 direction != 270) arr.push(90);\n if (map[y + 1][x] == ' ' \u0026\u0026 direction != 0) arr.push(180);\n if (map[y][x - 1] == ' ' \u0026\u0026 direction != 90) arr.push(270);\n return arr;\n}","created_at":"2019-01-25T12:28:17.423+08:00","updated_at":"2019-11-11T19:48:39.146+08:00","name":"Pac-Man","language":"javascript","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/54875/8a52aaa6300ec3a452931389d21b4b52.jpg"},"parent_id":52859,"plugin":"var MODE; // chase, scatter, frightened\nvar tmpMODE;\nsetBackdrop('black');\nvar width = 15;\nvar offsetX = 110 + 7;\nvar offsetY = 15;\nvar food = [];\nvar level = 1;\nvar score = 0;\nvar timer = 0;\nvar life = 3;\nvar bestScore = 0;\nvar bonus = 100; // 吃掉鬼魂的獎勵\nvar startTime = Date.now();\nvar map = [\n '┏━━━━━━━━━━━━┓┏━━━━━━━━━━━━┓',\n '┃............┃┃............┃',\n '┃.┏━━┓.┏━━━┓.┃┃.┏━━━┓.┏━━┓.┃',\n '┃.┃ ┃.┃ ┃.┃┃.┃ ┃.┃ ┃.┃',\n '┃*┗━━┛.┗━━━┛.┗┛.┗━━━┛.┗━━┛*┃',\n '┃..........................┃',\n '┃.┏━━┓.┏┓.┏━━━━━━┓.┏┓.┏━━┓.┃',\n '┃.┗━━┛.┃┃.┗━━┓┏━━┛.┃┃.┗━━┛.┃',\n '┃......┃┃....┃┃....┃┃......┃',\n '┗━━━━┓.┃┗━━┓.┃┃.┏━━┛┃.┏━━━━┛',\n ' ┃.┃┏━━┛.┗┛.┗━━┓┃.┃ ',\n ' ┃.┃┃ ┃┃.┃ ',\n ' ┃.┃┃ ┏━┓ ┏━┓ ┃┃.┃ ',\n '━━━━━┛.┗┛ ┃┏┛ ┗┓┃ ┗┛.┗━━━━━',\n ' ┃┃ ┃┃ ',\n '━━━━━┓.┏┓ ┃┗━━━━┛┃ ┏┓.┏━━━━━',\n ' ┃.┃┃ ┗━━━━━━┛ ┃┃.┃ ',\n ' ┃.┃┃ ┃┃.┃ ',\n ' ┃.┃┃ ┏━━━━━━┓ ┃┃.┃ ',\n '┏━━━━┛.┗┛ ┗━━┓┏━━┛ ┗┛.┗━━━━┓',\n '┃............┃┃............┃',\n '┃.┏━━┓.┏━━━┓.┃┃.┏━━━┓.┏━━┓.┃',\n '┃.┗━┓┃.┗━━━┛.┃┃.┗━━━┛.┃┏━┛.┃',\n '┃*..┃┃.......┃┃.......┃┃..*┃',\n '┗━┓.┃┃.┏┓.┏━━┛┗━━┓.┏┓.┃┃.┏━┛',\n '┏━┛.┗┛.┃┃.┗━━┓┏━━┛.┃┃.┗┛.┗━┓',\n '┃......┃┃....┃┃....┃┃......┃',\n '┃.┏━━━━┛┗━━┓.┃┃.┏━━┛┗━━━━┓.┃',\n '┃.┗━━━━━━━━┛.┗┛.┗━━━━━━━━┛.┃',\n '┃..........................┃',\n '┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛',\n]\n\nforever(function() {\n print('best: ' + bestScore, 10, 20, 'gold');\n print('score: ' + score, 10, 40, '#fff');\n print('level: ' + level, 10, 60, '#fff');\n print('mode: ' + MODE, 10, 80, '#fff');\n});\n\n// 地圖\nvar grid = (function (M) {\n var grid = {};\n for (var x = 0; x \u003c 28; x++) {\n grid[x] = {};\n for (var y = 0; y \u003c 31; y++) {\n var b = createSprite(['block_1.png', 'block_2.png', 'food.png', 'empty.png']);\n b.x = x*width + offsetX;\n b.y = y*width + offsetY;\n b.role = M[y][x];\n var t = M[y][x];\n b.scale = 1/7;\n b.isWall = ['┃', '━', '┛', '┗', '┏', '┓'].indexOf(t) !== -1\n if (['┃', '━', '┛', '┗', '┏', '┓'].indexOf(t) != -1) b.role = 'x';\n if (t == '━' || t == '┃') b.costumeId = 1;\n if (t == '.' || t == '*') b.costumeId = 2;\n if (t == ' ') b.costumeId = 3;\n if (t == '.') b.scale *= 0.25;\n if (t == '*') b.scale *= 0.5;\n if (t == '━') b.direction = 0;\n if (t == '┓') b.direction = 0;\n if (t == '┗') b.direction = 180;\n if (t == '┏') b.direction = 270;\n if (t == '.' || t == '*') food.push(b);\n grid[x][y] = b;\n }\n }\n\n for (var x = 0; x \u003c 28; x++) {\n for (var y = 0; y \u003c 31; y++) {\n var b = grid[x][y];\n b.count = 0;\n b.X = x;\n b.Y = y;\n if (x \u003e 0 \u0026\u0026 grid[x-1][y] \u0026\u0026 !grid[x-1][y].isWall) {\n b.left = grid[x-1][y];\n b.count++;\n }\n if (x \u003c 27 \u0026\u0026 grid[x+1][y] \u0026\u0026 !grid[x+1][y].isWall) {\n b.right = grid[x+1][y];\n b.count++;\n }\n if (y \u003c 30 \u0026\u0026 grid[x][y+1] \u0026\u0026 !grid[x][y+1].isWall) {\n b.bottom = grid[x][y+1];\n b.count++;\n }\n if (y \u003e 0 \u0026\u0026 grid[x][y-1] \u0026\u0026 !grid[x][y-1].isWall) {\n b.top = grid[x][y-1];\n b.count++;\n }\n }\n }\n\n forever(function() {\n pen.color = 'orange';\n pen.size = 4;\n pen.drawLine(299, 202, 341, 202);\n });\n return grid;\n})(map);\n\n\nfunction Player (costumes) {\n \n var s = createSprite(costumes);\n \n s.rotationStyle = 'fixed';\n s.speed = 1;\n s.X = 0;\n s.Y = 0;\n s.release = false;\n s.target = grid[0][0]; // 要移動到的目標格子\n \n s.mode = 'chase'; // chase, scatter, frightened, dead, leave\n \n s.forever(function() {\n s.updatePosition(); // 移動角色\n s.updateCostume(); // 更新造型\n });\n\n // 更新角色座標,朝著 target 的格子前進\n s.updatePosition = function () {\n\n if (s.release === false || MODE === 'pause') return;\n \n if (this.distanceTo(this.target) \u003e this.speed) {\n this.toward(this.target);\n this.stepForward(this.speed);\n } else {\n this.moveTo(this.target);\n this.X = this.target.X;\n this.Y = this.target.Y;\n this.decision();\n this.updateTarget();\n }\n }\n\n // 執行 AI 相關指令決策出下一個要移動的方向 nextDirection\n s.decision = function () {\n\n if (s.AI) s.AI();\n\n if (s.target.count \u003e= 3) {\n if (this.mode === 'chase' \u0026\u0026 s.chaseAI) s.chaseAI();\n if (this.mode === 'scatter' \u0026\u0026 s.scatterAI) s.scatterAI();\n if (this.mode === 'frightened' \u0026\u0026 s.frightenedAI) s.frightenedAI();\n if (this.mode === 'dead' \u0026\u0026 s.backToHouseAI) s.backToHouseAI();\n }\n \n if (this.mode === 'leave') this.leaveAI();\n }\n \n // 如果有 nextDirection 且是可以行走的格子\n // 更新下一個移動的目標 target\n s.updateTarget = function () {\n if (this.nextDirection == 0 \u0026\u0026 this.target.top) this.target = this.target.top;\n if (this.nextDirection == 90 \u0026\u0026 this.target.right) this.target = this.target.right;\n if (this.nextDirection == 180 \u0026\u0026 this.target.bottom) this.target = this.target.bottom;\n if (this.nextDirection == 270 \u0026\u0026 this.target.left) this.target = this.target.left;\n this.nextDirection = undefined;\n }\n \n // 角色造型切換\u0026移動時的動畫\n s.updateCostume = function () {\n this.costumeId = Math.floor(this.direction/90);\n \n if (this.mode == 'dead') this.costumeId += 8;\n if (this.mode == 'frightened') this.costumeId = 12;\n \n if (this.distanceTo(this.target) == 0) return;\n\n var bool = Math.floor(timer/150)%2 == 0;\n if (bool \u0026\u0026 (this.mode === 'chase' || MODE === 'scatter')) {\n this.costumeId += 4;\n }\n if (bool \u0026\u0026 this.mode === 'frightened') {\n this.costumeId += 1;\n }\n }\n \n // 離開鬼屋\n s.leaveAI = function () {\n if (s.target.top) s.nextDirection = 0;\n else if (s.target.right) s.nextDirection = 90;\n else if (s.target.left) s.nextDirection = 270;\n else s.nextDirection = 180;\n }\n\n // 角色轉向\n s.reverse = function () {\n if (this.direction == 0 \u0026\u0026 this.target.bottom) this.target = this.target.bottom;\n if (this.direction == 90 \u0026\u0026 this.target.left) this.target = this.target.left;\n if (this.direction == 180 \u0026\u0026 this.target.top) this.target = this.target.top;\n if (this.direction == 270 \u0026\u0026 this.target.right) this.target = this.target.right;\n }\n \n s.reset = function (x, y, direction) {\n s.X = x;\n s.Y = y;\n s.direction = direction;\n s.nextDirection = direction;\n s.target = grid[x][y];\n s.moveTo(grid[x][y]);\n }\n\n return s;\n}\n\n// 初始化四隻鬼魂、玩家角色\nvar Clyde = Player(['o1.png', 'o2.png', 'o3.png', 'o4.png', 'o5.png', 'o6.png', 'o7.png', 'o8.png', 'o9.png', 'o10.png', 'o11.png', 'o12.png', 'f13.png', 'f14.png']);\nvar Inky = Player(['b1.png', 'b2.png', 'b3.png', 'b4.png', 'b5.png', 'b6.png', 'b7.png', 'b8.png', 'b9.png', 'b10.png', 'b11.png', 'b12.png', 'f13.png', 'f14.png']);\nvar Pinky = Player(['p1.png', 'p2.png', 'p3.png', 'p4.png', 'p5.png', 'p6.png', 'p7.png', 'p8.png', 'p9.png', 'p10.png', 'p11.png', 'p12.png', 'f13.png', 'f14.png']);\nvar Blinky = Player(['r1.png', 'r2.png', 'r3.png', 'r4.png', 'r5.png', 'r6.png', 'r7.png', 'r8.png', 'r9.png', 'r10.png', 'r11.png', 'r12.png', 'f13.png', 'f14.png']);\nvar player = Player(['player_1.png', 'player.png', 'player_3.png', 'player_4.png', 'player_5.png', 'player_6.png', 'player_7.png', 'player_8.png', 'player_8.png', 'player_8.png', 'player_8.png', 'player_8.png', 'player_8.png', 'player_8.png']);\nvar ghosts = [Blinky, Inky, Pinky, Clyde];\n\nfunction restart () {\n MODE = 'pause';\n setTimeout(() =\u003e MODE='scatter', 2000);\n startTime = Date.now();\n Blinky.reset(12, 14, 90);\n Pinky.reset(13, 14, 90);\n Inky.reset(14, 14, 90);\n Clyde.reset(15, 14, 90);\n player.reset(13, 17, 90);\n}\nrestart();\n\nplayer.scale = 2;\nplayer.release = true;\nghosts.forEach((g) =\u003e g.scale = 0.23);\n\n// 神奇的傳送門\nghosts.concat(player).forEach((s) =\u003e {\n s.forever(function () {\n if (s.X == 1 \u0026\u0026 s.Y == 14 \u0026\u0026 s.distanceTo(grid[1][14]) == 0) {\n s.target = grid[25][14];\n s.moveTo(grid[26][14]);\n }\n if (s.X == 26 \u0026\u0026 s.Y == 14 \u0026\u0026 s.distanceTo(grid[26][14]) == 0) {\n s.target = grid[2][14];\n s.moveTo(grid[1][14]);\n }\n });\n});\n\n// 更新鬼魂的模式\nforever(function () {\n ghosts.forEach(function (g) {\n if (g.release === false) return g.mode = '';\n \n if (g.distanceTo(player) \u003c width) {\n if (g.mode === 'frightened') {\n score += bonus;\n bonus *= 2;\n g.mode = 'dead';\n createText('+'+bonus, g.x, g.y);\n }\n \n if (MODE !== 'frightened') {\n restart();\n life -= 1;\n if (life \u003c 0) {\n if (score \u003e bestScore) bestScore = score;\n life = 3;\n level = 1;\n }\n }\n }\n \n if (g.mode !== 'dead') g.mode = MODE;\n \n if (g.x \u003e 270 \u0026\u0026 g.x \u003c 370 \u0026\u0026 g.y \u003e 190 \u0026\u0026 g.y \u003c 240) {\n g.mode = 'leave';\n }\n })\n});\n\nforever(function() {\n \n // 如果切換模式則鬼魂進行轉向\n if (tmpMODE !== MODE) {\n bonus = 100; // 疊加獎勵恢復成 100\n ghosts.forEach(function (g) {g.reverse()});\n }\n tmpMODE = MODE;\n \n if (MODE == 'pause') return;\n \n // 遊戲經過時間\n timer = Date.now() - startTime;\n\n if (MODE == 'frightened') return;\n \n // level 1\n if (level == 1) {\n if (timer \u003c 7000) MODE = 'scatter';\n else if (timer \u003c 27000) MODE = 'chase';\n else if (timer \u003c 34000) MODE = 'scatter';\n else if (timer \u003c 54000) MODE = 'chase';\n else if (timer \u003c 59000) MODE = 'scatter';\n else if (timer \u003c 79000) MODE = 'chase';\n else if (timer \u003c 84000) MODE = 'scatter';\n else MODE = 'chase';\n // level 2 ~ 4\n } else if (level \u003c 5) {\n if (timer \u003c 7000) MODE = 'scatter';\n else if (timer \u003c 27000) MODE = 'chase';\n else if (timer \u003c 34000) MODE = 'scatter';\n else if (timer \u003c 54000) MODE = 'chase';\n else if (timer \u003c 59000) MODE = 'scatter';\n else if (timer \u003c 79000) MODE = 'chase';\n else if (timer \u003c 84000) MODE = 'scatter';\n else MODE = 'chase';\n // level 5 以上\n } else {\n if (timer \u003c 7000) MODE = 'scatter';\n else if (timer \u003c 27000) MODE = 'chase';\n else if (timer \u003c 34000) MODE = 'scatter';\n else if (timer \u003c 54000) MODE = 'chase';\n else if (timer \u003c 59000) MODE = 'scatter';\n else if (timer \u003c 79000) MODE = 'chase';\n else if (timer \u003c 84000) MODE = 'scatter';\n else MODE = 'chase';\n }\n\n Blinky.release = timer \u003e 0;\n Pinky.release = timer \u003e 5000;\n Inky.release = timer \u003e 8000;\n Clyde.release = timer \u003e 11000;\n});\n\nforever(function() {\n var limit = 2;\n var playerSpeed;\n var ghostsSpeed;\n // level 1\n if (level == 1) {\n if (MODE == 'frightened') {\n playerSpeed = limit*0.9;\n ghostsSpeed = limit*0.5;\n } else {\n playerSpeed = limit*0.8;\n ghostsSpeed = limit*0.75;\n }\n }\n // level 2 ~ 4\n else if (level \u003c 5) {\n if (MODE == 'frightened') {\n playerSpeed = limit*0.95;\n ghostsSpeed = limit*0.55;\n } else {\n playerSpeed = limit*0.9;\n ghostsSpeed = limit*0.85;\n }\n }\n // level \u003e= 5\n else {\n if (MODE == 'frightened') {\n playerSpeed = limit*1.0;\n ghostsSpeed = limit*0.6;\n } else {\n playerSpeed = limit*1.0;\n ghostsSpeed = limit*0.95;\n }\n }\n ghosts.forEach((g) =\u003e {\n if (g.mode == 'dead') g.speed = 10;\n else g.speed = ghostsSpeed;\n });\n player.speed = playerSpeed;\n});\n\nforever(function() {\n var success = true;\n food.forEach((f) =\u003e {\n success = f.hidden \u0026\u0026 success;\n if (!f.hidden \u0026\u0026 f.distanceTo(player) \u003c 5) {\n f.hidden = true;\n score += 10;\n if (f.role == '*') {\n MODE = 'frightened';\n setTimeout(function() {\n MODE = '';\n }, 8000);\n }\n }\n });\n if (success) nextLevel();\n});\n\nvar texts = [];\nfunction createText (text, x, y) {\n texts.push([text, x, y]);\n setTimeout(function () {\n texts.shift();\n }, 2000);\n forever(function(){\n texts.forEach(function (t) {\n print(t[0], t[1] - width, t[2] - width/2, 'lightblue', 14);\n });\n });\n}\n\nfunction nextLevel() {\n for (var x = 0; x \u003c 28; x++) {\n for (var y = 0; y \u003c 31; y++) {\n grid[x][y].hidden = false;\n }\n }\n restart();\n level++;\n}\n\n// 標記\nvar redTarget = createSprite('red_target.png');\nvar pinkTarget = createSprite('pink.png');\nvar blueTarget = createSprite('blue_target.png');\nvar orangeTarget = createSprite('orange_target.png');\n[redTarget, pinkTarget, blueTarget, orangeTarget].forEach((t) =\u003e {\n t.scale = 1.2/7;\n t.rotationStyle = 'fixed';\n t.hidden = true;\n});\n\nfor (var x=0; x\u003c31; x++) {\n for (var y=0; y\u003c28; y++) {\n if (map[x][y] == '.' || map[x][y] == '*') {\n map[x] = map[x].substr(0, y) + ' ' + map[x].substr(y + 1)\n }\n } \n}\n\n// 顯示剩餘生命\nvar lifes = [\n createSprite('player.png'),\n createSprite('player.png'),\n createSprite('player.png'),\n];\nfor (var i=0; i\u003c3; i++) {\n lifes[i].moveTo(80, 350 + 40*i);\n lifes[i].scale = 2;\n}\nforever(function(){\n if (life \u003c= 0) lifes[2].hidden = true;\n if (life \u003c= 1) lifes[1].hidden = true;\n if (life \u003c= 2) lifes[0].hidden = true;\n});\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":800,"hashid":"qmds9nr3","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":976997,"file_name":"o9.png","project_id":54875,"asset_id":105480,"created_at":"2019-01-25T12:28:17.429+08:00","updated_at":"2019-01-25T12:28:17.429+08:00"},{"id":976998,"file_name":"o12.png","project_id":54875,"asset_id":105481,"created_at":"2019-01-25T12:28:17.431+08:00","updated_at":"2019-01-25T12:28:17.431+08:00"},{"id":976999,"file_name":"o11.png","project_id":54875,"asset_id":105482,"created_at":"2019-01-25T12:28:17.432+08:00","updated_at":"2019-01-25T12:28:17.432+08:00"},{"id":977000,"file_name":"o10.png","project_id":54875,"asset_id":105483,"created_at":"2019-01-25T12:28:17.432+08:00","updated_at":"2019-01-25T12:28:17.432+08:00"},{"id":977001,"file_name":"r8.png","project_id":54875,"asset_id":105484,"created_at":"2019-01-25T12:28:17.433+08:00","updated_at":"2019-01-25T12:28:17.433+08:00"},{"id":977002,"file_name":"r7.png","project_id":54875,"asset_id":105485,"created_at":"2019-01-25T12:28:17.435+08:00","updated_at":"2019-01-25T12:28:17.435+08:00"},{"id":977003,"file_name":"r6.png","project_id":54875,"asset_id":105486,"created_at":"2019-01-25T12:28:17.436+08:00","updated_at":"2019-01-25T12:28:17.436+08:00"},{"id":977004,"file_name":"r5.png","project_id":54875,"asset_id":105487,"created_at":"2019-01-25T12:28:17.436+08:00","updated_at":"2019-01-25T12:28:17.436+08:00"},{"id":977005,"file_name":"r4.png","project_id":54875,"asset_id":105488,"created_at":"2019-01-25T12:28:17.437+08:00","updated_at":"2019-01-25T12:28:17.437+08:00"},{"id":977006,"file_name":"r3.png","project_id":54875,"asset_id":105489,"created_at":"2019-01-25T12:28:17.438+08:00","updated_at":"2019-01-25T12:28:17.438+08:00"},{"id":977007,"file_name":"r2.png","project_id":54875,"asset_id":105490,"created_at":"2019-01-25T12:28:17.439+08:00","updated_at":"2019-01-25T12:28:17.439+08:00"},{"id":977008,"file_name":"r1.png","project_id":54875,"asset_id":105491,"created_at":"2019-01-25T12:28:17.440+08:00","updated_at":"2019-01-25T12:28:17.440+08:00"},{"id":977009,"file_name":"r9.png","project_id":54875,"asset_id":105492,"created_at":"2019-01-25T12:28:17.441+08:00","updated_at":"2019-01-25T12:28:17.441+08:00"},{"id":977010,"file_name":"r10.png","project_id":54875,"asset_id":105493,"created_at":"2019-01-25T12:28:17.442+08:00","updated_at":"2019-01-25T12:28:17.442+08:00"},{"id":977011,"file_name":"r12.png","project_id":54875,"asset_id":105494,"created_at":"2019-01-25T12:28:17.443+08:00","updated_at":"2019-01-25T12:28:17.443+08:00"},{"id":977012,"file_name":"r11.png","project_id":54875,"asset_id":105495,"created_at":"2019-01-25T12:28:17.444+08:00","updated_at":"2019-01-25T12:28:17.444+08:00"},{"id":977013,"file_name":"p12.png","project_id":54875,"asset_id":105496,"created_at":"2019-01-25T12:28:17.445+08:00","updated_at":"2019-01-25T12:28:17.445+08:00"},{"id":977014,"file_name":"p11.png","project_id":54875,"asset_id":105497,"created_at":"2019-01-25T12:28:17.446+08:00","updated_at":"2019-01-25T12:28:17.446+08:00"},{"id":977015,"file_name":"p10.png","project_id":54875,"asset_id":105498,"created_at":"2019-01-25T12:28:17.447+08:00","updated_at":"2019-01-25T12:28:17.447+08:00"},{"id":977016,"file_name":"p9.png","project_id":54875,"asset_id":105499,"created_at":"2019-01-25T12:28:17.447+08:00","updated_at":"2019-01-25T12:28:17.447+08:00"},{"id":977017,"file_name":"p8.png","project_id":54875,"asset_id":105500,"created_at":"2019-01-25T12:28:17.448+08:00","updated_at":"2019-01-25T12:28:17.448+08:00"},{"id":977018,"file_name":"p7.png","project_id":54875,"asset_id":105501,"created_at":"2019-01-25T12:28:17.449+08:00","updated_at":"2019-01-25T12:28:17.449+08:00"},{"id":977019,"file_name":"p6.png","project_id":54875,"asset_id":105502,"created_at":"2019-01-25T12:28:17.450+08:00","updated_at":"2019-01-25T12:28:17.450+08:00"},{"id":977020,"file_name":"p5.png","project_id":54875,"asset_id":105503,"created_at":"2019-01-25T12:28:17.451+08:00","updated_at":"2019-01-25T12:28:17.451+08:00"},{"id":977021,"file_name":"p4.png","project_id":54875,"asset_id":105504,"created_at":"2019-01-25T12:28:17.452+08:00","updated_at":"2019-01-25T12:28:17.452+08:00"},{"id":977022,"file_name":"p3.png","project_id":54875,"asset_id":105505,"created_at":"2019-01-25T12:28:17.453+08:00","updated_at":"2019-01-25T12:28:17.453+08:00"},{"id":977023,"file_name":"p2.png","project_id":54875,"asset_id":105506,"created_at":"2019-01-25T12:28:17.454+08:00","updated_at":"2019-01-25T12:28:17.454+08:00"},{"id":977024,"file_name":"p1.png","project_id":54875,"asset_id":105507,"created_at":"2019-01-25T12:28:17.454+08:00","updated_at":"2019-01-25T12:28:17.454+08:00"},{"id":977025,"file_name":"o8.png","project_id":54875,"asset_id":105508,"created_at":"2019-01-25T12:28:17.455+08:00","updated_at":"2019-01-25T12:28:17.455+08:00"},{"id":977026,"file_name":"o7.png","project_id":54875,"asset_id":105509,"created_at":"2019-01-25T12:28:17.456+08:00","updated_at":"2019-01-25T12:28:17.456+08:00"},{"id":977027,"file_name":"o6.png","project_id":54875,"asset_id":105510,"created_at":"2019-01-25T12:28:17.457+08:00","updated_at":"2019-01-25T12:28:17.457+08:00"},{"id":977028,"file_name":"o5.png","project_id":54875,"asset_id":105511,"created_at":"2019-01-25T12:28:17.458+08:00","updated_at":"2019-01-25T12:28:17.458+08:00"},{"id":977029,"file_name":"o4.png","project_id":54875,"asset_id":105512,"created_at":"2019-01-25T12:28:17.459+08:00","updated_at":"2019-01-25T12:28:17.459+08:00"},{"id":977030,"file_name":"o3.png","project_id":54875,"asset_id":105513,"created_at":"2019-01-25T12:28:17.459+08:00","updated_at":"2019-01-25T12:28:17.459+08:00"},{"id":977031,"file_name":"o2.png","project_id":54875,"asset_id":105514,"created_at":"2019-01-25T12:28:17.460+08:00","updated_at":"2019-01-25T12:28:17.460+08:00"},{"id":977032,"file_name":"o1.png","project_id":54875,"asset_id":105515,"created_at":"2019-01-25T12:28:17.461+08:00","updated_at":"2019-01-25T12:28:17.461+08:00"},{"id":977033,"file_name":"f14.png","project_id":54875,"asset_id":105516,"created_at":"2019-01-25T12:28:17.462+08:00","updated_at":"2019-01-25T12:28:17.462+08:00"},{"id":977034,"file_name":"f13.png","project_id":54875,"asset_id":105517,"created_at":"2019-01-25T12:28:17.463+08:00","updated_at":"2019-01-25T12:28:17.463+08:00"},{"id":977035,"file_name":"b12.png","project_id":54875,"asset_id":105518,"created_at":"2019-01-25T12:28:17.464+08:00","updated_at":"2019-01-25T12:28:17.464+08:00"},{"id":977036,"file_name":"b11.png","project_id":54875,"asset_id":105519,"created_at":"2019-01-25T12:28:17.465+08:00","updated_at":"2019-01-25T12:28:17.465+08:00"},{"id":977037,"file_name":"b10.png","project_id":54875,"asset_id":105520,"created_at":"2019-01-25T12:28:17.466+08:00","updated_at":"2019-01-25T12:28:17.466+08:00"},{"id":977038,"file_name":"b9.png","project_id":54875,"asset_id":105521,"created_at":"2019-01-25T12:28:17.467+08:00","updated_at":"2019-01-25T12:28:17.467+08:00"},{"id":977039,"file_name":"b8.png","project_id":54875,"asset_id":105522,"created_at":"2019-01-25T12:28:17.467+08:00","updated_at":"2019-01-25T12:28:17.467+08:00"},{"id":977040,"file_name":"b7.png","project_id":54875,"asset_id":105523,"created_at":"2019-01-25T12:28:17.468+08:00","updated_at":"2019-01-25T12:28:17.468+08:00"},{"id":977041,"file_name":"b6.png","project_id":54875,"asset_id":105524,"created_at":"2019-01-25T12:28:17.469+08:00","updated_at":"2019-01-25T12:28:17.469+08:00"},{"id":977042,"file_name":"b5.png","project_id":54875,"asset_id":105525,"created_at":"2019-01-25T12:28:17.470+08:00","updated_at":"2019-01-25T12:28:17.470+08:00"},{"id":977043,"file_name":"b4.png","project_id":54875,"asset_id":105526,"created_at":"2019-01-25T12:28:17.471+08:00","updated_at":"2019-01-25T12:28:17.471+08:00"},{"id":977044,"file_name":"b3.png","project_id":54875,"asset_id":105527,"created_at":"2019-01-25T12:28:17.472+08:00","updated_at":"2019-01-25T12:28:17.472+08:00"},{"id":977045,"file_name":"b2.png","project_id":54875,"asset_id":105528,"created_at":"2019-01-25T12:28:17.473+08:00","updated_at":"2019-01-25T12:28:17.473+08:00"},{"id":977046,"file_name":"b1.png","project_id":54875,"asset_id":105529,"created_at":"2019-01-25T12:28:17.474+08:00","updated_at":"2019-01-25T12:28:17.474+08:00"},{"id":977047,"file_name":"blue_target.png","project_id":54875,"asset_id":105530,"created_at":"2019-01-25T12:28:17.475+08:00","updated_at":"2019-01-25T12:28:17.475+08:00"},{"id":977048,"file_name":"pink.png","project_id":54875,"asset_id":105531,"created_at":"2019-01-25T12:28:17.475+08:00","updated_at":"2019-01-25T12:28:17.475+08:00"},{"id":977049,"file_name":"orange_target.png","project_id":54875,"asset_id":105532,"created_at":"2019-01-25T12:28:17.476+08:00","updated_at":"2019-01-25T12:28:17.476+08:00"},{"id":977050,"file_name":"red_target.png","project_id":54875,"asset_id":105533,"created_at":"2019-01-25T12:28:17.477+08:00","updated_at":"2019-01-25T12:28:17.477+08:00"},{"id":977051,"file_name":"food.png","project_id":54875,"asset_id":105534,"created_at":"2019-01-25T12:28:17.478+08:00","updated_at":"2019-01-25T12:28:17.478+08:00"},{"id":977052,"file_name":"block_2.png","project_id":54875,"asset_id":105535,"created_at":"2019-01-25T12:28:17.479+08:00","updated_at":"2019-01-25T12:28:17.479+08:00"},{"id":977053,"file_name":"block_1.png","project_id":54875,"asset_id":105536,"created_at":"2019-01-25T12:28:17.480+08:00","updated_at":"2019-01-25T12:28:17.480+08:00"},{"id":977054,"file_name":"empty.png","project_id":54875,"asset_id":105537,"created_at":"2019-01-25T12:28:17.481+08:00","updated_at":"2019-01-25T12:28:17.481+08:00"},{"id":977055,"file_name":"player.png","project_id":54875,"asset_id":105538,"created_at":"2019-01-25T12:28:17.482+08:00","updated_at":"2019-01-25T12:28:17.482+08:00"},{"id":977056,"file_name":"player_4.png","project_id":54875,"asset_id":105539,"created_at":"2019-01-25T12:28:17.483+08:00","updated_at":"2019-01-25T12:28:17.483+08:00"},{"id":977057,"file_name":"player_1.png","project_id":54875,"asset_id":105540,"created_at":"2019-01-25T12:28:17.483+08:00","updated_at":"2019-01-25T12:28:17.483+08:00"},{"id":977058,"file_name":"player_3.png","project_id":54875,"asset_id":105541,"created_at":"2019-01-25T12:28:17.485+08:00","updated_at":"2019-01-25T12:28:17.485+08:00"},{"id":977059,"file_name":"player_8.png","project_id":54875,"asset_id":105542,"created_at":"2019-01-25T12:28:17.486+08:00","updated_at":"2019-01-25T12:28:17.486+08:00"},{"id":977060,"file_name":"player_6.png","project_id":54875,"asset_id":105543,"created_at":"2019-01-25T12:28:17.486+08:00","updated_at":"2019-01-25T12:28:17.486+08:00"},{"id":977061,"file_name":"player_5.png","project_id":54875,"asset_id":105544,"created_at":"2019-01-25T12:28:17.487+08:00","updated_at":"2019-01-25T12:28:17.487+08:00"},{"id":977062,"file_name":"player_7.png","project_id":54875,"asset_id":105545,"created_at":"2019-01-25T12:28:17.488+08:00","updated_at":"2019-01-25T12:28:17.488+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦