{"id":745493,"student_id":10,"content":"from game import *\nfrom random import *\n\nH = 8 #高幾個國旗\nW = 12 #寬幾個國旗\nset_backdrop('bg.png')\nimgs = [str(i) + '.png' for i in range(32)]\nnums = ['n' + str(i) + '.png' for i in range(10)]\nrules = create_sprite('rules.png', 'end.png')\nrules.layer = 1\n\ntimer = [] #從放時間角色\nlights = [] #存放黃色方塊\nflags = [] #存放國旗角色\nstart = None #存放第一次點擊的國旗角色\nclock = 0 #紀錄經過多少時間\ncount = 0 #紀錄消除多少個國旗\n\n# 創造時間數字\nfor i in range(4):\n n = create_sprite(nums)\n n.x = 240 * i + 240\n n.x *= 0.1 #縮小至左上角\n n.y *= 0.1 #縮小至左上角\n n.scale *= 0.1 #縮小至左上角\n timer.append(n)\n\n# 創造黃色塊\nfor y in range(H + 4):\n for x in range(W + 4):\n l = create_sprite('yellow.png')\n l.x = x * 75 + 75 * 0.5\n l.y = y * 75 + 75 * 0.5\n lights.append(l)\n\n# 創造國旗\nfor x in range(W):\n for y in range(H):\n f = create_sprite(imgs)\n f.x = x * 75 + 75 * 2.5\n f.y = y * 75 + 75 * 2.5\n f.costume_id = (y * W + x) // 2 % 32\n flags.append(f)\n\n# 洗牌\ndef shuffle():\n for i in range(W * H):\n rand = randrange(W * H)\n f1 = flags[i]\n f2 = flags[rand]\n a = f1.costume_id\n b = f2.costume_id\n f1.costume_id = b\n f2.costume_id = a\n\n# 遊戲迴圈\ndef loop():\n global start\n \n for s in lights:\n if not start: #如果沒有點擊第一個國旗\n s.opacity = 0.01 #就全部設定為幾乎透明\n elif s.touched(cursor): #如果碰到滑鼠\n s.opacity = 1 #就讓方塊量起來\n \n for f in flags:\n if start and f.touched(cursor) and f.costume_id != start.costume_id:\n start = None\n \n if check_jump(): start = None\n \n update_timer() #更新時間\n \n# 更新時間\ndef update_timer():\n global clock\n if rules.hidden: clock += 1\n s = clock // 60\n timer[0].costume_id = (s // 60) // 10\n timer[1].costume_id = (s // 60) % 10\n timer[2].costume_id = (s % 60) // 10\n timer[3].costume_id = (s % 60) % 10\n \n# 滑鼠按下 \ndef mousedown():\n global start\n for f in flags:\n if f.touched(cursor):\n start = f\n\n# 滑鼠放開\ndef mouseup():\n global start, count\n for f in flags:\n # 如果已經點了第一個旗子\n # 而且這個旗子碰到滑鼠\n # 而且這個旗子的造型跟第一個旗子一樣\n # 而且這個旗子跟第一個旗子不是同一個角色\n if start and f.touched(cursor) and f.costume_id == start.costume_id and f is not start:\n f.hidden = True #隱藏這個旗子\n start.hidden = True #隱藏第二個旗子\n count += 2\n start = None #清空\n \n if count == W * H: gameover()\n \n# 開始遊戲\ndef startgame():\n rules.hidden = True\n\n# 遊戲結束\ndef gameover():\n for n in timer: #將時間放大恢復至場景中央\n n.scale *= 10\n n.x *= 10\n n.y *= 10\n end.costume_id = 1 #切換結束圖片\n end.hidden = False #顯示遊戲結束\n stop()\n \n# 檢查連續\ndef check_jump():\n for a in lights:\n count = 0\n for b in lights:\n if b.opacity == 1 and a.distance_to(b) \u003c= 75:\n count += 1\n if count == 0 and a.opacity == 1:\n return True\n return False\n\non('mousedown', mousedown) #當滑鼠按下時\non('mouseup', mouseup) #當滑鼠放開時\nrules.on('click', startgame) #當遊戲說明被點擊時\nforever(loop) #重複不斷執行遊戲迴圈\nshuffle()\n\n\n","created_at":"2024-05-06T17:30:56.980+08:00","updated_at":"2024-11-13T10:51:54.222+08:00","name":"國旗配對碰","language":"python","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/745493/0ed12b0031bb6e87461d4fcdba1cace7.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":142,"hashid":"d5msnr83p","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":16761079,"file_name":"38.png","project_id":745493,"asset_id":741709,"created_at":"2024-05-15T10:35:33.799+08:00","updated_at":"2024-05-15T10:35:33.799+08:00"},{"id":16761080,"file_name":"39.png","project_id":745493,"asset_id":741710,"created_at":"2024-05-15T10:35:33.801+08:00","updated_at":"2024-05-15T10:35:33.801+08:00"},{"id":16761127,"file_name":"coin.ogg","project_id":745493,"asset_id":741755,"created_at":"2024-05-15T11:34:01.167+08:00","updated_at":"2024-05-15T11:34:01.167+08:00"},{"id":16761049,"file_name":"8.png","project_id":745493,"asset_id":741679,"created_at":"2024-05-15T10:35:25.396+08:00","updated_at":"2024-05-15T10:35:25.396+08:00"},{"id":16761050,"file_name":"9.png","project_id":745493,"asset_id":741680,"created_at":"2024-05-15T10:35:25.398+08:00","updated_at":"2024-05-15T10:35:25.398+08:00"},{"id":16761111,"file_name":"bg.png","project_id":745493,"asset_id":741741,"created_at":"2024-05-15T10:35:40.278+08:00","updated_at":"2024-05-15T10:35:40.278+08:00"},{"id":16761117,"file_name":"n4.png","project_id":745493,"asset_id":741747,"created_at":"2024-05-15T10:35:41.679+08:00","updated_at":"2024-05-15T10:35:41.679+08:00"},{"id":16761118,"file_name":"n5.png","project_id":745493,"asset_id":741748,"created_at":"2024-05-15T10:35:41.681+08:00","updated_at":"2024-05-15T10:35:41.681+08:00"},{"id":16761119,"file_name":"n6.png","project_id":745493,"asset_id":741749,"created_at":"2024-05-15T10:35:42.064+08:00","updated_at":"2024-05-15T10:35:42.064+08:00"},{"id":16761120,"file_name":"n7.png","project_id":745493,"asset_id":741750,"created_at":"2024-05-15T10:35:42.065+08:00","updated_at":"2024-05-15T10:35:42.065+08:00"},{"id":16761109,"file_name":"68.png","project_id":745493,"asset_id":741739,"created_at":"2024-05-15T10:35:39.869+08:00","updated_at":"2024-05-15T10:35:39.869+08:00"},{"id":16761110,"file_name":"69.png","project_id":745493,"asset_id":741740,"created_at":"2024-05-15T10:35:39.871+08:00","updated_at":"2024-05-15T10:35:39.871+08:00"},{"id":16761115,"file_name":"n2.png","project_id":745493,"asset_id":741745,"created_at":"2024-05-15T10:35:41.030+08:00","updated_at":"2024-05-15T10:35:41.030+08:00"},{"id":16761116,"file_name":"n3.png","project_id":745493,"asset_id":741746,"created_at":"2024-05-15T10:35:41.032+08:00","updated_at":"2024-05-15T10:35:41.032+08:00"},{"id":16761051,"file_name":"10.png","project_id":745493,"asset_id":741681,"created_at":"2024-05-15T10:35:26.293+08:00","updated_at":"2024-05-15T10:35:26.293+08:00"},{"id":16761052,"file_name":"11.png","project_id":745493,"asset_id":741682,"created_at":"2024-05-15T10:35:26.294+08:00","updated_at":"2024-05-15T10:35:26.294+08:00"},{"id":16761053,"file_name":"12.png","project_id":745493,"asset_id":741683,"created_at":"2024-05-15T10:35:27.199+08:00","updated_at":"2024-05-15T10:35:27.199+08:00"},{"id":16761054,"file_name":"13.png","project_id":745493,"asset_id":741684,"created_at":"2024-05-15T10:35:27.201+08:00","updated_at":"2024-05-15T10:35:27.201+08:00"},{"id":16761055,"file_name":"14.png","project_id":745493,"asset_id":741685,"created_at":"2024-05-15T10:35:27.665+08:00","updated_at":"2024-05-15T10:35:27.665+08:00"},{"id":16761056,"file_name":"15.png","project_id":745493,"asset_id":741686,"created_at":"2024-05-15T10:35:27.667+08:00","updated_at":"2024-05-15T10:35:27.667+08:00"},{"id":16761057,"file_name":"16.png","project_id":745493,"asset_id":741687,"created_at":"2024-05-15T10:35:28.046+08:00","updated_at":"2024-05-15T10:35:28.046+08:00"},{"id":16761058,"file_name":"17.png","project_id":745493,"asset_id":741688,"created_at":"2024-05-15T10:35:28.048+08:00","updated_at":"2024-05-15T10:35:28.048+08:00"},{"id":16761061,"file_name":"20.png","project_id":745493,"asset_id":741691,"created_at":"2024-05-15T10:35:28.820+08:00","updated_at":"2024-05-15T10:35:28.820+08:00"},{"id":16761062,"file_name":"21.png","project_id":745493,"asset_id":741692,"created_at":"2024-05-15T10:35:28.821+08:00","updated_at":"2024-05-15T10:35:28.821+08:00"},{"id":16761063,"file_name":"22.png","project_id":745493,"asset_id":741693,"created_at":"2024-05-15T10:35:29.749+08:00","updated_at":"2024-05-15T10:35:29.749+08:00"},{"id":16761064,"file_name":"23.png","project_id":745493,"asset_id":741694,"created_at":"2024-05-15T10:35:29.751+08:00","updated_at":"2024-05-15T10:35:29.751+08:00"},{"id":16761069,"file_name":"28.png","project_id":745493,"asset_id":741699,"created_at":"2024-05-15T10:35:30.985+08:00","updated_at":"2024-05-15T10:35:30.985+08:00"},{"id":16761070,"file_name":"29.png","project_id":745493,"asset_id":741700,"created_at":"2024-05-15T10:35:30.987+08:00","updated_at":"2024-05-15T10:35:30.987+08:00"},{"id":16761073,"file_name":"32.png","project_id":745493,"asset_id":741703,"created_at":"2024-05-15T10:35:32.610+08:00","updated_at":"2024-05-15T10:35:32.610+08:00"},{"id":16761074,"file_name":"33.png","project_id":745493,"asset_id":741704,"created_at":"2024-05-15T10:35:32.612+08:00","updated_at":"2024-05-15T10:35:32.612+08:00"},{"id":16761075,"file_name":"34.png","project_id":745493,"asset_id":741705,"created_at":"2024-05-15T10:35:33.071+08:00","updated_at":"2024-05-15T10:35:33.071+08:00"},{"id":16761076,"file_name":"35.png","project_id":745493,"asset_id":741706,"created_at":"2024-05-15T10:35:33.073+08:00","updated_at":"2024-05-15T10:35:33.073+08:00"},{"id":16761077,"file_name":"36.png","project_id":745493,"asset_id":741707,"created_at":"2024-05-15T10:35:33.442+08:00","updated_at":"2024-05-15T10:35:33.442+08:00"},{"id":16761078,"file_name":"37.png","project_id":745493,"asset_id":741708,"created_at":"2024-05-15T10:35:33.444+08:00","updated_at":"2024-05-15T10:35:33.444+08:00"},{"id":16761081,"file_name":"40.png","project_id":745493,"asset_id":741711,"created_at":"2024-05-15T10:35:34.196+08:00","updated_at":"2024-05-15T10:35:34.196+08:00"},{"id":16761082,"file_name":"41.png","project_id":745493,"asset_id":741712,"created_at":"2024-05-15T10:35:34.198+08:00","updated_at":"2024-05-15T10:35:34.198+08:00"},{"id":16761083,"file_name":"42.png","project_id":745493,"asset_id":741713,"created_at":"2024-05-15T10:35:34.650+08:00","updated_at":"2024-05-15T10:35:34.650+08:00"},{"id":16761084,"file_name":"43.png","project_id":745493,"asset_id":741714,"created_at":"2024-05-15T10:35:34.652+08:00","updated_at":"2024-05-15T10:35:34.652+08:00"},{"id":16761085,"file_name":"44.png","project_id":745493,"asset_id":741715,"created_at":"2024-05-15T10:35:35.018+08:00","updated_at":"2024-05-15T10:35:35.018+08:00"},{"id":16761086,"file_name":"45.png","project_id":745493,"asset_id":741716,"created_at":"2024-05-15T10:35:35.019+08:00","updated_at":"2024-05-15T10:35:35.019+08:00"},{"id":16761091,"file_name":"50.png","project_id":745493,"asset_id":741721,"created_at":"2024-05-15T10:35:36.315+08:00","updated_at":"2024-05-15T10:35:36.315+08:00"},{"id":16761092,"file_name":"51.png","project_id":745493,"asset_id":741722,"created_at":"2024-05-15T10:35:36.317+08:00","updated_at":"2024-05-15T10:35:36.317+08:00"},{"id":16761093,"file_name":"52.png","project_id":745493,"asset_id":741723,"created_at":"2024-05-15T10:35:36.701+08:00","updated_at":"2024-05-15T10:35:36.701+08:00"},{"id":16761094,"file_name":"53.png","project_id":745493,"asset_id":741724,"created_at":"2024-05-15T10:35:36.703+08:00","updated_at":"2024-05-15T10:35:36.703+08:00"},{"id":16761103,"file_name":"62.png","project_id":745493,"asset_id":741733,"created_at":"2024-05-15T10:35:38.747+08:00","updated_at":"2024-05-15T10:35:38.747+08:00"},{"id":16761104,"file_name":"63.png","project_id":745493,"asset_id":741734,"created_at":"2024-05-15T10:35:38.749+08:00","updated_at":"2024-05-15T10:35:38.749+08:00"},{"id":16761087,"file_name":"46.png","project_id":745493,"asset_id":741717,"created_at":"2024-05-15T10:35:35.395+08:00","updated_at":"2024-05-15T10:35:35.395+08:00"},{"id":16761088,"file_name":"47.png","project_id":745493,"asset_id":741718,"created_at":"2024-05-15T10:35:35.397+08:00","updated_at":"2024-05-15T10:35:35.397+08:00"},{"id":16761089,"file_name":"48.png","project_id":745493,"asset_id":741719,"created_at":"2024-05-15T10:35:35.827+08:00","updated_at":"2024-05-15T10:35:35.827+08:00"},{"id":16761090,"file_name":"49.png","project_id":745493,"asset_id":741720,"created_at":"2024-05-15T10:35:35.828+08:00","updated_at":"2024-05-15T10:35:35.828+08:00"},{"id":16761041,"file_name":"0.png","project_id":745493,"asset_id":741671,"created_at":"2024-05-15T10:35:21.680+08:00","updated_at":"2024-05-15T10:35:21.680+08:00"},{"id":16761042,"file_name":"1.png","project_id":745493,"asset_id":741672,"created_at":"2024-05-15T10:35:21.684+08:00","updated_at":"2024-05-15T10:35:21.684+08:00"},{"id":16761121,"file_name":"n8.png","project_id":745493,"asset_id":741751,"created_at":"2024-05-15T10:35:42.452+08:00","updated_at":"2024-05-15T10:35:42.452+08:00"},{"id":16761122,"file_name":"n9.png","project_id":745493,"asset_id":741752,"created_at":"2024-05-15T10:35:42.454+08:00","updated_at":"2024-05-15T10:35:42.454+08:00"},{"id":16761065,"file_name":"24.png","project_id":745493,"asset_id":741695,"created_at":"2024-05-15T10:35:30.137+08:00","updated_at":"2024-05-15T10:35:30.137+08:00"},{"id":16761066,"file_name":"25.png","project_id":745493,"asset_id":741696,"created_at":"2024-05-15T10:35:30.139+08:00","updated_at":"2024-05-15T10:35:30.139+08:00"},{"id":16761067,"file_name":"26.png","project_id":745493,"asset_id":741697,"created_at":"2024-05-15T10:35:30.509+08:00","updated_at":"2024-05-15T10:35:30.509+08:00"},{"id":16761068,"file_name":"27.png","project_id":745493,"asset_id":741698,"created_at":"2024-05-15T10:35:30.511+08:00","updated_at":"2024-05-15T10:35:30.511+08:00"},{"id":16761095,"file_name":"54.png","project_id":745493,"asset_id":741725,"created_at":"2024-05-15T10:35:37.179+08:00","updated_at":"2024-05-15T10:35:37.179+08:00"},{"id":16761096,"file_name":"55.png","project_id":745493,"asset_id":741726,"created_at":"2024-05-15T10:35:37.180+08:00","updated_at":"2024-05-15T10:35:37.180+08:00"},{"id":16761105,"file_name":"64.png","project_id":745493,"asset_id":741735,"created_at":"2024-05-15T10:35:39.116+08:00","updated_at":"2024-05-15T10:35:39.116+08:00"},{"id":16761106,"file_name":"65.png","project_id":745493,"asset_id":741736,"created_at":"2024-05-15T10:35:39.118+08:00","updated_at":"2024-05-15T10:35:39.118+08:00"},{"id":16761043,"file_name":"2.png","project_id":745493,"asset_id":741673,"created_at":"2024-05-15T10:35:22.624+08:00","updated_at":"2024-05-15T10:35:22.624+08:00"},{"id":16761044,"file_name":"3.png","project_id":745493,"asset_id":741674,"created_at":"2024-05-15T10:35:22.625+08:00","updated_at":"2024-05-15T10:35:22.625+08:00"},{"id":16761113,"file_name":"n0.png","project_id":745493,"asset_id":741743,"created_at":"2024-05-15T10:35:40.653+08:00","updated_at":"2024-05-15T10:35:40.653+08:00"},{"id":16761114,"file_name":"n1.png","project_id":745493,"asset_id":741744,"created_at":"2024-05-15T10:35:40.655+08:00","updated_at":"2024-05-15T10:35:40.655+08:00"},{"id":16761101,"file_name":"60.png","project_id":745493,"asset_id":741731,"created_at":"2024-05-15T10:35:38.385+08:00","updated_at":"2024-05-15T10:35:38.385+08:00"},{"id":16761102,"file_name":"61.png","project_id":745493,"asset_id":741732,"created_at":"2024-05-15T10:35:38.387+08:00","updated_at":"2024-05-15T10:35:38.387+08:00"},{"id":16761126,"file_name":"bgm.ogg","project_id":745493,"asset_id":741754,"created_at":"2024-05-15T11:32:29.125+08:00","updated_at":"2024-05-15T11:32:29.125+08:00"},{"id":16761059,"file_name":"18.png","project_id":745493,"asset_id":741689,"created_at":"2024-05-15T10:35:28.417+08:00","updated_at":"2024-05-15T10:35:28.417+08:00"},{"id":16761060,"file_name":"19.png","project_id":745493,"asset_id":741690,"created_at":"2024-05-15T10:35:28.420+08:00","updated_at":"2024-05-15T10:35:28.420+08:00"},{"id":16761071,"file_name":"30.png","project_id":745493,"asset_id":741701,"created_at":"2024-05-15T10:35:31.368+08:00","updated_at":"2024-05-15T10:35:31.368+08:00"},{"id":16761072,"file_name":"31.png","project_id":745493,"asset_id":741702,"created_at":"2024-05-15T10:35:31.370+08:00","updated_at":"2024-05-15T10:35:31.370+08:00"},{"id":16761123,"file_name":"rules.png","project_id":745493,"asset_id":741753,"created_at":"2024-05-15T10:35:42.936+08:00","updated_at":"2024-05-15T10:35:42.936+08:00"},{"id":16761099,"file_name":"58.png","project_id":745493,"asset_id":741729,"created_at":"2024-05-15T10:35:38.007+08:00","updated_at":"2024-05-15T10:35:38.007+08:00"},{"id":16761100,"file_name":"59.png","project_id":745493,"asset_id":741730,"created_at":"2024-05-15T10:35:38.009+08:00","updated_at":"2024-05-15T10:35:38.009+08:00"},{"id":16761107,"file_name":"66.png","project_id":745493,"asset_id":741737,"created_at":"2024-05-15T10:35:39.491+08:00","updated_at":"2024-05-15T10:35:39.491+08:00"},{"id":16761108,"file_name":"67.png","project_id":745493,"asset_id":741738,"created_at":"2024-05-15T10:35:39.494+08:00","updated_at":"2024-05-15T10:35:39.494+08:00"},{"id":16761045,"file_name":"4.png","project_id":745493,"asset_id":741675,"created_at":"2024-05-15T10:35:23.125+08:00","updated_at":"2024-05-15T10:35:23.125+08:00"},{"id":16761046,"file_name":"5.png","project_id":745493,"asset_id":741676,"created_at":"2024-05-15T10:35:23.128+08:00","updated_at":"2024-05-15T10:35:23.128+08:00"},{"id":16761047,"file_name":"6.png","project_id":745493,"asset_id":741677,"created_at":"2024-05-15T10:35:24.425+08:00","updated_at":"2024-05-15T10:35:24.425+08:00"},{"id":16761048,"file_name":"7.png","project_id":745493,"asset_id":741678,"created_at":"2024-05-15T10:35:24.427+08:00","updated_at":"2024-05-15T10:35:24.427+08:00"},{"id":16761097,"file_name":"56.png","project_id":745493,"asset_id":741727,"created_at":"2024-05-15T10:35:37.617+08:00","updated_at":"2024-05-15T10:35:37.617+08:00"},{"id":16761098,"file_name":"57.png","project_id":745493,"asset_id":741728,"created_at":"2024-05-15T10:35:37.619+08:00","updated_at":"2024-05-15T10:35:37.619+08:00"},{"id":16768164,"file_name":"end.png","project_id":745493,"asset_id":741856,"created_at":"2024-05-17T10:32:31.380+08:00","updated_at":"2024-05-17T10:32:31.380+08:00"},{"id":16865635,"file_name":"yellow.png","project_id":745493,"asset_id":743091,"created_at":"2024-05-20T16:42:06.518+08:00","updated_at":"2024-05-20T16:42:06.518+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦