{"id":98118,"student_id":3311,"content":"// 將背景設定為黑色\nsetBackdrop(\"#000000\");\n// 用 \"head.gif\" 創造一個角色\nvar head = createSprite(\"head.gif\");\n head.x = 320;\n head.y = 240;\n\nvar food = createSprite(\"food.gif\");\n food.x = Math.random()*640;\n food.y = Math.random()*480;\nvar clock = 0;\nvar bodies = [];\nvar score = 0;\nvar alive = true;\nvar speed = 6;\n\nforever(function() {\n print(speed ,20 ,20 ,\"white\");\n print(bodies.length ,10 ,10 ,\"white\");\n clock = clock + 1;\n // console.log(clock)\n if (clock %6 === 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});\n\n// when(\"key.down\", \"right\", function() {\n// head.direction = 90;\n// });\nfunction Move() {\n if (bodies.length \u003e 0) {\n var lestbody = bodies.pop();\n lestbody.x = head.x;\n lestbody.y = head.y;\n bodies.unshift(lestbody);\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.left \u0026\u0026 head.direction != 90) {\n head.direction = 270;\n }\n if (key.right \u0026\u0026 head.direction != 270) {\n head.direction = 90;\n }\n}\nfunction eat(){\n if (score % 3 == 0) {\n speed - 1;\n }\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 bodies.push(body);\n // \u0026\u0026 speed \u003e 0\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":"2019-09-28T13:50:46.233+08:00","updated_at":"2019-11-30T14:46:54.789+08:00","name":"貪食蛇_S 副本","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/98118/1184bb037132130ef4f7d75370d4fd5d.jpg"},"parent_id":54317,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":131,"hashid":"882s393d","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1667964,"file_name":"head.gif","project_id":98118,"asset_id":107712,"created_at":"2019-09-28T13:50:46.249+08:00","updated_at":"2019-09-28T13:50:46.249+08:00"},{"id":1667965,"file_name":"body.gif","project_id":98118,"asset_id":107711,"created_at":"2019-09-28T13:50:46.250+08:00","updated_at":"2019-09-28T13:50:46.250+08:00"},{"id":1667966,"file_name":"food.gif","project_id":98118,"asset_id":107710,"created_at":"2019-09-28T13:50:46.251+08:00","updated_at":"2019-09-28T13:50:46.251+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦