{"id":194475,"student_id":2589,"content":"","created_at":"2020-10-06T18:23:52.829+08:00","updated_at":"2023-12-05T10:40:32.205+08:00","name":"終極密碼 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/194475/dd958fa784ef89fde46d73b733d31b71.jpg"},"parent_id":4,"plugin":"import game #載入遊戲框架\nimport random #載入產生隨機數的套件\n\ngame.set_backdrop('bg.jpg') #設定背景圖\n\nanswer = random.randrange(1, 101) #產生 1-100 的隨機整數\nlow = 0 #範圍下界\nhigh = 101 #範圍上界\n\ngame.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","description":null,"note":null,"status":"public","like_student_ids":[6571],"is_featured":false,"views":121,"hashid":"yeyseeej","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3330164,"file_name":"bg.jpg","project_id":194475,"asset_id":267906,"created_at":"2020-10-06T18:24:05.574+08:00","updated_at":"2020-10-06T18:24:05.574+08:00"},{"id":3330165,"file_name":"too_low.jpg","project_id":194475,"asset_id":267907,"created_at":"2020-10-06T18:24:05.583+08:00","updated_at":"2020-10-06T18:24:05.583+08:00"},{"id":3330166,"file_name":"too_high.jpg","project_id":194475,"asset_id":267908,"created_at":"2020-10-06T18:24:05.591+08:00","updated_at":"2020-10-06T18:24:05.591+08:00"},{"id":3330167,"file_name":"bingo.jpg","project_id":194475,"asset_id":267909,"created_at":"2020-10-06T18:24:05.600+08:00","updated_at":"2020-10-06T18:24:05.600+08:00"},{"id":3330168,"file_name":"bgm.mp3","project_id":194475,"asset_id":267910,"created_at":"2020-10-06T18:24:05.625+08:00","updated_at":"2020-10-06T18:24:05.625+08:00"},{"id":3330169,"file_name":"lol.mp3","project_id":194475,"asset_id":267911,"created_at":"2020-10-06T18:24:05.629+08:00","updated_at":"2020-10-06T18:24:05.629+08:00"},{"id":3330170,"file_name":"bingo.mp3","project_id":194475,"asset_id":267912,"created_at":"2020-10-06T18:24:05.633+08:00","updated_at":"2020-10-06T18:24:05.633+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦