{"id":68902,"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.slim.min.js\\\"\u003e\u003c/script\u003e\\n\u003c/head\u003e\\n\u003cbody\u003e\\n \u003cp\u003e\u003c/p\u003e\\n \u003cbutton type=\\\"button\\\" id=\\\"setId\\\"\u003e發起戰帖\u003c/button\u003e\\n\u003c/body\u003e\\n\u003c/html\u003e\",\"css\":\"body {\\n background-image: url('bg.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}\",\"js\":\"var status = 0;\\nvar p1_id = Math.floor(Math.random()*1000);\\nvar p2_id;\\nvar p1_count = 0;\\nvar p2_count = 0;\\n\\n$('p').text(`你的 id: ${p1_id}`);\\n\\n$('#setId').click(function () {\\n p2_id = Number(prompt('輸入對手 id?'));\\n DB.broadcast('fightwithme', {\\n from: p1_id,\\n to: p2_id,\\n });\\n});\\n\\nDB.onMessage('fightwithme', function (data) {\\n if (data.to == p1_id) {\\n p2_id = data.from;\\n DB.broadcast('ok', {\\n to: p2_id,\\n });\\n status = 1;\\n }\\n});\\n\\nDB.onMessage('ok', function(data) {\\n if (data.to == p1_id) {\\n status = 1;\\n }\\n});\\n\\nDB.onMessage('update', function (data) {\\n if (data.to == p1_id) {\\n p2_count = data.count;\\n updateBg();\\n }\\n});\\n\\nDB.onMessage('gameover', function (data) {\\n if (data.to == p1_id) {\\n gameover();\\n }\\n});\\n\\n$('body').click(function () {\\n if (status == 1) {\\n p1_count++;\\n updateBg();\\n DB.broadcast('update', {\\n to: p2_id,\\n count: p1_count,\\n });\\n }\\n});\\n\\nfunction updateBg () {\\n var diff = p1_count - p2_count;\\n $('body').css('background-position', `calc(50% + ${diff*5}px) 50%`);\\n if (diff \u003e= 10) {\\n DB.broadcast('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 $('p').text('獲勝');\\n } else {\\n $('p').text('失敗');\\n }\\n}\"}","created_at":"2019-05-21T11:11:54.244+08:00","updated_at":"2019-11-10T21:57:30.687+08:00","name":"點擊大 PK","language":"web","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/68902/3fa7e3a12fe2f779c19b28e569a30f04.jpg"},"parent_id":3,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":312,"hashid":"kdmsv3w6","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1206611,"file_name":"bg.jpg","project_id":68902,"asset_id":122479,"created_at":"2019-05-21T11:12:25.454+08:00","updated_at":"2019-05-21T11:12:25.454+08:00"},{"id":1206612,"file_name":"cursor.png","project_id":68902,"asset_id":122480,"created_at":"2019-05-21T11:29:09.203+08:00","updated_at":"2019-05-21T11:29:09.203+08:00"},{"id":1206613,"file_name":"clicker.png","project_id":68902,"asset_id":122481,"created_at":"2019-05-21T11:29:10.588+08:00","updated_at":"2019-05-21T11:29:10.588+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
前往網站頁面
1:1:1
1:1
full
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦