{"id":138209,"student_id":10,"content":"import game #載入遊戲框架\nimport random #載入產生隨機數的套件\n\ngame.set_backdrop('bg.jpg') #設定背景圖\n\nanswer = random.randrange(1, 101) #產生 1-100 的隨機整數\nlow = 0 #範圍下界\nhigh = 101 #範圍上界\n\n# game.create_sound('bgm.mp3', True)\n\ndef onclick():\n global low, high #存取函式外部的變數\n \n #取得使用者的輸入\n guess = int(input('請輸入 1-100 的數字?'))\n \n print('ok!')\n \n if guess == answer: #如果猜的跟答一樣大\n game.set_backdrop('bingo.jpg')\n low = answer\n high = answer\n game.stop()\n game.create_sound('bingo.mp3')\n \n if guess \u003e answer: #如果猜的比答案大\n game.set_backdrop('too_high.jpg')\n high = guess\n game.create_sound('lol.mp3')\n \n if guess \u003c answer: #如果猜的比答案小\n game.set_backdrop('too_low.jpg')\n low = guess\n game.create_sound('lol.mp3')\n\n#遊戲迴圈\ndef loop():\n # game.draw_text(answer, 10, 10, 'white', 90)\n game.draw_text(low, 320, 680, 'black', 90)\n game.draw_text(high, 750, 680, 'black', 90)\n\ngame.forever(loop) #重複不斷執行遊戲迴圈\ngame.on('click', onclick) #點擊遊戲場景時執行 onclick 函式\n\n","created_at":"2020-03-30T10:51:11.588+08:00","updated_at":"2020-09-17T17:26:30.806+08:00","name":"終極密碼(完整版)","language":"python","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/138209/9d075c09390610f4222c45b8844e3e33.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":259,"hashid":"kdmspq99","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3272733,"file_name":"lol.mp3","project_id":138209,"asset_id":262226,"created_at":"2020-09-14T11:29:29.540+08:00","updated_at":"2020-09-14T11:29:29.540+08:00"},{"id":3272734,"file_name":"bgm.mp3","project_id":138209,"asset_id":262227,"created_at":"2020-09-14T11:29:36.239+08:00","updated_at":"2020-09-14T11:29:36.239+08:00"},{"id":3272732,"file_name":"bingo.mp3","project_id":138209,"asset_id":262225,"created_at":"2020-09-14T11:28:28.642+08:00","updated_at":"2020-09-14T11:28:28.642+08:00"},{"id":3274721,"file_name":"bg.jpg","project_id":138209,"asset_id":262405,"created_at":"2020-09-16T17:06:08.819+08:00","updated_at":"2020-09-16T17:06:08.819+08:00"},{"id":3274720,"file_name":"too_low.jpg","project_id":138209,"asset_id":262404,"created_at":"2020-09-16T17:06:08.818+08:00","updated_at":"2020-09-16T17:11:45.012+08:00"},{"id":3274718,"file_name":"bingo.jpg","project_id":138209,"asset_id":262402,"created_at":"2020-09-16T17:06:06.848+08:00","updated_at":"2020-09-16T17:06:06.848+08:00"},{"id":3274719,"file_name":"too_high.jpg","project_id":138209,"asset_id":262403,"created_at":"2020-09-16T17:06:06.850+08:00","updated_at":"2020-09-16T17:11:41.521+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦