{"id":182931,"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(0, 6)\n dice2.costume_id = random.randrange(0, 6)\n dice3.costume_id = random.randrange(0, 6)\n dice4.costume_id = random.randrange(0, 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 \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\n\n\n","created_at":"2020-08-19T11:42:31.606+08:00","updated_at":"2020-08-19T12:16:30.723+08:00","name":"十八仔_S 副本 副本","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/182931/5dd1da1c2af4033b0b93539edc1758b5.jpg"},"parent_id":182922,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":81,"hashid":"kdmsqn5z","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3111983,"file_name":"1.png","project_id":182931,"asset_id":23145,"created_at":"2020-08-19T11:42:31.612+08:00","updated_at":"2020-08-19T11:42:31.612+08:00"},{"id":3111984,"file_name":"6.png","project_id":182931,"asset_id":23150,"created_at":"2020-08-19T11:42:31.614+08:00","updated_at":"2020-08-19T11:42:31.614+08:00"},{"id":3111985,"file_name":"5.png","project_id":182931,"asset_id":23149,"created_at":"2020-08-19T11:42:31.615+08:00","updated_at":"2020-08-19T11:42:31.615+08:00"},{"id":3111986,"file_name":"4.png","project_id":182931,"asset_id":23148,"created_at":"2020-08-19T11:42:31.616+08:00","updated_at":"2020-08-19T11:42:31.616+08:00"},{"id":3111987,"file_name":"3.png","project_id":182931,"asset_id":23147,"created_at":"2020-08-19T11:42:31.617+08:00","updated_at":"2020-08-19T11:42:31.617+08:00"},{"id":3111988,"file_name":"2.png","project_id":182931,"asset_id":23146,"created_at":"2020-08-19T11:42:31.618+08:00","updated_at":"2020-08-19T11:42:31.618+08:00"},{"id":3111989,"file_name":"player.png","project_id":182931,"asset_id":232683,"created_at":"2020-08-19T11:42:31.619+08:00","updated_at":"2020-08-19T11:42:31.619+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
繁中
简中
English
日本語
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦