{"id":145358,"student_id":10,"content":"setBackdrop('bg_1.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 bodies = [tail]; // 用來存放蛇的身體\nvar clock = 0;\nvar direction = 90; //蛇下次移動的方向\nvar isStart = false; //是否開始遊戲\nvar level = 0; //分數等級用來計算移動速度\n\n// 設定蛇頭、食物、遊戲結束示意圖的圖層順序\nhead.layer = 1;\nfood.layer = 2;\ngameover.layer = 3;\n\ngameover.hidden = true; //預設隱藏遊戲結束示意圖\nhint.hidden = true; // 預設隱藏遊戲開始示意圖\n\nfood.moveTo(930, 450); //(60*15 + 30, 60*7 + 30)\nhead.moveTo(330, 450); //(60*5 + 30, 60*7 + 30)\ntail.moveTo(270, 450);\ntail.costumeId = 3;\n\ncreateSound('bgm.mp3', true);\n\nforever(loop); //不斷執行遊戲迴圈\n\n// 遊戲主迴圈\nfunction loop () {\n clock++;\n if (clock % (10 - level) == 0 \u0026\u0026 isStart) {\n if (head.touched(food)) {\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 b.x = head.x;\n b.y = head.y;\n bodies.push(b);\n createSound('bling.ogg');\n }\n if (bodies.length \u003e 0) {\n var b = bodies.pop();\n b.x = head.x;\n b.y = head.y;\n bodies.unshift(b);\n\n var diff = direction - head.direction;\n if (diff == 0) { //蛇向前移動\n b.costumeId = 0;\n }\n if (diff == -90 || diff == 270) { //蛇左轉移動\n b.costumeId = 1;\n }\n if (diff == 90 || diff == -270) { //蛇右轉移動\n b.costumeId = 2;\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 isStart = true;\n }\n if (key.right \u0026\u0026 head.direction != 270) {\n direction = 90;\n isStart = true;\n }\n if (key.down \u0026\u0026 head.direction != 0) {\n direction = 180;\n isStart = true;\n }\n if (key.left \u0026\u0026 head.direction != 90) {\n direction = 270;\n isStart = true;\n }\n hint.hidden = isStart;\n\n if (head.touched(bodies)) {\n stop();\n gameover.hidden = false;\n print(bodies.length - 1, 550, 550, 'white', 80);\n }\n\n print(bodies.length - 1, 10, 10, 'white', 40);\n\n level = Math.floor((bodies.length - 1)/5);\n if (level \u003e 10) {\n level = 10;\n }\n if (head.x \u003c 0) {\n head.x += 1200;\n }\n if (head.x \u003e 1200) {\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}","created_at":"2020-05-02T14:40:25.370+08:00","updated_at":"2020-05-02T14:40:25.370+08:00","name":"貪食蛇 雙師素材更新 v3 (without grid) 沒有土 副本","language":"javascript","screenshot":{"url":null},"parent_id":144375,"plugin":"Game.set({ width: 1200, height: 900 })","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":251,"hashid":"meysj8ep","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2517838,"file_name":"bg_1.jpg","project_id":145358,"asset_id":210253,"created_at":"2020-05-02T14:40:25.392+08:00","updated_at":"2020-05-02T14:40:25.392+08:00"},{"id":2517839,"file_name":"tail.png","project_id":145358,"asset_id":210006,"created_at":"2020-05-02T14:40:25.393+08:00","updated_at":"2020-05-02T14:40:25.393+08:00"},{"id":2517840,"file_name":"head.png","project_id":145358,"asset_id":210005,"created_at":"2020-05-02T14:40:25.394+08:00","updated_at":"2020-05-02T14:40:25.394+08:00"},{"id":2517841,"file_name":"orange.png","project_id":145358,"asset_id":210004,"created_at":"2020-05-02T14:40:25.395+08:00","updated_at":"2020-05-02T14:40:25.395+08:00"},{"id":2517842,"file_name":"apple.png","project_id":145358,"asset_id":210003,"created_at":"2020-05-02T14:40:25.396+08:00","updated_at":"2020-05-02T14:40:25.396+08:00"},{"id":2517843,"file_name":"body.png","project_id":145358,"asset_id":210002,"created_at":"2020-05-02T14:40:25.397+08:00","updated_at":"2020-05-02T14:40:25.397+08:00"},{"id":2517844,"file_name":"body_right.png","project_id":145358,"asset_id":210010,"created_at":"2020-05-02T14:40:25.398+08:00","updated_at":"2020-05-02T14:40:25.398+08:00"},{"id":2517845,"file_name":"body_left.png","project_id":145358,"asset_id":210000,"created_at":"2020-05-02T14:40:25.399+08:00","updated_at":"2020-05-02T14:40:25.399+08:00"},{"id":2517846,"file_name":"bg.jpg","project_id":145358,"asset_id":209999,"created_at":"2020-05-02T14:40:25.400+08:00","updated_at":"2020-05-02T14:40:25.400+08:00"},{"id":2517847,"file_name":"bg_grid.jpg","project_id":145358,"asset_id":209998,"created_at":"2020-05-02T14:40:25.401+08:00","updated_at":"2020-05-02T14:40:25.401+08:00"},{"id":2517848,"file_name":"bling.ogg","project_id":145358,"asset_id":209215,"created_at":"2020-05-02T14:40:25.402+08:00","updated_at":"2020-05-02T14:40:25.402+08:00"},{"id":2517849,"file_name":"bgm.mp3","project_id":145358,"asset_id":209214,"created_at":"2020-05-02T14:40:25.403+08:00","updated_at":"2020-05-02T14:40:25.403+08:00"},{"id":2517850,"file_name":"gameover.png","project_id":145358,"asset_id":209510,"created_at":"2020-05-02T14:40:25.404+08:00","updated_at":"2020-05-02T14:40:25.404+08:00"},{"id":2517851,"file_name":"hint.png","project_id":145358,"asset_id":209511,"created_at":"2020-05-02T14:40:25.405+08:00","updated_at":"2020-05-02T14:40:25.405+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦