{"id":182630,"student_id":10,"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','d77.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\nflames = [] #存放火焰角色\nbullets = [] #存放子彈角色\nscore = 0 #玩家分數\nclock = 0 #紀錄遊戲迴圈次數\nlife = 7 #遊戲生命\nend_time = 0 #緩慢模式的結束時間點\n\nfood.x = random.randrange(100, 1100)\nfood.y = random.randrange(100, 800)\n\ncreate_sound('bgm.mp3', True)\n\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 #緩速模式時子彈產生的速度變 1/4\n if clock \u003c end_time:\n rate = 8 #每執行 8 次迴圈創造一個子彈\n else:\n rate = 4 #每執行 4 次迴圈創造一個子彈\n\n clock += 1\n if clock % rate == 0:\n bullet = create_sprite('bullet_0.png','bullet_1.png')\n bullet.direction = random.randrange(360)\n bullet.step_forward(750)\n bullet.direction = random.randrange(360)\n bullets.append(bullet)\n \n for b in bullets:\n if b.touched(ship):\n b.destroy()\n life -= 1\n create_sound('boom.wav')\n \n if clock \u003c end_time:\n b.step_forward(2) #緩速模式時子彈速度變 1/4\n b.costume_id = 1\n else:\n b.step_forward(4)\n b.costume_id = 0\n \n if len(bullets) \u003e 100:\n del bullets[0]\n bullets[0].destroy()\n\n if ship.touched(food):\n food.x = random.randrange(100, 1100)\n food.y = random.randrange(100, 800)\n \n #生命條造型編號不能超過 7\n if food.costume_id == 1 and life \u003c 7:\n life += 1\n \n if food.costume_id == 2:\n end_time = clock + 500 # 500 個遊戲迴圈的時間內是緩速狀態\n\n if score % 10 == 4: #每 10 個食物,第 5 個是緩速\n food.costume_id = 2\n elif score % 10 == 9: #每 10 個食物,第 10 個是補血\n food.costume_id = 1\n else:\n food.costume_id = 0\n \n score += 1\n create_sound('effect.wav')\n\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\n bars.costume_id = life #生命值介於 0 - 7 之間\n \n if life \u003c= 0:\n stop()\n gameover_text.hidden = False\n\n if clock % 5 == 0:\n flame = create_sprite('flame.png')\n flame.direction = ship.direction + 90\n flame.move_to(ship)\n flames.append(flame)\n \n for flame in flames:\n flame.opacity -= 0.01\n flame.scale -= 0.01\n \n if len(flames) \u003e 20:\n del flames[0]\n flames[0].destroy()\n\nforever(loop) #重複不斷執行遊戲回圈\n\n","created_at":"2020-08-18T10:04:37.930+08:00","updated_at":"2020-11-02T20:05:52.478+08:00","name":"飛行訓練(完整版)","language":"python","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/182630/d628c809afa38073de3dfc7f41247dcd.jpg"},"parent_id":182494,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":227,"hashid":"rdvsqk4y","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3109254,"file_name":"d77.png","project_id":182630,"asset_id":204001,"created_at":"2020-08-18T10:04:37.936+08:00","updated_at":"2020-08-18T10:04:37.936+08:00"},{"id":3109255,"file_name":"d6.png","project_id":182630,"asset_id":204000,"created_at":"2020-08-18T10:04:37.937+08:00","updated_at":"2020-08-18T10:04:37.937+08:00"},{"id":3109256,"file_name":"d5.png","project_id":182630,"asset_id":203999,"created_at":"2020-08-18T10:04:37.938+08:00","updated_at":"2020-08-18T10:04:37.938+08:00"},{"id":3109257,"file_name":"d4.png","project_id":182630,"asset_id":203998,"created_at":"2020-08-18T10:04:37.939+08:00","updated_at":"2020-08-18T10:04:37.939+08:00"},{"id":3109258,"file_name":"d3.png","project_id":182630,"asset_id":203997,"created_at":"2020-08-18T10:04:37.940+08:00","updated_at":"2020-08-18T10:04:37.940+08:00"},{"id":3109259,"file_name":"d2.png","project_id":182630,"asset_id":203996,"created_at":"2020-08-18T10:04:37.941+08:00","updated_at":"2020-08-18T10:04:37.941+08:00"},{"id":3109260,"file_name":"d1.png","project_id":182630,"asset_id":203995,"created_at":"2020-08-18T10:04:37.942+08:00","updated_at":"2020-08-18T10:04:37.942+08:00"},{"id":3109261,"file_name":"d0.png","project_id":182630,"asset_id":237098,"created_at":"2020-08-18T10:04:37.943+08:00","updated_at":"2020-08-18T10:04:37.943+08:00"},{"id":3109262,"file_name":"effect.wav","project_id":182630,"asset_id":172347,"created_at":"2020-08-18T10:04:37.944+08:00","updated_at":"2020-08-18T10:04:37.944+08:00"},{"id":3109263,"file_name":"boom.wav","project_id":182630,"asset_id":250885,"created_at":"2020-08-18T10:04:37.945+08:00","updated_at":"2020-08-18T10:04:37.945+08:00"},{"id":3109264,"file_name":"bgm.mp3","project_id":182630,"asset_id":172346,"created_at":"2020-08-18T10:04:37.946+08:00","updated_at":"2020-08-18T10:04:37.946+08:00"},{"id":3109265,"file_name":"player.png","project_id":182630,"asset_id":204005,"created_at":"2020-08-18T10:04:37.947+08:00","updated_at":"2020-08-18T10:04:37.947+08:00"},{"id":3109266,"file_name":"gameover.png","project_id":182630,"asset_id":203994,"created_at":"2020-08-18T10:04:37.947+08:00","updated_at":"2020-08-18T10:04:37.947+08:00"},{"id":3109267,"file_name":"food_2.png","project_id":182630,"asset_id":204004,"created_at":"2020-08-18T10:04:37.948+08:00","updated_at":"2020-08-18T10:04:37.948+08:00"},{"id":3109268,"file_name":"food_1.png","project_id":182630,"asset_id":204003,"created_at":"2020-08-18T10:04:37.949+08:00","updated_at":"2020-08-18T10:04:37.949+08:00"},{"id":3109269,"file_name":"food_0.png","project_id":182630,"asset_id":250887,"created_at":"2020-08-18T10:04:37.950+08:00","updated_at":"2020-08-18T10:04:37.950+08:00"},{"id":3109270,"file_name":"flame.png","project_id":182630,"asset_id":250886,"created_at":"2020-08-18T10:04:37.951+08:00","updated_at":"2020-08-18T10:04:37.951+08:00"},{"id":3109271,"file_name":"bullet_1.png","project_id":182630,"asset_id":203993,"created_at":"2020-08-18T10:04:37.952+08:00","updated_at":"2020-08-18T10:04:37.952+08:00"},{"id":3109272,"file_name":"bullet_0.png","project_id":182630,"asset_id":203992,"created_at":"2020-08-18T10:04:37.953+08:00","updated_at":"2020-08-18T10:04:37.953+08:00"},{"id":3109273,"file_name":"bg.png","project_id":182630,"asset_id":203991,"created_at":"2020-08-18T10:04:37.953+08:00","updated_at":"2020-08-18T10:04:37.953+08:00"},{"id":3109274,"file_name":"9.png","project_id":182630,"asset_id":203990,"created_at":"2020-08-18T10:04:37.954+08:00","updated_at":"2020-08-18T10:04:37.954+08:00"},{"id":3109275,"file_name":"8.png","project_id":182630,"asset_id":203989,"created_at":"2020-08-18T10:04:37.955+08:00","updated_at":"2020-08-18T10:04:37.955+08:00"},{"id":3109276,"file_name":"7.png","project_id":182630,"asset_id":203988,"created_at":"2020-08-18T10:04:37.956+08:00","updated_at":"2020-08-18T10:04:37.956+08:00"},{"id":3109277,"file_name":"6.png","project_id":182630,"asset_id":203987,"created_at":"2020-08-18T10:04:37.957+08:00","updated_at":"2020-08-18T10:04:37.957+08:00"},{"id":3109278,"file_name":"5.png","project_id":182630,"asset_id":203986,"created_at":"2020-08-18T10:04:37.958+08:00","updated_at":"2020-08-18T10:04:37.958+08:00"},{"id":3109279,"file_name":"4.png","project_id":182630,"asset_id":203985,"created_at":"2020-08-18T10:04:37.958+08:00","updated_at":"2020-08-18T10:04:37.958+08:00"},{"id":3109280,"file_name":"3.png","project_id":182630,"asset_id":203984,"created_at":"2020-08-18T10:04:37.959+08:00","updated_at":"2020-08-18T10:04:37.959+08:00"},{"id":3109281,"file_name":"2.png","project_id":182630,"asset_id":203983,"created_at":"2020-08-18T10:04:37.960+08:00","updated_at":"2020-08-18T10:04:37.960+08:00"},{"id":3109282,"file_name":"1.png","project_id":182630,"asset_id":203982,"created_at":"2020-08-18T10:04:37.961+08:00","updated_at":"2020-08-18T10:04:37.961+08:00"},{"id":3109283,"file_name":"0.png","project_id":182630,"asset_id":203981,"created_at":"2020-08-18T10:04:37.962+08:00","updated_at":"2020-08-18T10:04:37.962+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦