{"id":100763,"student_id":3439,"content":"// 將背景設定為黑色\nsetBackdrop(\"#000000\");\n// 用 \"head.gif\" 創造一個角色\nvar head = createSprite(\"head.gif\");\nvar food = createSprite(\"food.gif\");\nfood.x = Math.random()*480\nfood.y = Math.random()*640\nvar clock = 0;\nvar score;\nvar bodies = []\nforever(function() {\n print (bodies.length, 10, 10, 'whit')\n clock += 1;\n if (clock % 6 == 0) {\n playerControl()\n eat()\n move()\n \n\n }\n\n});\nfunction move() {\n\n if (bodies.length \u003e 0) {\n var lastboby = bodies.pop();\n lastboby.x = head.x\n lastboby.y = head.y\n bodies.unshift(lastboby)\n\n }\n head.stepForward(16)\n}\nfunction playerControl() {\n if (key.up) {\n head.direction = 0\n }\n if (key.down) {\n head.direction = 180\n }\n if (key.right) {\n head.direction = 90\n }\n if (key.left) {\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 score += 1;\n var body = createSprite('body.gif')\n bodies.push(body)\n }\n}\n\n\n\n\n\n\n\n\n\n\n// when(\"keydown\", \"right\", function(){\n// \thead.direction = 90;\n// });\n// when(\"keydown\", \"left\", function(){\n// \thead.direction = 0;\n// });\n// when(\"keydown\", \"right\", function(){\n// \thead.direction = 90;\n// });\n// when(\"keydown\", \"right\", function(){\n// \thead.direction = 90;\n// });","created_at":"2019-10-19T10:23:05.861+08:00","updated_at":"2019-11-06T09:57:26.228+08:00","name":"貪食蛇_S 副本","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/100763/fd7c5cb4f0a122766582f55b42a1d7b6.jpg"},"parent_id":54317,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":72,"hashid":"2pdsqkqv","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1701673,"file_name":"head.gif","project_id":100763,"asset_id":107712,"created_at":"2019-10-19T10:23:05.872+08:00","updated_at":"2019-10-19T10:23:05.872+08:00"},{"id":1701674,"file_name":"body.gif","project_id":100763,"asset_id":107711,"created_at":"2019-10-19T10:23:05.874+08:00","updated_at":"2019-10-19T10:23:05.874+08:00"},{"id":1701675,"file_name":"food.gif","project_id":100763,"asset_id":107710,"created_at":"2019-10-19T10:23:05.875+08:00","updated_at":"2019-10-19T10:23:05.875+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦