{"id":160520,"student_id":16,"content":"setBackdrop('bg.jpg'); //設定背景圖\nvar food = createSprite('apple.png', 'orange.png'); //食物\nvar head = createSprite('head.png'); //蛇頭\nvar hint = createSprite('hint.png'); //遊戲開始示意圖\nvar gameover = createSprite('gameover.png'); //遊戲結束示意圖\nvar tail = createSprite('body.png', 'body_left.png', 'body_right.png', 'tail.png');\n\nvar clock = 0;\nvar direction = 90;\nvar bodies = [tail];\nvar level = 0;\n\nhead.x = 330;\nfood.x = 930;\ntail.x = 270;\ntail.costumeId = 3;\n\n// 設定蛇頭、食物、遊戲結束示意圖的圖層順序\nfood.layer = 1;\nhead.layer = 2;\ngameover.layer = 3;\n\n\ngameover.hidden = true; //預設隱藏遊戲結束示意圖\nhint.x = 330;\n\nforever(loop); //不斷執行遊戲迴圈\n\nfunction loop () {\n drawText(bodies.length - 1, 10 , 10, 'white', 40);\n clock++;\n if(clock % (15 - level) == 0 \u0026\u0026 hint.hidden) {\n if(head.touched(food)) {\n // x : (0-19) * 60 + 30\n // y : (0-14) * 60 + 30\n food.x = Math.floor(Math.random() * 20) * 60 + 30;\n food.y = Math.floor(Math.random() * 15) * 60 + 30;\n var b = createSprite('body.png', 'body_left.png', 'body_right.png', 'tail.png');\n bodies.push(b);\n b.moveTo(head);\n }\n if(bodies.length \u003e 0) {\n var b = bodies.pop();\n b.moveTo(head);\n bodies.unshift(b);\n var diff = direction - head.direction;\n if(diff == 90 || diff == -270) {\n b.costumeId = 2;\n }\n if(diff == -90 || diff == 270) {\n b.costumeId = 1;\n }\n if(diff == 0) {\n b.costumeId = 0;\n }\n b.direction = direction;\n bodies[bodies.length - 1].costumeId = 3;\n }\n head.direction = direction;\n head.stepForward(60);\n }\n if(key.up \u0026\u0026 head.direction !== 180) {\n direction = 0;\n hint.hidden = true;\n }\n if(key.down \u0026\u0026 head.direction !== 0) {\n direction = 180;\n hint.hidden = true;\n }\n if(key.right \u0026\u0026 head.direction !== 270) {\n direction = 90;\n hint.hidden = true;\n }\n if(key.left \u0026\u0026 head.direction !== 90) {\n direction = 270;\n }\n if(head.touched(bodies)) {\n stop();\n gameover.hidden = false;\n drawText(bodies.length - 1, 580 , 460, 'white', 80);\n }\n level = Math.floor((bodies.length - 1) / 5);\n if(level \u003e 10) {\n level = 10;\n }\n if(head.x \u003e 1200) {\n head.x -= 1200;\n }\n if(head.x \u003c 0) {\n head.x += 1200;\n }\n if(head.y \u003c 0) {\n head.y += 900;\n }\n if(head.y \u003e 900) {\n head.y -= 900;\n }\n}\n","created_at":"2020-06-28T18:02:02.252+08:00","updated_at":"2020-06-28T23:02:50.503+08:00","name":"貪食蛇 雙師素材更新 v4 副本","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/160520/c16ff8d0446296daa88fca30c85956fd.jpg"},"parent_id":146132,"plugin":"Game.set({ width: 1200, height: 900 })","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":98,"hashid":"9ygsmd4m","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2792942,"file_name":"hint.png","project_id":160520,"asset_id":210817,"created_at":"2020-06-28T18:02:02.260+08:00","updated_at":"2020-06-28T18:02:02.260+08:00"},{"id":2792943,"file_name":"gameover.png","project_id":160520,"asset_id":210816,"created_at":"2020-06-28T18:02:02.261+08:00","updated_at":"2020-06-28T18:02:02.261+08:00"},{"id":2792944,"file_name":"bg.jpg","project_id":160520,"asset_id":210815,"created_at":"2020-06-28T18:02:02.262+08:00","updated_at":"2020-06-28T18:02:02.262+08:00"},{"id":2792945,"file_name":"bgm.mp3","project_id":160520,"asset_id":209214,"created_at":"2020-06-28T18:02:02.263+08:00","updated_at":"2020-06-28T18:02:02.263+08:00"},{"id":2792946,"file_name":"bling.ogg","project_id":160520,"asset_id":209215,"created_at":"2020-06-28T18:02:02.266+08:00","updated_at":"2020-06-28T18:02:02.266+08:00"},{"id":2792947,"file_name":"body_left.png","project_id":160520,"asset_id":210000,"created_at":"2020-06-28T18:02:02.267+08:00","updated_at":"2020-06-28T18:02:02.267+08:00"},{"id":2792948,"file_name":"body_right.png","project_id":160520,"asset_id":210010,"created_at":"2020-06-28T18:02:02.268+08:00","updated_at":"2020-06-28T18:02:02.268+08:00"},{"id":2792949,"file_name":"body.png","project_id":160520,"asset_id":210002,"created_at":"2020-06-28T18:02:02.269+08:00","updated_at":"2020-06-28T18:02:02.269+08:00"},{"id":2792950,"file_name":"apple.png","project_id":160520,"asset_id":210003,"created_at":"2020-06-28T18:02:02.270+08:00","updated_at":"2020-06-28T18:02:02.270+08:00"},{"id":2792951,"file_name":"orange.png","project_id":160520,"asset_id":210004,"created_at":"2020-06-28T18:02:02.271+08:00","updated_at":"2020-06-28T18:02:02.271+08:00"},{"id":2792952,"file_name":"head.png","project_id":160520,"asset_id":210005,"created_at":"2020-06-28T18:02:02.272+08:00","updated_at":"2020-06-28T18:02:02.272+08:00"},{"id":2792953,"file_name":"tail.png","project_id":160520,"asset_id":210006,"created_at":"2020-06-28T18:02:02.273+08:00","updated_at":"2020-06-28T18:02:02.273+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦