{"id":92752,"student_id":3463,"content":"// 將背景設定為黑色\nsetBackdrop(\"#000000\");\n// 用 \"head.gif\" 創造一個角色\nvar head = createSprite(\"head.gif\");\nvar clock = 0;\nvar bodies = [];\nvar food = createSprite('food.gif');\nfood.x = Math.random() * 640;\nfood.y = Math.random() * 480;\nvar scoore = 0;\nvar alive = true;\nvar speed = 16;\nforever(function() {\n print(scoore, 50, 50, 'white', 20)\n clock += 1;\n if (clock % 6 == 0 \u0026\u0026 alive == true) {\n move();\n playerControl();\n eat();\n die();\n }\n});\n\n// 當按下鍵盤的「右方向鍵」時\n\n\nfunction move() {\n if (scoore % 3 == 0) {\n speed += 100\n }\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}\nfunction playerControl() {\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 if (key.right \u0026\u0026 head.direction !== 270) {\n head.direction = 90;\n }\n\n if (key.left \u0026\u0026 head.direction !== 90) {\n head.direction = 270;\n }\n}\nfunction eat() {\n if (head.touched(food)) {\n food.x = Math.random() * 640;\n food.y = Math.random() * 480;\n scoore += 1;\n var body = createSprite('body.gif');\n bodies.push(body);\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 print('Game Over', 160, 200, 'white', 60);\n }\n}","created_at":"2019-08-31T13:33:28.575+08:00","updated_at":"2019-09-08T11:17:39.555+08:00","name":"貪食蛇_S 副本","language":"javascript","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/92752/d69fe82d7943084a429e061b223c5950.jpg"},"parent_id":54317,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":90,"hashid":"npmsydrn","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1564913,"file_name":"head.gif","project_id":92752,"asset_id":107712,"created_at":"2019-08-31T13:33:28.582+08:00","updated_at":"2019-08-31T13:33:28.582+08:00"},{"id":1564914,"file_name":"body.gif","project_id":92752,"asset_id":107711,"created_at":"2019-08-31T13:33:28.585+08:00","updated_at":"2019-08-31T13:33:28.585+08:00"},{"id":1564915,"file_name":"food.gif","project_id":92752,"asset_id":107710,"created_at":"2019-08-31T13:33:28.586+08:00","updated_at":"2019-08-31T13:33:28.586+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦