{"id":64919,"student_id":1940,"content":"// 將背景設定為黑色\nsetBackdrop(\"#000000\");\n// 用 \"head.gif\" 創造一個角色\nvar head = createSprite(\"head.gif\");\nhead.x = 320;\nhead.y = 240;\nvar food = createSprite(\"page_bg_apple1.png\");\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 print(score, 20, 20, \"white\");\n clock += 1\n if (clock % 6 == 0 \u0026\u0026 alive == true) {\n die()\n playerControl()\n eat()\n move()\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 playerControl() {\n if (key.right \u0026\u0026 head.direction ) {\n head.direction = 90\n }\n if (key.left \u0026\u0026 head.direction !=270 ) {\n head.direction = 270\n }\n if (key.up \u0026\u0026 head.direction !=270 ) {\n head.direction = 0\n }\n if (key.down \u0026\u0026 head.direction !=270 ) {\n head.direction = 180\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 var body = createSprite(\"body.gif\")\n bodies.push(body)\n }\n}\nfunction die(){\n if(head.x \u003e 640|| head.x \u003c 0||head.y \u003e 480|| head.y \u003c 0||head.touched(bodies)){\n alive === false\n }\n}","created_at":"2019-04-28T13:34:48.909+08:00","updated_at":"2019-07-05T12:49:57.797+08:00","name":"貪食蛇_S","language":"javascript","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/64919/c256180e51cc8c0df3574099840df090.jpg"},"parent_id":62770,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":93,"hashid":"5j3s5n84","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1137633,"file_name":"food.gif","project_id":64919,"asset_id":107710,"created_at":"2019-04-28T13:34:48.915+08:00","updated_at":"2019-04-28T13:34:48.915+08:00"},{"id":1137634,"file_name":"body.gif","project_id":64919,"asset_id":107711,"created_at":"2019-04-28T13:34:48.916+08:00","updated_at":"2019-04-28T13:34:48.916+08:00"},{"id":1137635,"file_name":"head.gif","project_id":64919,"asset_id":107712,"created_at":"2019-04-28T13:34:48.917+08:00","updated_at":"2019-04-28T13:34:48.917+08:00"},{"id":1158256,"file_name":"page_bg_apple1.png","project_id":64919,"asset_id":118224,"created_at":"2019-05-04T22:08:40.072+08:00","updated_at":"2019-05-04T22:08:40.072+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦