{"id":168794,"student_id":3232,"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\")\ndice1.x = 300\ndice1.y = 180\ndice2.x = 500\ndice2.y = 180\ndice3.x = 700\ndice3.y = 180\ndice4.x = 900\ndice4.y = 180\nscore = 0\n\ndef dice():\n global score\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 # 計分\n if dice1.costume_id == dice2.costume_id == dice3.costume_id == dice4.costume_id:\n game.draw_text(\"win\", 500, 500, \"black\", 180)\n print(score)\n game.stop()\n \n elif dice1.costume_id == dice2.costume_id:\n if dice1.costume_id != dice3.costume_id and dice1.costume_id != dice4.costume_id:\n if dice3.costume_id != dice4.costume_id:\n score = dice3.costume_id + dice4.costume_id + 2\n print(score)\n game.stop()\n else:\n if dice3.costume_id \u003e dice1.costume_id:\n score = dice3.costume_id + dice4.costume_id + 2\n else:\n score = dice1.costume_id + dice2.costume_id + 2\n elif dice1.costume_id == dice3.costume_id:\n if dice1.costume_id != dice2.costume_id and dice1.costume_id != dice4.costume_id:\n if dice2.costume_id != dice4.costume_id:\n score = dice2.costume_id + dice4.costume_id + 2\n print(score)\n game.stop()\n else:\n if dice2.costume_id \u003e dice1.costume_id:\n score = dice2.costume_id + dice4.costume_id + 2\n else:\n score = dice1.costume_id + dice3.costume_id + 2\n elif dice1.costume_id == dice4.costume_id:\n if dice1.costume_id != dice3.costume_id and dice1.costume_id != dice2.costume_id:\n if dice3.costume_id != dice2.costume_id:\n score = dice2.costume_id + dice3.costume_id + 2\n print(score)\n game.stop()\n else:\n if dice2.costume_id \u003e dice1.costume_id:\n score = dice3.costume_id + dice2.costume_id + 2\n else:\n score = dice1.costume_id + dice4.costume_id + 2\n elif dice2.costume_id == dice3.costume_id:\n if dice2.costume_id != dice1.costume_id and dice2.costume_id != dice4.costume_id:\n if dice1.costume_id != dice4.costume_id:\n score = dice1.costume_id + dice4.costume_id + 2\n print(score)\n game.stop()\n else:\n if dice3.costume_id \u003e dice1.costume_id:\n score = dice3.costume_id + dice2.costume_id + 2\n else:\n score = dice1.costume_id + dice4.costume_id + 2\n elif dice2.costume_id == dice4.costume_id:\n if dice2.costume_id != dice3.costume_id and dice2.costume_id != dice1.costume_id:\n if dice3.costume_id != dice1.costume_id:\n score = dice3.costume_id + dice1.costume_id + 2\n print(score)\n game.stop()\n else:\n if dice2.costume_id \u003e dice1.costume_id:\n score = dice2.costume_id + dice4.costume_id + 2\n else:\n score = dice1.costume_id + dice3.costume_id + 2\n elif dice3.costume_id == dice4.costume_id:\n if dice3.costume_id != dice1.costume_id and dice3.costume_id != dice2.costume_id:\n if dice1.costume_id != dice2.costume_id:\n score = dice1.costume_id + dice2.costume_id + 2\n print(score)\n game.stop()\n else:\n if dice3.costume_id \u003e dice1.costume_id:\n score = dice3.costume_id + dice4.costume_id + 2\n else:\n score = dice1.costume_id + dice2.costume_id + 2\n \n # 分數顯示以及停止\n if score \u003e 0:\n game.draw_text(score, 500, 500, \"black\", 90)\n game.stop()\n# enter鍵按下偵測\ngame.on(\"keydown\", \"enter\", dice)","created_at":"2020-07-21T08:59:16.826+08:00","updated_at":"2020-07-21T10:52:48.167+08:00","name":"十八仔_S 副本","language":"python","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/168794/b0c806952fb5fbf85b8d465d9527d517.jpg"},"parent_id":162837,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":42,"hashid":"wdksym2r","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2922018,"file_name":"player.png","project_id":168794,"asset_id":232683,"created_at":"2020-07-21T08:59:16.831+08:00","updated_at":"2020-07-21T08:59:16.831+08:00"},{"id":2922019,"file_name":"2.png","project_id":168794,"asset_id":23146,"created_at":"2020-07-21T08:59:16.832+08:00","updated_at":"2020-07-21T08:59:16.832+08:00"},{"id":2922020,"file_name":"3.png","project_id":168794,"asset_id":23147,"created_at":"2020-07-21T08:59:16.833+08:00","updated_at":"2020-07-21T08:59:16.833+08:00"},{"id":2922021,"file_name":"4.png","project_id":168794,"asset_id":23148,"created_at":"2020-07-21T08:59:16.834+08:00","updated_at":"2020-07-21T08:59:16.834+08:00"},{"id":2922022,"file_name":"5.png","project_id":168794,"asset_id":23149,"created_at":"2020-07-21T08:59:16.835+08:00","updated_at":"2020-07-21T08:59:16.835+08:00"},{"id":2922023,"file_name":"6.png","project_id":168794,"asset_id":23150,"created_at":"2020-07-21T08:59:16.836+08:00","updated_at":"2020-07-21T08:59:16.836+08:00"},{"id":2922024,"file_name":"1.png","project_id":168794,"asset_id":23145,"created_at":"2020-07-21T08:59:16.837+08:00","updated_at":"2020-07-21T08:59:16.837+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦