{"id":252056,"student_id":1998,"content":"import random #載入產生隨機數的套件\nfrom game import * #載入所有遊戲套件提供的方法\n\nset_backdrop('bg.png') #設定背景\nship = create_sprite('player.png') #飛船\nfood = create_sprite('food_0.png','food_1.png','food_2.png') #目標物\nbars = create_sprite('d0.png','d1.png','d2.png','d3.png','d4.png','d5.png','d6.png','d7.png') #儀表板\nn3 = create_sprite('0.png','1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png') #百位數\nn2 = create_sprite('0.png','1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png') #十位數\nn1 = create_sprite('0.png','1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png') #個位數\ngameover_text = create_sprite('gameover.png') #遊戲結束文字圖\n\nn3.move_to(550, 50)\nn2.move_to(600, 50)\nn1.move_to(650, 50)\nbars.move_to(600, 850)\nship.layer = 1\ngameover_text.hidden = True\n\nfood.x = random.randrange(100,1100)\nfood.y = random.randrange(100,800)\nflames = [] #存放火焰角色\nbullets = [] #存放子彈角色\nscore = 0 #玩家分數\nclock = 0 #紀錄遊戲迴圈次數\nlife = 7 #遊戲生命\nend_time = 0 #緩慢模式的結束時間點\n\ngame.create_sound('bgm.mp3') == True\n#遊戲主迴圈\ndef loop ():\n global score, clock, life, end_time\n \n speed = ship.distance_to(cursor) / 20\n ship.toward(cursor)\n ship.step_forward(speed)\n\n if ship.touched(food):\n food.x = random.randrange(100,1100)\n food.y = random.randrange(100,800)\n score += 1\n game.create_sound('effect.wav')\n \n if food.costume_id == 1:\n end_time = clock + 500\n if food.costume_id == 2 and life \u003c 7:\n life += 1\n if score % 10 == 4:\n food.costume_id = 1\n elif score % 10 == 9:\n food.costume_id = 2\n else:\n food.costume_id = 0\n n3.costume_id = int(score / 100) % 10\n n2.costume_id = int(score / 10) % 10\n n1.costume_id = int(score / 1) % 10\n if clock \u003c end_time:\n rate = 8\n else:\n rate = 4\n clock += 1\n \n \n if clock % rate == 0:\n b = create_sprite('bullet_0.png','bullet_1.png')\t \n b.direction = random.randrange(360)\n b.step_forward(750)\n b.direction = random.randrange(360)\n bullets.append(b)\n for b in bullets:\n if clock \u003c end_time:\n b.step_forward(2)\n b.costume_id = 1\n else:\n b.step_forward(4)\n b.costume_id = 0\n if ship.touched(b):\n life -= 1\n b.destroy()\n game.create_sound('boom.wv')\n if len(bullets) \u003e 100:\n bullets[0].destroy()\n del bullets[0]\n \n bars.costume_id = life\n if life \u003c= 0:\n gameover_text.hidden = False\n stop()\n if clock % 5 == 0:\n f = create_sprite('flame.png')\n f.direction = ship.direction\n f.move_to(ship)\n flames.append(f)\n for f in flames:\n f.scale -= 0.01\n f.opacity -= 0.01\n if len(flames) \u003e 20:\n flames[0].destroy()\n del flames[0]\nforever(loop) #重複不斷執行遊戲回圈\n\n","created_at":"2021-05-09T13:45:53.195+08:00","updated_at":"2021-05-09T16:46:09.385+08:00","name":"飛行訓練(預設版) 副本","language":"python","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/252056/7cdc5a270caf1c1c018c7bc08778a89d.jpg"},"parent_id":200984,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":36,"hashid":"meyswqvz8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4764405,"file_name":"flame.png","project_id":252056,"asset_id":276916,"created_at":"2021-05-09T13:45:53.201+08:00","updated_at":"2021-05-09T13:45:53.201+08:00"},{"id":4764406,"file_name":"d7.png","project_id":252056,"asset_id":276917,"created_at":"2021-05-09T13:45:53.202+08:00","updated_at":"2021-05-09T13:45:53.202+08:00"},{"id":4764407,"file_name":"d6.png","project_id":252056,"asset_id":276918,"created_at":"2021-05-09T13:45:53.203+08:00","updated_at":"2021-05-09T13:45:53.203+08:00"},{"id":4764408,"file_name":"d5.png","project_id":252056,"asset_id":276919,"created_at":"2021-05-09T13:45:53.204+08:00","updated_at":"2021-05-09T13:45:53.204+08:00"},{"id":4764409,"file_name":"d4.png","project_id":252056,"asset_id":276920,"created_at":"2021-05-09T13:45:53.204+08:00","updated_at":"2021-05-09T13:45:53.204+08:00"},{"id":4764410,"file_name":"d3.png","project_id":252056,"asset_id":276921,"created_at":"2021-05-09T13:45:53.205+08:00","updated_at":"2021-05-09T13:45:53.205+08:00"},{"id":4764411,"file_name":"d2.png","project_id":252056,"asset_id":276922,"created_at":"2021-05-09T13:45:53.206+08:00","updated_at":"2021-05-09T13:45:53.206+08:00"},{"id":4764412,"file_name":"d1.png","project_id":252056,"asset_id":276923,"created_at":"2021-05-09T13:45:53.207+08:00","updated_at":"2021-05-09T13:45:53.207+08:00"},{"id":4764413,"file_name":"d0.png","project_id":252056,"asset_id":276924,"created_at":"2021-05-09T13:45:53.208+08:00","updated_at":"2021-05-09T13:45:53.208+08:00"},{"id":4764414,"file_name":"effect.wav","project_id":252056,"asset_id":276925,"created_at":"2021-05-09T13:45:53.209+08:00","updated_at":"2021-05-09T13:45:53.209+08:00"},{"id":4764415,"file_name":"boom.wav","project_id":252056,"asset_id":276926,"created_at":"2021-05-09T13:45:53.210+08:00","updated_at":"2021-05-09T13:45:53.210+08:00"},{"id":4764416,"file_name":"bgm.mp3","project_id":252056,"asset_id":276927,"created_at":"2021-05-09T13:45:53.211+08:00","updated_at":"2021-05-09T13:45:53.211+08:00"},{"id":4764417,"file_name":"player.png","project_id":252056,"asset_id":276928,"created_at":"2021-05-09T13:45:53.212+08:00","updated_at":"2021-05-09T13:45:53.212+08:00"},{"id":4764418,"file_name":"gameover.png","project_id":252056,"asset_id":276929,"created_at":"2021-05-09T13:45:53.212+08:00","updated_at":"2021-05-09T13:45:53.212+08:00"},{"id":4764419,"file_name":"food_1.png","project_id":252056,"asset_id":276930,"created_at":"2021-05-09T13:45:53.213+08:00","updated_at":"2021-05-09T13:45:53.213+08:00"},{"id":4764420,"file_name":"food_2.png","project_id":252056,"asset_id":276931,"created_at":"2021-05-09T13:45:53.214+08:00","updated_at":"2021-05-09T13:45:53.214+08:00"},{"id":4764421,"file_name":"food_0.png","project_id":252056,"asset_id":276932,"created_at":"2021-05-09T13:45:53.215+08:00","updated_at":"2021-05-09T13:45:53.215+08:00"},{"id":4764422,"file_name":"bullet_1.png","project_id":252056,"asset_id":276933,"created_at":"2021-05-09T13:45:53.216+08:00","updated_at":"2021-05-09T13:45:53.216+08:00"},{"id":4764423,"file_name":"bullet_0.png","project_id":252056,"asset_id":276934,"created_at":"2021-05-09T13:45:53.217+08:00","updated_at":"2021-05-09T13:45:53.217+08:00"},{"id":4764424,"file_name":"bg.png","project_id":252056,"asset_id":276935,"created_at":"2021-05-09T13:45:53.218+08:00","updated_at":"2021-05-09T13:45:53.218+08:00"},{"id":4764425,"file_name":"9.png","project_id":252056,"asset_id":276936,"created_at":"2021-05-09T13:45:53.218+08:00","updated_at":"2021-05-09T13:45:53.218+08:00"},{"id":4764426,"file_name":"8.png","project_id":252056,"asset_id":276937,"created_at":"2021-05-09T13:45:53.219+08:00","updated_at":"2021-05-09T13:45:53.219+08:00"},{"id":4764427,"file_name":"7.png","project_id":252056,"asset_id":276938,"created_at":"2021-05-09T13:45:53.220+08:00","updated_at":"2021-05-09T13:45:53.220+08:00"},{"id":4764428,"file_name":"6.png","project_id":252056,"asset_id":276939,"created_at":"2021-05-09T13:45:53.221+08:00","updated_at":"2021-05-09T13:45:53.221+08:00"},{"id":4764429,"file_name":"5.png","project_id":252056,"asset_id":276940,"created_at":"2021-05-09T13:45:53.222+08:00","updated_at":"2021-05-09T13:45:53.222+08:00"},{"id":4764430,"file_name":"4.png","project_id":252056,"asset_id":276941,"created_at":"2021-05-09T13:45:53.223+08:00","updated_at":"2021-05-09T13:45:53.223+08:00"},{"id":4764431,"file_name":"3.png","project_id":252056,"asset_id":276942,"created_at":"2021-05-09T13:45:53.224+08:00","updated_at":"2021-05-09T13:45:53.224+08:00"},{"id":4764432,"file_name":"2.png","project_id":252056,"asset_id":276943,"created_at":"2021-05-09T13:45:53.224+08:00","updated_at":"2021-05-09T13:45:53.224+08:00"},{"id":4764433,"file_name":"1.png","project_id":252056,"asset_id":276944,"created_at":"2021-05-09T13:45:53.225+08:00","updated_at":"2021-05-09T13:45:53.225+08:00"},{"id":4764434,"file_name":"0.png","project_id":252056,"asset_id":276945,"created_at":"2021-05-09T13:45:53.226+08:00","updated_at":"2021-05-09T13:45:53.226+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦