{"id":183021,"student_id":10,"content":"// 將背景設定為黑色\nsetBackdrop(\"#000000\");\n// 用 \"head.gif\" 創造一個角色\nvar head = createSprite(\"head.gif\");\nhead.x = 320;\nhead.y = 240;\nvar food = createSprite(\"food.gif\");\nfood.x = Math.random()*640;\nfood.y = Math.random()*480;\n\nvar bodies = [];\nvar score = 0;\nvar clock = 0;\nvar speed = 6;\nvar alive = true;\n\nforever(function() {\n // 在這裡的程式碼會不斷執行\n clock = clock + 1;\n\n if (clock%speed == 0 \u0026\u0026 alive == true) {\n playerControl();\n eat();\n move();\n die();\n }\n if (alive == false) {\n print(\"Game over!\", 160, 200, \"white\", 60);\n }\n print(score, 20, 20, \"white\");\n\n});\n\nfunction playerControl() {\n ead.stepForward(1)\n if (key.right \u0026\u0026 head.direction != 270) {\n head.direction = 90;\n }\n if (key.left \u0026\u0026 head.direction != 90) {\n head.direction = 270;\n }\n if (key.up \u0026\u0026 head.direction != 180) {\n head.direction = 0;\n }\n if (key.down \u0026\u0026 head.direction != 0) {\n head.direction = 180;\n }\n}\n\nfunction eat() {\n if (head.touched(food)) {\n score += 1;\n food.x = Math.random()*640;\n food.y = Math.random()*480;\n\n var body = createSprite(\"body.gif\");\n\n bodies.push(body);\n\n if (score % 3 == 0 \u0026\u0026 speed\u003e1) {\n speed -= 1;\n }\n }\n}\n\nfunction move () {\n if (bodies.length \u003e 0) {\n var lastBody = bodies.pop();\n lastBody.x = head.x;\n lastBody.y = head.y;\n bodies.unshift(lastBody);\n }\n head.stepForward(16);\n}\n\nfunction die() {\n if (head.touched(bodies) || head.x \u003c 0 || head.x \u003e 640 || head.y \u003c 0 || head.y \u003e 480) {\n alive = false;\n }\n}","created_at":"2020-08-19T17:00:30.423+08:00","updated_at":"2020-08-19T17:02:33.632+08:00","name":"貪食蛇(DT試玩版) 副本","language":"javascript","screenshot":{"url":"/uploads/project/screenshot/183021/370b9cb1f2a7d47691e5c05eb6dc2b9a.jpg"},"parent_id":73441,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":484,"hashid":"zpes9ydq","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3112991,"file_name":"food.gif","project_id":183021,"asset_id":127587,"created_at":"2020-08-19T17:00:30.428+08:00","updated_at":"2020-08-19T17:00:30.428+08:00"},{"id":3112992,"file_name":"body.gif","project_id":183021,"asset_id":127586,"created_at":"2020-08-19T17:00:30.429+08:00","updated_at":"2020-08-19T17:00:30.429+08:00"},{"id":3112993,"file_name":"head.gif","project_id":183021,"asset_id":127585,"created_at":"2020-08-19T17:00:30.430+08:00","updated_at":"2020-08-19T17:00:30.430+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