{"id":13312,"student_id":10,"content":"setBackdrop(\"bg.png\");\nvar W = 23;\nvar current = 'b';\nvar grid = [];\nfor(var x=0; x\u003cW; x++) {\n grid[x] = [];\n}\n\nforever(function(){\n for (var x=4; x\u003cW-4; x++) {\n for (var y=4; y\u003cW-4; y++) {\n pen.size = 0;\n if (grid[x][y] == undefined) continue;\n if (grid[x][y] == 'b') pen.fillColor = 'black';\n if (grid[x][y] == 'w') pen.fillColor = 'white';\n pen.drawCircle(x*30 - 11, y*30 - 91, 14);\n }\n }\n for (var x=4; x\u003cW-4; x++) {\n for (var y=4; y\u003cW-4; y++) {\n check(x, y, 1, 0);\n check(x, y, -1, 0);\n check(x, y, 0, 1);\n check(x, y, 0, -1);\n check(x, y, 1, 1);\n check(x, y, -1, 1);\n check(x, y, 1, -1);\n check(x, y, -1, -1);\n }\n }\n});\n\nwhen('click', function () {\n var x = Math.floor((cursor.x - 95)/30) + 4;\n var y = Math.floor((cursor.y - 15)/30) + 4;\n\n if (x \u003c 4 || x \u003e= 19 || y \u003c 4 || y \u003e= 19) return;\n\n if (grid[x][y] != undefined) return;\n\n grid[x][y] = current;\n current = current == 'b' ? 'w' : 'b';\n});\n\nfunction check (x, y, vx, vy) {\n var re = grid[x][y] + grid[x + vx][y + vy] + grid[x + vx*2][y + vy*2] + grid[x + vx*3][y + vy*3] + grid[x + vx*4][y + vy*4];\n if (re == 'bbbbb') {\n print(\"黑方獲勝\");\n stop();\n }\n if (re == 'wwwww') {\n print(\"白方獲勝\");\n stop();\n }\n}","created_at":"2017-03-01T20:52:04.729+08:00","updated_at":"2019-11-12T02:14:58.690+08:00","name":"五子棋","language":"javascript","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/13312/89edcce60b8890776f43b51e69f48ea4.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":true,"views":1446,"hashid":"vngsygre","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":275053,"file_name":"bg.png","project_id":13312,"asset_id":33400,"created_at":"2017-10-16T21:06:25.584+08:00","updated_at":"2017-10-16T21:06:25.584+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦