{"id":73507,"student_id":1443,"content":"setBackdrop(\"#000000\");\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;\nvar clock = 0;\nvar score = 0;\nvar bobies = [];\nvar period=6;\n\nforever(function() {\n print(bobies.length, 10, 10, 'white')\n print(period, 50, 10, 'white')\n clock = clock + 1;\n if (clock % period === 0) {\n playerControl();\n eat();\n move();\n checkGameover();\n }\n});\nfunction eat() {\n if (head.touched(food)) {\n food.x = Math.random()*640;\n food.y = Math.random()*480;\n score = score + 1;\n\n var body = createSprite(\"body.gif\");\n bobies.push(body);\n\n if (score%5 == 0 \u0026\u0026 period \u003e= 2) {\n period -= 1;\n }\n }\n}\nfunction move() {\n if (bobies.length \u003e 0) {\n var lastBoby = bobies.pop();\n lastBoby.x = head.x;\n lastBoby.y = head.y;\n bobies.unshift(lastBoby);\n }\n head.stepForward(16);\n}\nfunction playerControl() {\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 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}\nfunction checkGameover() {\n if (head.touched(bobies) || head.x \u003c 0 || head.x \u003e 640 || head.y \u003c 0 || head.y \u003e 480) {\n stop();\n print('Game Over', 200, 200, 'white', 60)\n }\n}\n\nwhen(\"keydown\", \"right\", function() {\n //head.direction = 90;\n});","created_at":"2019-06-21T15:42:53.068+08:00","updated_at":"2023-04-30T10:55:30.064+08:00","name":"貪食蛇_S 副本","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/73507/1ea62bf5e5760b95e371cb7d7385d875.jpg"},"parent_id":54317,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":109,"hashid":"ej9swnvw","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1281554,"file_name":"head.gif","project_id":73507,"asset_id":107712,"created_at":"2019-06-21T15:42:53.072+08:00","updated_at":"2019-06-21T15:42:53.072+08:00"},{"id":1281555,"file_name":"body.gif","project_id":73507,"asset_id":107711,"created_at":"2019-06-21T15:42:53.073+08:00","updated_at":"2019-06-21T15:42:53.073+08:00"},{"id":1281556,"file_name":"food.gif","project_id":73507,"asset_id":107710,"created_at":"2019-06-21T15:42:53.074+08:00","updated_at":"2019-06-21T15:42:53.074+08:00"},{"id":7292453,"file_name":"cat.jpg","project_id":73507,"asset_id":469751,"created_at":"2022-01-23T11:28:48.716+08:00","updated_at":"2022-01-23T11:28:48.716+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦