{"id":177233,"student_id":3760,"content":"import game\nimport random\n\n# 建立骰子及初始化\ndice1 = game.create_sprite(\"1.png\", \"2.png\", \"3.png\", \"4.png\", \"5.png\", \"6.png\")\ndice2 = game.create_sprite(\"1.png\", \"2.png\", \"3.png\", \"4.png\", \"5.png\", \"6.png\")\ndice3 = game.create_sprite(\"1.png\", \"2.png\", \"3.png\", \"4.png\", \"5.png\", \"6.png\")\ndice4 = game.create_sprite(\"1.png\", \"2.png\", \"3.png\", \"4.png\", \"5.png\", \"6.png\")\n\ndice1.x = 300\ndice1.y = 180\ndice2.x = 500\ndice2.y = 180\ndice3.x = 700\ndice3.y = 180\ndice4.x = 900\ndice4.y = 180\n\nscore = 0\n\ndef dice():\n global score\n \n # 隨機產生骰子點數\n dice1.costume_id = random.randrange(6)\n dice2.costume_id = random.randrange(6)\n dice3.costume_id = random.randrange(6)\n dice4.costume_id = random.randrange(6)\n \n # 計分\n dice_1 = dice1.costume_id + 1\n dice_2 = dice2.costume_id + 1\n dice_3 = dice3.costume_id + 1\n dice_4 = dice4.costume_id + 1\n \n if dice_1==dice_2 and dice_2==dice_3 and dice_3==dice_4:\n score = 10000\n elif dice_1==dice_2 and dice_1!=dice_3 and dice_1!=dice_4 and dice_3!=dice_4:\n score = dice_3 + dice_4\n elif dice_1==dice_3 and dice_1!=dice_2 and dice_1!=dice_4 and dice_2!=dice_4:\n score = dice_2 + dice_4\n elif dice_1==dice_4 and dice_1!=dice_2 and dice_1!=dice_3 and dice_2!=dice_3:\n score = dice_2 + dice_3\n elif dice_2==dice_3 and dice_2!=dice_1 and dice_2!=dice_4 and dice_1!=dice_4:\n score = dice_1 + dice_4\n elif dice_2==dice_4 and dice_2!=dice_1 and dice_2!=dice_3 and dice_1!=dice_3:\n score = dice_1 + dice_3\n elif dice_3==dice_4 and dice_3!=dice_1 and dice_3!=dice_2 and dice_1!=dice_2:\n score = dice_1 + dice_2\n elif dice_1==dice_2 and dice_3==dice_4:\n if dice_1 \u003e dice_3:\n score = dice_1 + dice_2\n else:\n score = dice_3 + dice_4\n elif dice_1==dice_3 and dice_2==dice_4:\n if dice_1 \u003e dice_2:\n score = dice_1 + dice_3\n else:\n score = dice_2 + dice_4\n elif dice_1==dice_4 and dice_2==dice_3:\n if dice_1 \u003e dice_2:\n score = dice_1 + dice_4\n else:\n score = dice_2 + dice_3\n \n\n # 分數顯示以及停止\n if score \u003e 1 and score != 10000:\n game.draw_text(str(score), 600, 620, 'black', 90)\n game.stop()\n if score == 10000:\n game.draw_text(\"win\", 600, 620, 'black', 90)\n game.stop()\n\n# enter鍵按下偵測\ngame.on(\"keydown\", \"enter\", dice)\n","created_at":"2020-08-05T12:21:25.676+08:00","updated_at":"2020-08-19T11:48:38.947+08:00","name":"十八仔_S 副本","language":"python","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/177233/20bcc88d8cabcb20d05329147edd3734.jpg"},"parent_id":162837,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":36,"hashid":"6rpsv2pw","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3029205,"file_name":"player.png","project_id":177233,"asset_id":232683,"created_at":"2020-08-05T12:21:25.680+08:00","updated_at":"2020-08-05T12:21:25.680+08:00"},{"id":3029206,"file_name":"2.png","project_id":177233,"asset_id":23146,"created_at":"2020-08-05T12:21:25.681+08:00","updated_at":"2020-08-05T12:21:25.681+08:00"},{"id":3029207,"file_name":"3.png","project_id":177233,"asset_id":23147,"created_at":"2020-08-05T12:21:25.682+08:00","updated_at":"2020-08-05T12:21:25.682+08:00"},{"id":3029208,"file_name":"4.png","project_id":177233,"asset_id":23148,"created_at":"2020-08-05T12:21:25.683+08:00","updated_at":"2020-08-05T12:21:25.683+08:00"},{"id":3029209,"file_name":"5.png","project_id":177233,"asset_id":23149,"created_at":"2020-08-05T12:21:25.684+08:00","updated_at":"2020-08-05T12:21:25.684+08:00"},{"id":3029210,"file_name":"6.png","project_id":177233,"asset_id":23150,"created_at":"2020-08-05T12:21:25.685+08:00","updated_at":"2020-08-05T12:21:25.685+08:00"},{"id":3029211,"file_name":"1.png","project_id":177233,"asset_id":23145,"created_at":"2020-08-05T12:21:25.685+08:00","updated_at":"2020-08-05T12:21:25.685+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦