{"id":196933,"student_id":2589,"content":"","created_at":"2020-10-19T17:04:14.304+08:00","updated_at":"2023-03-14T14:41:28.296+08:00","name":"太空人 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/196933/e445e99abf63f1b112ca4c2ec3458c7c.jpg"},"parent_id":4,"plugin":"import random #載入隨機數模組\nfrom game import (\n set_backdrop, #設定背景圖\n create_sprite, #創造角色\n create_sound, #創造音效\n draw_text, #繪製文字\n key, #鍵盤狀態\n forever, #重複不斷執行\n stop, #遊戲結束\n)\n\nset_backdrop('bg.jpg') #設定背景圖\nbar = create_sprite('bar.png') #生命條\ndashboard = create_sprite('dashboard.png') #生命條框\nlevels = create_sprite('0.png','1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png') #關卡地形\nplayer = create_sprite('player.png') #玩家\ntarget = create_sprite('target.png') #目標\ninfo = create_sprite('arrow.png', 'youwin.png', 'gameover.png') #文字圖\n\nbar.move_to(250, 46) #初始化位置\nplayer.layer = 1 #設定玩家圖層到最上層\n\nvx = 0 #水平的移動速度\nvy = 0 #垂直的移動速度\nis_start = False #是否開始\nfuel = 1000 #燃料\n\ngoal_x = [1000, 1000, 200, 200, 1000, 1000, 1000, 600, 1100]\ngoal_y = [700, 200, 700, 200, 200, 800, 200, 450, 700]\n\ncreate_sound('bgm.mp3', True)\n\n#遊戲主迴圈\ndef loop ():\n global vx, vy, is_start, fuel\n \n if is_start:\n vy += 0.07\n player.move(vx, vy)\n player.direction = 90 + vx*2\n info.hidden = True\n \n if key.up and fuel \u003e 0:\n vy -= 0.15\n \n if key.right and fuel \u003e 0:\n vx += 0.1\n \n if key.left and fuel \u003e 0:\n vx -= 0.1\n \n #按下方向按鍵時消耗燃料\n if key.right or key.left or key.up:\n fuel -= 1\n bar.x -= 0.5\n if fuel % 3 == 0 and fuel \u003e 0: create_flame()\n is_start = True\n\n target.x = goal_x[levels.costume_id]\n target.y = goal_y[levels.costume_id]\n target.direction += 1\n \n #碰到目標物\n if player.touched(target):\n levels.costume_id += 1\n fuel = 1000\n bar.move_to(250, 46)\n create_sound('coin.wav')\n \n #遊戲勝利\n if levels.costume_id == 9:\n stop()\n info.hidden = False\n info.costume_id = 1\n \n #遊戲失敗\n if player.touched(levels):\n stop()\n info.hidden = False\n info.costume_id = 2\n\n#創造火焰球\ndef create_flame ():\n f = create_sprite('flame.png')\n f.move_to(player)\n f.direction = player.direction + 90 + random.randrange(-15, 15)\n f.stepForward(50)\n \n def fireloop ():\n f.stepForward(5)\n f.opacity -= 0.01\n f.scale -= 0.01\n if f.opacity \u003c 0: f.destroy()\n \n f.forever(fireloop)\n\nforever(loop) #重複不斷執行遊戲回圈\n","description":null,"note":null,"status":"public","like_student_ids":[13135,13032,23000,22718,11000,11190,12460,9874,27952,33599,2293,15565,13068,27631,18427,13078,4730,35397,20767,12466,24217,22391,22240,22072,30994,6736,36137,17411,30022,23460,12833,16968,29481,10801,17119,28328,26650,28540,32648,34617,31794,27694,26704,35074,23648,47233,8046,6189,27966,12023,47495,38763,42359,16514,43026,39398,33563,37164,39194,24155,41370,52238,40578,28143,28503,42999,42222,47168,35917,42279,43742,46547,42057,41701,40009,62418,33044,45534],"is_featured":false,"views":5611,"hashid":"jzmseyrp8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3378003,"file_name":"coin.wav","project_id":196933,"asset_id":270898,"created_at":"2020-10-19T17:04:28.119+08:00","updated_at":"2020-10-19T17:04:28.119+08:00"},{"id":3378004,"file_name":"effect.wav","project_id":196933,"asset_id":270899,"created_at":"2020-10-19T17:04:28.133+08:00","updated_at":"2020-10-19T17:04:28.133+08:00"},{"id":3378005,"file_name":"bgm.mp3","project_id":196933,"asset_id":270900,"created_at":"2020-10-19T17:04:28.161+08:00","updated_at":"2020-10-19T17:04:28.161+08:00"},{"id":3378006,"file_name":"9.png","project_id":196933,"asset_id":270901,"created_at":"2020-10-19T17:04:28.166+08:00","updated_at":"2020-10-19T17:04:28.166+08:00"},{"id":3378007,"file_name":"8.png","project_id":196933,"asset_id":270902,"created_at":"2020-10-19T17:04:28.171+08:00","updated_at":"2020-10-19T17:04:28.171+08:00"},{"id":3378008,"file_name":"7.png","project_id":196933,"asset_id":270903,"created_at":"2020-10-19T17:04:28.175+08:00","updated_at":"2020-10-19T17:04:28.175+08:00"},{"id":3378009,"file_name":"6.png","project_id":196933,"asset_id":270904,"created_at":"2020-10-19T17:04:28.180+08:00","updated_at":"2020-10-19T17:04:28.180+08:00"},{"id":3378010,"file_name":"5.png","project_id":196933,"asset_id":270905,"created_at":"2020-10-19T17:04:28.185+08:00","updated_at":"2020-10-19T17:04:28.185+08:00"},{"id":3378011,"file_name":"4.png","project_id":196933,"asset_id":270906,"created_at":"2020-10-19T17:04:28.190+08:00","updated_at":"2020-10-19T17:04:28.190+08:00"},{"id":3378012,"file_name":"3.png","project_id":196933,"asset_id":270907,"created_at":"2020-10-19T17:04:28.195+08:00","updated_at":"2020-10-19T17:04:28.195+08:00"},{"id":3378013,"file_name":"2.png","project_id":196933,"asset_id":270908,"created_at":"2020-10-19T17:04:28.238+08:00","updated_at":"2020-10-19T17:04:28.238+08:00"},{"id":3378014,"file_name":"1.png","project_id":196933,"asset_id":270909,"created_at":"2020-10-19T17:04:28.243+08:00","updated_at":"2020-10-19T17:04:28.243+08:00"},{"id":3378015,"file_name":"0.png","project_id":196933,"asset_id":270910,"created_at":"2020-10-19T17:04:28.259+08:00","updated_at":"2020-10-19T17:04:28.259+08:00"},{"id":3378016,"file_name":"arrow.png","project_id":196933,"asset_id":270911,"created_at":"2020-10-19T17:04:28.266+08:00","updated_at":"2020-10-19T17:04:28.266+08:00"},{"id":3378017,"file_name":"bar.png","project_id":196933,"asset_id":270912,"created_at":"2020-10-19T17:04:28.275+08:00","updated_at":"2020-10-19T17:04:28.275+08:00"},{"id":3378018,"file_name":"bg.jpg","project_id":196933,"asset_id":270913,"created_at":"2020-10-19T17:04:28.294+08:00","updated_at":"2020-10-19T17:04:28.294+08:00"},{"id":3378019,"file_name":"dashboard.png","project_id":196933,"asset_id":270914,"created_at":"2020-10-19T17:04:28.299+08:00","updated_at":"2020-10-19T17:04:28.299+08:00"},{"id":3378020,"file_name":"flame.png","project_id":196933,"asset_id":270915,"created_at":"2020-10-19T17:04:28.304+08:00","updated_at":"2020-10-19T17:04:28.304+08:00"},{"id":3378021,"file_name":"gameover.png","project_id":196933,"asset_id":270916,"created_at":"2020-10-19T17:04:28.309+08:00","updated_at":"2020-10-19T17:04:28.309+08:00"},{"id":3378022,"file_name":"player.png","project_id":196933,"asset_id":270917,"created_at":"2020-10-19T17:04:28.319+08:00","updated_at":"2020-10-19T17:04:28.319+08:00"},{"id":3378023,"file_name":"target.png","project_id":196933,"asset_id":270918,"created_at":"2020-10-19T17:04:28.325+08:00","updated_at":"2020-10-19T17:04:28.325+08:00"},{"id":3378024,"file_name":"wall.png","project_id":196933,"asset_id":270919,"created_at":"2020-10-19T17:04:28.331+08:00","updated_at":"2020-10-19T17:04:28.331+08:00"},{"id":3378025,"file_name":"youwin.png","project_id":196933,"asset_id":270920,"created_at":"2020-10-19T17:04:28.342+08:00","updated_at":"2020-10-19T17:04:28.342+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦