{"id":162838,"student_id":2589,"content":"import game\nimport random\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 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 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 # 如果四個骰子相同\n if dice_1 == dice_2 and dice_2 == dice_3 and dice_3 == dice_4:\n score = 10000\n \n # 1、2 相同 而且 3、4 不相同 而且沒有 3 個一樣\n elif dice_1 == dice_2 and dice_3 != dice_4 and dice_1 != dice_3 and dice_1 != dice_4:\n score = dice_3 + dice_4\n \n # 1、3 相同 而且 2、4 不相同 而且沒有 3 個一樣\n elif dice_1 == dice_3 and dice_2 != dice_4 and dice_1 != dice_2 and dice_1 != dice_4:\n score = dice_2 + dice_4\n \n # 1、4 相同 而且 2、3 不相同 而且沒有 3 個一樣\n elif dice_1 == dice_4 and dice_2 != dice_3 and dice_1 != dice_2 and dice_1 != dice_3:\n score = dice_2 + dice_3\n \n # 2、3 相同 而且 1、4 不相同 而且沒有 3 個一樣\n elif dice_2 == dice_3 and dice_1 != dice_4 and dice_2 != dice_1 and dice_2 != dice_4:\n score = dice_1 + dice_4\n \n # 2、4 相同 而且 1、3 不相同 而且沒有 3 個一樣\n elif dice_2 == dice_4 and dice_1 != dice_3 and dice_2 != dice_1 and dice_2 != dice_3:\n score = dice_1 + dice_3\n \n # 3、4 相同 而且 1、2 不相同 而且沒有 3 個一樣\n elif dice_3 == dice_4 and dice_1 != dice_2 and dice_3 != dice_1 and dice_3 != dice_2:\n score = dice_1 + dice_2\n \n # 1、2 相同 而且 3、4 相同\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 \n # 1、3 相同 而且 2、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 \n # 1、3 相同 而且 2、3 相同\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 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\ngame.on(\"keydown\", \"enter\", dice)\n ","created_at":"2020-07-06T01:06:41.651+08:00","updated_at":"2020-07-31T20:38:44.719+08:00","name":"十八仔_T ","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/162838/3d47c5082bff18bae801593cfea1f753.jpg"},"parent_id":160435,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":214,"hashid":"882sp9ej","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2832508,"file_name":"player.png","project_id":162838,"asset_id":232683,"created_at":"2020-07-06T01:06:41.657+08:00","updated_at":"2020-07-06T01:06:41.657+08:00"},{"id":2832509,"file_name":"2.png","project_id":162838,"asset_id":23146,"created_at":"2020-07-06T01:06:41.658+08:00","updated_at":"2020-07-06T01:06:41.658+08:00"},{"id":2832510,"file_name":"3.png","project_id":162838,"asset_id":23147,"created_at":"2020-07-06T01:06:41.659+08:00","updated_at":"2020-07-06T01:06:41.659+08:00"},{"id":2832511,"file_name":"4.png","project_id":162838,"asset_id":23148,"created_at":"2020-07-06T01:06:41.661+08:00","updated_at":"2020-07-06T01:06:41.661+08:00"},{"id":2832512,"file_name":"5.png","project_id":162838,"asset_id":23149,"created_at":"2020-07-06T01:06:41.662+08:00","updated_at":"2020-07-06T01:06:41.662+08:00"},{"id":2832513,"file_name":"6.png","project_id":162838,"asset_id":23150,"created_at":"2020-07-06T01:06:41.663+08:00","updated_at":"2020-07-06T01:06:41.663+08:00"},{"id":2832514,"file_name":"1.png","project_id":162838,"asset_id":23145,"created_at":"2020-07-06T01:06:41.664+08:00","updated_at":"2020-07-06T01:06:41.664+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦