{"id":129329,"student_id":10,"content":"{\"html\":\"\u003c!DOCTYPE html\u003e\\n\u003chtml\u003e\\n\u003chead\u003e\\n\\t\u003ctitle\u003eDocument\u003c/title\u003e\\n\\t\u003cscript src=\\\"https://code.jquery.com/jquery-3.2.1.min.js\\\"\u003e\u003c/script\u003e\\n\u003c/head\u003e\\n\u003cbody\u003e\\n \u003cdiv id=\\\"cover\\\"\u003e\\n \u003ch1\u003e\u003c/h1\u003e\\n \u003cbutton type=\\\"button\\\" id=\\\"setId\\\"\u003e發起戰帖\u003c/button\u003e \\n \u003c/div\u003e\\n\u003c/body\u003e\\n\u003c/html\u003e\",\"css\":\"body {\\n background-image: url('bg_1.jpg');\\n background-size: cover;\\n background-position: 50% 50%;\\n background-repeat: no-repeat;\\n width: 100vw;\\n height: 100vh;\\n cursor: url('cursor.png') 32 32, auto;\\n}\\n\\nbody:active {\\n cursor: url('clicker.png') 32 32, auto;\\n}\\n\\n#cover {\\n width: 100vw;\\n height: 100vh;\\n padding: 30px;\\n box-sizing: border-box;\\n color: #fff;\\n text-align: center;\\n background-color: #00000099;\\n font-size: 40px;\\n}\\n\\nbutton {\\n padding: 10px;\\n border: 2px solid #ccc;\\n font-size: 20px;\\n}\",\"js\":\"var status = 0;\\nvar p1_id = Math.floor(Math.random()*10000);\\nvar p2_id;\\nvar p1_count = 0;\\nvar p2_count = 0;\\n\\n$('h1').text('ID: ' + p1_id);\\n\\n\\n$('#setId').click(invite); // 送出「邀請」訊息\\n$('body').click(pull); // 拉繩子\\n\\n\\nfunction invite () {\\n p2_id = Number(prompt('輸入對方 id?'));\\n socket.emit('invite', { from: p1_id, to: p2_id });\\n}\\n\\nfunction pull () {\\n if (status == 1) {\\n p1_count++;\\n update();\\n socket.emit('update', { to: p2_id, count: p1_count });\\n }\\n}\\n\\n// 接收「邀請」訊息並返回「開始」訊息\\nsocket.on('invite', function (data) {\\n if (data.to == p1_id) { // 判斷是否是在邀請自己\\n p2_id = data.from;\\n socket.emit('start', { to: p2_id });\\n start();\\n }\\n});\\n\\n// 接收來自對手「開始遊戲」訊息\\nsocket.on('start', function(data) {\\n if (data.to == p1_id) {\\n start();\\n }\\n});\\n\\n// 接收來自對手點擊次數的訊息並更新\\nsocket.on('update', function (data) {\\n if (data.to == p1_id) {\\n p2_count = data.count;\\n update();\\n }\\n});\\n\\n// 接收來自對手「遊戲結束」訊息\\nsocket.on('gameover', function (data) {\\n if (data.to == p1_id) {\\n gameover();\\n }\\n});\\n\\nfunction start () {\\n status = 1;\\n $('#cover').fadeOut();\\n}\\n\\nfunction update () {\\n var diff = p1_count - p2_count;\\n $('body').css('background-position', `calc(50% + ${diff*5}px) 50%`);\\n if (diff \u003e= 10) {\\n socket.emit('gameover', {\\n to: p2_id,\\n });\\n gameover();\\n }\\n}\\n\\nfunction gameover () {\\n status = 2;\\n if (p1_count - p2_count \u003e 0) {\\n $('body').css('background-image', 'url(\\\"bg_3.jpg\\\")');\\n } else {\\n $('body').css('background-image', 'url(\\\"bg_2.jpg\\\")');\\n }\\n}\"}","created_at":"2020-02-25T11:02:54.079+08:00","updated_at":"2020-02-25T12:08:10.398+08:00","name":"點擊大 PK","language":"web","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/129329/d9623804f20ee112726bf67724bc377b.jpg"},"parent_id":3,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":249,"hashid":"4y3sqj95","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2220654,"file_name":"bg_1.jpg","project_id":129329,"asset_id":190387,"created_at":"2020-02-25T11:03:09.666+08:00","updated_at":"2020-02-25T11:03:09.666+08:00"},{"id":2220655,"file_name":"bg_3.jpg","project_id":129329,"asset_id":190388,"created_at":"2020-02-25T11:03:09.675+08:00","updated_at":"2020-02-25T11:03:09.675+08:00"},{"id":2220656,"file_name":"bg_2.jpg","project_id":129329,"asset_id":190389,"created_at":"2020-02-25T11:03:09.682+08:00","updated_at":"2020-02-25T11:03:09.682+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
前往網站頁面
1:1:1
1:1
full
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦