{"id":201158,"student_id":10,"content":"# # level 1\ngrid = [\n ['red', 'orange', 'red'],\n ['orange', 'red', 'orange'],\n ['red', 'orange', 'red'],\n]\n\n\n# # level 2\n# for x in range(10):\n# grid.append([])\n# for y in range(10):\n# grid[x].append('orange')\n \n\n# level 3\n# for x in range(10):\n# grid.append([])\n# for y in range(5):\n# grid[x].append('orange')\n# grid[x].append('red')\n\n\n# level 4\n# for x in range(5):\n# row = []\n# for y in range(10):\n# row.append('orange')\n# grid.append(row)\n# row = []\n# for y in range(10):\n# row.append('red')\n# grid.append(row)\n\n\n# # level 5\n# for x in range(10):\n# grid.append([])\n# for y in range(10):\n# if (x + y) % 2 == 0:\n# grid[x].append('orange')\n# else:\n# grid[x].append('yellow')","created_at":"2020-11-05T18:04:34.625+08:00","updated_at":"2020-12-09T10:25:10.680+08:00","name":"國旗挑戰","language":"python","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/201158/9ac7374ba4060f4c343dfc34d9ed0f54.jpg"},"parent_id":4,"plugin":"from game import *\nimport time\nimport math\n\ngrid = []\npadding = 10\npen.size = 0\n\ngame.set_backdrop(\"#222\")\nshape = 'circle'\nshowIndex = False\nanimate = True\nflagName = 'ddd'\n\ndef loop():\n \n w = len(grid)\n h = 1\n for i in range(len(grid)):\n if type(grid[i]) == list and len(grid[i]) \u003e h:\n h = len(grid[i])\n\n a = (1200 - padding * 2) / w\n b = (900 - padding * 2) / h\n cellWidth = b if a \u003e b else a\n\n offsetX = (1200 - cellWidth * w) / 2\n offsetY = (900 - cellWidth * h) / 2\n\n for i in range(len(grid)):\n row = grid[i]\n if type(grid[i]) == list:\n for j in range(len(row)):\n pen.fillColor = grid[i][j]\n # pen.draw_rect(offsetX + i*cellWidth, offsetY + j*cellWidth, cellWidth - cellWidth/10, cellWidth - cellWidth/10)\n pen.drawCircle(offsetX + i*cellWidth + cellWidth/2, offsetY + j*cellWidth + cellWidth/2, cellWidth/2 - cellWidth/10)\n else:\n pen.fillColor = grid[i]\n pen.draw_rect(offsetX + i*cellWidth, offsetY + j*cellWidth, cellWidth - cellWidth/10, cellWidth - cellWidth/10)\n \n\n # for i in range(len(grid)):\n \n # if type(grid[i]) == 'list':\n \n # for(j=0 j\u003cgrid[i].length j++) {\n # if(grid[i][j]===undefined) continue\n # pen.fillColor = grid[i][j]\n # if(window.shape == 'rect' \u0026\u0026 !animate) {\n # pen.drawRect(offsetX + i*cellWidth, offsetY + j*cellWidth, cellWidth - cellWidth/10, cellWidth - cellWidth/10)\n # }\n # if(window.shape == 'circle' \u0026\u0026 !animate) {\n # pen.drawCircle(offsetX + i*cellWidth + cellWidth/2, offsetY + j*cellWidth + cellWidth/2, cellWidth/2 - cellWidth/10)\n # }\n # if(animate) {\n # waveX = Math.sin(t*3 - math.pi*i/7)\n # waveY = Math.sin(t*3 - math.pi*i/7 + Math.PI/2)\n # }\n # if(window.shape == 'rect' \u0026\u0026 animate) {\n # pen.drawRect(offsetX + i*cellWidth + waveX*3, offsetY + j*cellWidth + waveY*10, cellWidth - cellWidth/10 - waveX*1.2, cellWidth - cellWidth/10 - waveX*2)\n # }\n # if(window.shape == 'circle' \u0026\u0026 animate) {\n # pen.drawCircle(offsetX + i*cellWidth + cellWidth/2 + waveX*3, offsetY + j*cellWidth + cellWidth/2 + waveY*10, cellWidth/2 - cellWidth/10 - waveX*2)\n # }\n # }\n # } else {\n # if(grid[i]===undefined) continue\n # pen.fillColor = grid[i]\n # if(window.shape == 'rect') {\n # pen.drawRect(offsetX + i*cellWidth, offsetY, cellWidth - cellWidth/10, cellWidth - cellWidth/10)\n # } else {\n # pen.drawCircle(offsetX + i*cellWidth + cellWidth/2, offsetY + cellWidth/2, cellWidth/2 - cellWidth/10)\n # }\n # }\n # }\n\n # if(showIndex) {\n # for(i=0 i\u003cw i++) {\n # print(i, offsetX + i*cellWidth, offsetY - cellWidth/2, \"white\", cellWidth/3)\n # }\n # if(h \u003e 1) {\n # for(i=0 i\u003ch i++) {\n # print(i, offsetX - cellWidth/2, offsetY + i*cellWidth, \"white\", cellWidth/3)\n # }\n # }\n # }\n\n\n\n\n\n\nforever(loop)","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":220,"hashid":"gk4skgvp6","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦