{"id":5755,"student_id":98,"content":"// 將背景設定為黑色\nsetBackdrop(\"#000000\");\n// 用 \"head.gif\" 創造一個角色\nvar head = createSprite( \"head.gif\" );\nvar food = createSprite( \"food.gif\" );\nvar bodies =[];\nvar score = 0;\nvar time = 0;\n\n\nforever(function(){\n // 在這裡的程式碼會不斷執行\n if ( time%8==0){\n var lastBody = bodies.pop(); // 將body最後的身體拿出來\n if (lastBody){ //確定有lastbody\n \tlastBody.x = head.x;\n lastBody.y = head.y;\n bodies.unshift(lastBody); //把lastbody放到陣列最前面\n }\n \thead.stepForward(16);\n if (head.touched(food) ){\n score= score +1;\n food.x = Math.random()*640;\n food.y = Math.random()*480;\n var body = createSprite(\"body.gif\");\n body.x = head.x;\n body.y = head.y;\n bodies.push( body );\n }\n\n if (head.x\u003c0 || head.x\u003e640 || head.y\u003c0 || head.y\u003e480){\n print(\"Game Over!\", 160 , 200,\"white\",50);\n stop();\n }\n }\n time = time+1;\n\tprint(score,20,20,\"white\");\n});\n\n// 當按下鍵盤的「右方向鍵」時\nwhen(\"keydown\",\"left\",function(){\n head.direction = 270;\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});","created_at":"2017-05-14T23:09:29.975+08:00","updated_at":"2019-09-28T11:31:11.792+08:00","name":"貪食蛇 學生版","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/5755/65ad8768e59500dfa0bca0d2b6254004.jpg"},"parent_id":4697,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":121,"hashid":"36ys9mm","is_content_changed":null,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":140235,"file_name":"head.gif","project_id":5755,"asset_id":15651,"created_at":"2017-05-30T13:47:41.442+08:00","updated_at":"2017-05-30T13:47:41.442+08:00"},{"id":140236,"file_name":"body.gif","project_id":5755,"asset_id":15652,"created_at":"2017-05-30T13:47:41.444+08:00","updated_at":"2017-05-30T13:47:41.444+08:00"},{"id":140237,"file_name":"food.gif","project_id":5755,"asset_id":15653,"created_at":"2017-05-30T13:47:41.446+08:00","updated_at":"2017-05-30T13:47:41.446+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦