{"id":113104,"student_id":10,"content":"setBackdrop('bg.jpg');\nvar food = createSprite('food.png');\nvar head = createSprite('head.png');\nvar hint = createSprite('hintt.png');\nvar gameover = createSprite('gameover.png');\nvar bodies = [];\nvar score = 0;\nvar clock = 0;\nvar isStart = false;\n\nhint.moveTo(630, 450);\nhead.moveTo(630, 450);\nfood.x = Math.floor(Math.random()*20)*60 + 30;\nfood.y = Math.floor(Math.random()*15)*60 + 30;\ngameover.hidden = true;\n\nsound.play('bgm.mp3', true);\n\nforever(loop);\n\nfunction loop () {\n print(score, 10, 10, 'black', 40);\n \n var level = Math.floor(score/5);\n if (level \u003e 9) level = 9;\n \n clock++;\n if (clock%(10 - level) == 0 \u0026\u0026 isStart) {\n // 這裏的順序很重要\n // 先偵測是否碰撞到食物、然後移動身體、移動蛇的頭、判斷是否撞到身體\n // 因為碰撞到食物會新增身體的角色到頭的位置,所以順序不能在移動之後\n if (head.touched(food)) {\n food.x = Math.floor(Math.random()*16)*60 + 30;\n food.y = Math.floor(Math.random()*12)*60 + 30;\n var b = createSprite('body.png');\n b.x = head.x;\n b.y = head.y;\n bodies.push(b);\n score++;\n sound.play('bling.ogg');\n }\n if (bodies.length \u003e 0) {\n var b = bodies.pop();\n b.moveTo(head);\n bodies.unshift(b);\n }\n head.stepForward(60);\n if (head.touched(bodies)) {\n gameover.hidden = false;\n stop();\n }\n }\n if (key.up \u0026\u0026 head.direction != 180) {\n head.direction = 0;\n isStart = true;\n }\n if (key.right \u0026\u0026 head.direction != 270) {\n head.direction = 90;\n isStart = true;\n }\n if (key.down \u0026\u0026 head.direction != 0) {\n head.direction = 180;\n isStart = true;\n }\n if (key.left \u0026\u0026 head.direction != 90) {\n head.direction = 270;\n isStart = true;\n }\n if (isStart) {\n hint.hidden = true;\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":"2019-12-10T10:43:09.372+08:00","updated_at":"2020-04-30T00:30:48.058+08:00","name":"貪食蛇 雙師素材更新 v2 ","language":"javascript","screenshot":{"url":"/uploads/project/screenshot/113104/9878579afbe1eb30f7780d88a185203f.jpg"},"parent_id":2,"plugin":"Game.set({ width: 1200, height: 900 })","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":436,"hashid":"rdvsrdnq","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2493379,"file_name":"hintt.png","project_id":113104,"asset_id":209210,"created_at":"2020-04-27T19:50:22.694+08:00","updated_at":"2020-04-27T19:50:22.694+08:00"},{"id":2493380,"file_name":"bg.jpg","project_id":113104,"asset_id":209211,"created_at":"2020-04-27T19:50:22.699+08:00","updated_at":"2020-04-27T19:50:22.699+08:00"},{"id":2493381,"file_name":"gameover.png","project_id":113104,"asset_id":209212,"created_at":"2020-04-27T19:50:22.703+08:00","updated_at":"2020-04-27T19:50:22.703+08:00"},{"id":2493382,"file_name":"head.png","project_id":113104,"asset_id":209213,"created_at":"2020-04-27T19:50:22.707+08:00","updated_at":"2020-04-27T19:50:22.707+08:00"},{"id":2493383,"file_name":"bgm.mp3","project_id":113104,"asset_id":209214,"created_at":"2020-04-27T19:50:22.779+08:00","updated_at":"2020-04-27T19:50:22.779+08:00"},{"id":2493384,"file_name":"bling.ogg","project_id":113104,"asset_id":209215,"created_at":"2020-04-27T19:50:22.784+08:00","updated_at":"2020-04-27T19:50:22.784+08:00"},{"id":2493385,"file_name":"food.png","project_id":113104,"asset_id":209216,"created_at":"2020-04-27T19:50:22.788+08:00","updated_at":"2020-04-27T19:50:22.788+08:00"},{"id":2493386,"file_name":"body.png","project_id":113104,"asset_id":209217,"created_at":"2020-04-27T19:50:22.792+08:00","updated_at":"2020-04-27T19:50:22.792+08:00"}]
Orange Apple Learning Platform
My Projects
View Project Page
Export
Remix
Import
Delete
Download Android APP (APK)
Screenshot
繁中
简中
English
日本語
1:1:1
1:1
Full Width
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer