{"id":51242,"student_id":10,"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\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":"2018-12-05T16:35:30.407+08:00","updated_at":"2021-09-16T12:05:10.529+08:00","name":"小精靈","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/51242/27faa668d6047935729aa4aa735dfdc8.jpg"},"parent_id":2,"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\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":320,"hashid":"5j3svz83","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":914528,"file_name":"player_7.png","project_id":51242,"asset_id":101888,"created_at":"2018-12-06T10:19:17.675+08:00","updated_at":"2018-12-06T10:19:17.675+08:00"},{"id":914529,"file_name":"player_5.png","project_id":51242,"asset_id":101889,"created_at":"2018-12-06T10:19:17.950+08:00","updated_at":"2018-12-06T10:19:17.950+08:00"},{"id":914530,"file_name":"player_6.png","project_id":51242,"asset_id":101890,"created_at":"2018-12-06T10:19:17.953+08:00","updated_at":"2018-12-06T10:19:17.953+08:00"},{"id":914531,"file_name":"player_8.png","project_id":51242,"asset_id":101891,"created_at":"2018-12-06T10:19:18.400+08:00","updated_at":"2018-12-06T10:19:18.400+08:00"},{"id":914532,"file_name":"player_3.png","project_id":51242,"asset_id":101892,"created_at":"2018-12-06T10:19:18.402+08:00","updated_at":"2018-12-06T10:19:18.402+08:00"},{"id":914533,"file_name":"player_1.png","project_id":51242,"asset_id":101893,"created_at":"2018-12-06T10:19:18.639+08:00","updated_at":"2018-12-06T10:19:18.639+08:00"},{"id":914535,"file_name":"player_4.png","project_id":51242,"asset_id":101895,"created_at":"2018-12-06T10:19:18.836+08:00","updated_at":"2018-12-06T10:19:18.836+08:00"},{"id":914539,"file_name":"player.png","project_id":51242,"asset_id":101894,"created_at":"2018-12-06T10:27:07.863+08:00","updated_at":"2018-12-06T10:27:54.759+08:00"},{"id":914526,"file_name":"empty.png","project_id":51242,"asset_id":101886,"created_at":"2018-12-05T22:55:25.112+08:00","updated_at":"2018-12-06T15:30:13.509+08:00"},{"id":914728,"file_name":"block_1.png","project_id":51242,"asset_id":101978,"created_at":"2018-12-07T15:32:54.890+08:00","updated_at":"2018-12-07T15:32:54.890+08:00"},{"id":914729,"file_name":"block_2.png","project_id":51242,"asset_id":101979,"created_at":"2018-12-07T15:33:22.863+08:00","updated_at":"2018-12-07T15:33:22.863+08:00"},{"id":914730,"file_name":"food.png","project_id":51242,"asset_id":101980,"created_at":"2018-12-07T15:34:42.150+08:00","updated_at":"2018-12-07T15:34:42.150+08:00"},{"id":914731,"file_name":"red_target.png","project_id":51242,"asset_id":101981,"created_at":"2018-12-07T15:39:36.225+08:00","updated_at":"2018-12-07T15:39:36.225+08:00"},{"id":914732,"file_name":"orange_target.png","project_id":51242,"asset_id":101982,"created_at":"2018-12-07T15:39:36.227+08:00","updated_at":"2018-12-07T15:39:36.227+08:00"},{"id":914734,"file_name":"blue_target.png","project_id":51242,"asset_id":101984,"created_at":"2018-12-07T15:39:36.775+08:00","updated_at":"2018-12-07T15:39:36.775+08:00"},{"id":914733,"file_name":"pink.png","project_id":51242,"asset_id":101983,"created_at":"2018-12-07T15:39:36.773+08:00","updated_at":"2018-12-07T17:30:46.808+08:00"},{"id":922492,"file_name":"b1.png","project_id":51242,"asset_id":102348,"created_at":"2018-12-08T13:52:03.270+08:00","updated_at":"2018-12-08T13:52:03.270+08:00"},{"id":922493,"file_name":"b2.png","project_id":51242,"asset_id":102349,"created_at":"2018-12-08T13:52:03.273+08:00","updated_at":"2018-12-08T13:52:03.273+08:00"},{"id":922494,"file_name":"b3.png","project_id":51242,"asset_id":102350,"created_at":"2018-12-08T13:52:03.542+08:00","updated_at":"2018-12-08T13:52:03.542+08:00"},{"id":922495,"file_name":"b4.png","project_id":51242,"asset_id":102351,"created_at":"2018-12-08T13:52:03.544+08:00","updated_at":"2018-12-08T13:52:03.544+08:00"},{"id":922496,"file_name":"b5.png","project_id":51242,"asset_id":102352,"created_at":"2018-12-08T13:52:03.851+08:00","updated_at":"2018-12-08T13:52:03.851+08:00"},{"id":922497,"file_name":"b6.png","project_id":51242,"asset_id":102353,"created_at":"2018-12-08T13:52:03.853+08:00","updated_at":"2018-12-08T13:52:03.853+08:00"},{"id":922498,"file_name":"b7.png","project_id":51242,"asset_id":102354,"created_at":"2018-12-08T13:52:04.101+08:00","updated_at":"2018-12-08T13:52:04.101+08:00"},{"id":922499,"file_name":"b8.png","project_id":51242,"asset_id":102355,"created_at":"2018-12-08T13:52:04.104+08:00","updated_at":"2018-12-08T13:52:04.104+08:00"},{"id":922500,"file_name":"b9.png","project_id":51242,"asset_id":102356,"created_at":"2018-12-08T13:52:04.381+08:00","updated_at":"2018-12-08T13:52:04.381+08:00"},{"id":922501,"file_name":"b10.png","project_id":51242,"asset_id":102357,"created_at":"2018-12-08T13:52:04.383+08:00","updated_at":"2018-12-08T13:52:04.383+08:00"},{"id":922502,"file_name":"b11.png","project_id":51242,"asset_id":102358,"created_at":"2018-12-08T13:52:04.676+08:00","updated_at":"2018-12-08T13:52:04.676+08:00"},{"id":922503,"file_name":"b12.png","project_id":51242,"asset_id":102359,"created_at":"2018-12-08T13:52:04.679+08:00","updated_at":"2018-12-08T13:52:04.679+08:00"},{"id":922504,"file_name":"f13.png","project_id":51242,"asset_id":102360,"created_at":"2018-12-08T13:52:04.960+08:00","updated_at":"2018-12-08T13:52:04.960+08:00"},{"id":922505,"file_name":"f14.png","project_id":51242,"asset_id":102361,"created_at":"2018-12-08T13:52:04.963+08:00","updated_at":"2018-12-08T13:52:04.963+08:00"},{"id":922506,"file_name":"o1.png","project_id":51242,"asset_id":102362,"created_at":"2018-12-08T13:52:05.238+08:00","updated_at":"2018-12-08T13:52:05.238+08:00"},{"id":922507,"file_name":"o2.png","project_id":51242,"asset_id":102363,"created_at":"2018-12-08T13:52:05.241+08:00","updated_at":"2018-12-08T13:52:05.241+08:00"},{"id":922508,"file_name":"o3.png","project_id":51242,"asset_id":102364,"created_at":"2018-12-08T13:52:05.505+08:00","updated_at":"2018-12-08T13:52:05.505+08:00"},{"id":922509,"file_name":"o4.png","project_id":51242,"asset_id":102365,"created_at":"2018-12-08T13:52:05.508+08:00","updated_at":"2018-12-08T13:52:05.508+08:00"},{"id":922510,"file_name":"o5.png","project_id":51242,"asset_id":102366,"created_at":"2018-12-08T13:52:05.789+08:00","updated_at":"2018-12-08T13:52:05.789+08:00"},{"id":922511,"file_name":"o6.png","project_id":51242,"asset_id":102367,"created_at":"2018-12-08T13:52:05.792+08:00","updated_at":"2018-12-08T13:52:05.792+08:00"},{"id":922512,"file_name":"o7.png","project_id":51242,"asset_id":102368,"created_at":"2018-12-08T13:52:06.053+08:00","updated_at":"2018-12-08T13:52:06.053+08:00"},{"id":922513,"file_name":"o8.png","project_id":51242,"asset_id":102369,"created_at":"2018-12-08T13:52:06.056+08:00","updated_at":"2018-12-08T13:52:06.056+08:00"},{"id":922514,"file_name":"p1.png","project_id":51242,"asset_id":102370,"created_at":"2018-12-08T13:52:06.431+08:00","updated_at":"2018-12-08T13:52:06.431+08:00"},{"id":922515,"file_name":"p2.png","project_id":51242,"asset_id":102371,"created_at":"2018-12-08T13:52:06.434+08:00","updated_at":"2018-12-08T13:52:06.434+08:00"},{"id":922516,"file_name":"p3.png","project_id":51242,"asset_id":102372,"created_at":"2018-12-08T13:52:06.707+08:00","updated_at":"2018-12-08T13:52:06.707+08:00"},{"id":922517,"file_name":"p4.png","project_id":51242,"asset_id":102373,"created_at":"2018-12-08T13:52:06.710+08:00","updated_at":"2018-12-08T13:52:06.710+08:00"},{"id":922518,"file_name":"p5.png","project_id":51242,"asset_id":102374,"created_at":"2018-12-08T13:52:07.339+08:00","updated_at":"2018-12-08T13:52:07.339+08:00"},{"id":922519,"file_name":"p6.png","project_id":51242,"asset_id":102375,"created_at":"2018-12-08T13:52:07.342+08:00","updated_at":"2018-12-08T13:52:07.342+08:00"},{"id":922520,"file_name":"p7.png","project_id":51242,"asset_id":102376,"created_at":"2018-12-08T13:52:07.948+08:00","updated_at":"2018-12-08T13:52:07.948+08:00"},{"id":922521,"file_name":"p8.png","project_id":51242,"asset_id":102377,"created_at":"2018-12-08T13:52:07.950+08:00","updated_at":"2018-12-08T13:52:07.950+08:00"},{"id":922522,"file_name":"p9.png","project_id":51242,"asset_id":102378,"created_at":"2018-12-08T13:52:08.189+08:00","updated_at":"2018-12-08T13:52:08.189+08:00"},{"id":922523,"file_name":"p10.png","project_id":51242,"asset_id":102379,"created_at":"2018-12-08T13:52:08.192+08:00","updated_at":"2018-12-08T13:52:08.192+08:00"},{"id":922524,"file_name":"p11.png","project_id":51242,"asset_id":102380,"created_at":"2018-12-08T13:52:08.417+08:00","updated_at":"2018-12-08T13:52:08.417+08:00"},{"id":922525,"file_name":"p12.png","project_id":51242,"asset_id":102381,"created_at":"2018-12-08T13:52:08.419+08:00","updated_at":"2018-12-08T13:52:08.419+08:00"},{"id":922530,"file_name":"r1.png","project_id":51242,"asset_id":102386,"created_at":"2018-12-08T13:52:09.240+08:00","updated_at":"2018-12-08T13:52:09.240+08:00"},{"id":922531,"file_name":"r2.png","project_id":51242,"asset_id":102387,"created_at":"2018-12-08T13:52:09.243+08:00","updated_at":"2018-12-08T13:52:09.243+08:00"},{"id":922532,"file_name":"r3.png","project_id":51242,"asset_id":102388,"created_at":"2018-12-08T13:52:09.505+08:00","updated_at":"2018-12-08T13:52:09.505+08:00"},{"id":922533,"file_name":"r4.png","project_id":51242,"asset_id":102389,"created_at":"2018-12-08T13:52:09.508+08:00","updated_at":"2018-12-08T13:52:09.508+08:00"},{"id":922534,"file_name":"r5.png","project_id":51242,"asset_id":102390,"created_at":"2018-12-08T13:52:09.789+08:00","updated_at":"2018-12-08T13:52:09.789+08:00"},{"id":922535,"file_name":"r6.png","project_id":51242,"asset_id":102391,"created_at":"2018-12-08T13:52:09.791+08:00","updated_at":"2018-12-08T13:52:09.791+08:00"},{"id":922536,"file_name":"r7.png","project_id":51242,"asset_id":102392,"created_at":"2018-12-08T13:52:10.108+08:00","updated_at":"2018-12-08T13:52:10.108+08:00"},{"id":922537,"file_name":"r8.png","project_id":51242,"asset_id":102393,"created_at":"2018-12-08T13:52:10.110+08:00","updated_at":"2018-12-08T13:52:10.110+08:00"},{"id":922539,"file_name":"o10.png","project_id":51242,"asset_id":102395,"created_at":"2018-12-08T13:52:10.380+08:00","updated_at":"2018-12-08T14:01:01.891+08:00"},{"id":922540,"file_name":"o11.png","project_id":51242,"asset_id":102396,"created_at":"2018-12-08T13:52:10.652+08:00","updated_at":"2018-12-08T14:01:06.385+08:00"},{"id":922541,"file_name":"o12.png","project_id":51242,"asset_id":102397,"created_at":"2018-12-08T13:52:10.654+08:00","updated_at":"2018-12-08T14:01:10.303+08:00"},{"id":922526,"file_name":"r11.png","project_id":51242,"asset_id":102382,"created_at":"2018-12-08T13:52:08.654+08:00","updated_at":"2018-12-08T14:01:23.216+08:00"},{"id":922527,"file_name":"r12.png","project_id":51242,"asset_id":102383,"created_at":"2018-12-08T13:52:08.656+08:00","updated_at":"2018-12-08T14:01:27.175+08:00"},{"id":922528,"file_name":"r10.png","project_id":51242,"asset_id":102384,"created_at":"2018-12-08T13:52:08.863+08:00","updated_at":"2018-12-08T14:01:31.658+08:00"},{"id":922529,"file_name":"r9.png","project_id":51242,"asset_id":102385,"created_at":"2018-12-08T13:52:08.866+08:00","updated_at":"2018-12-08T14:01:35.551+08:00"},{"id":922538,"file_name":"o9.png","project_id":51242,"asset_id":102394,"created_at":"2018-12-08T13:52:10.378+08:00","updated_at":"2018-12-08T14:00:58.995+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦