{"id":16082,"student_id":888,"content":"","created_at":"2017-03-01T20:52:04.729+08:00","updated_at":"2019-11-08T06:40:27.715+08:00","name":"點擊大 PK","language":"javascript","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/16082/2b1d378a10ece5a3d1c1e22a27b11610.jpg"},"parent_id":2,"plugin":"setBackdrop(\"bg.jpg\");\nvar rope = createSprite(\"rope.png\");\nvar p1_id = Math.floor(Math.random()*10000);\nvar p2_id;\nvar p1_times = 0;\nvar p2_times = 0;\nvar status = 0;\n\nwhen('click', function () {\n if (status == 0) {\n p2_id = prompt('對方 ID?');\n }\n if (status == 1) {\n p1_times++;\n }\n});\n\nDB.onMessage('update', function (data) {\n if (data.my_id == p2_id \u0026\u0026 data.u_id == p1_id) {\n if (status == 0) {\n status = 1;\n }\n if (status == 1) {\n p2_times = data.times;\n }\n if (data.isGameOver) {\n status = 2;\n }\n } \n});\n\nforever(function(){\n rope.y = 240 + (p1_times - p2_times)*12;\n var isGameOver = Math.abs(p1_times - p2_times) \u003e 10;\n \n if (p2_id \u0026\u0026 status != 2) {\n DB.broadcast('update',{\n my_id: p1_id,\n u_id: p2_id,\n times: p1_times,\n isGameOver: isGameOver\n });\n }\n if (isGameOver) {\n status = 2;\n }\n if (status == 2 \u0026\u0026 key.space) {\n p1_times = 0;\n p2_times = 0;\n status = 0;\n }\n});\n\nforever(function(){\n if (status == 0) {\n print('你的 ID: ' + p1_id, 10, 10, 'red', 25);\n print('對方 ID: ' + p2_id, 10, 40, 'blue', 25);\n }\n if (status == 1) {\n print('開始比賽!!', 10, 10, 'red', 25);\n }\n if (status == 2) {\n print('空白鍵重新開始', 10, 40, 'red', 25);\n if (p1_times \u003e p2_times) {\n print('獲勝!!', 10, 10, 'red', 25);\n } else {\n print('失敗!!', 10, 10, 'red', 25)\n }\n }\n});","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":466,"hashid":"wdks428r","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":332273,"file_name":"rope.png","project_id":16082,"asset_id":38919,"created_at":"2017-11-23T20:16:40.752+08:00","updated_at":"2017-11-23T20:16:40.752+08:00"},{"id":332274,"file_name":"bg.jpg","project_id":16082,"asset_id":38920,"created_at":"2017-11-23T20:16:40.779+08:00","updated_at":"2017-11-23T20:16:40.779+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦