{"id":7485,"student_id":10,"content":"setBackdrop('black');\n\nvar head = createSprite( \"head.gif\" );\nvar food = createSprite( \"food.gif\" );\nvar bodies = [];\nvar score = 0;\nvar clock = 0;\n\n\nforever(function(){\n // 在這裡的程式碼會不斷執行\n if(clock%8==0){\n var lastBody = bodies.pop();\n if(lastBody){\n \tlastBody.x = head.x;\n \tlastBody.y = head.y;\n bodies.unshift(lastBody);\n }\n \thead.stepForward(16);\n \tif( head.touched(food) ){\n score = score + 1;\n food.x = Math.random()*640;\n food.y = Math.random()*480;\n\t\t\tvar body = createSprite( \"body.gif\" );\n body.x = head.x;\n body.y = head.y;\n bodies.push( body );\n }\n if( head.touched(bodies) || head.x\u003c0 || head.x\u003e640 || head.y\u003c0 || head.y\u003e480 ){\n \t\tprint(\"Game over!\",160,200,\"white\",60);\n \tstop();\n }\n }\n clock = clock + 1;\n print(score,20,20,\"white\");\n});\n\n// 當按下鍵盤的「右方向鍵」時\nwhen(\"keydown\", \"right\", function(){\n\thead.direction = 90;\n});\nwhen(\"keydown\", \"up\", function(){\n\thead.direction = 0;\n});\nwhen(\"keydown\", \"down\", function(){\n\thead.direction = 180;\n});\nwhen(\"keydown\", \"left\", function(){\n\thead.direction = 270;\n});","created_at":"2017-03-01T20:52:04.729+08:00","updated_at":"2019-12-16T15:49:46.818+08:00","name":"貪食蛇_T","language":"javascript","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/7485/143e7c3922b0f2ec1802ef7dd2b44d43.jpg"},"parent_id":2,"plugin":"","description":"","note":"","status":"public","like_student_ids":[10,172,871,109,3090,3201,4728,2162,1921],"is_featured":false,"views":1484,"hashid":"qmdsyzr","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1961777,"file_name":"head.gif","project_id":7485,"asset_id":172243,"created_at":"2019-12-16T15:40:34.554+08:00","updated_at":"2019-12-16T15:40:34.554+08:00"},{"id":1961778,"file_name":"body.gif","project_id":7485,"asset_id":172244,"created_at":"2019-12-16T15:40:34.560+08:00","updated_at":"2019-12-16T15:40:34.560+08:00"},{"id":1961779,"file_name":"food.gif","project_id":7485,"asset_id":172245,"created_at":"2019-12-16T15:40:34.565+08:00","updated_at":"2019-12-16T15:40:34.565+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦