{"id":177609,"student_id":10,"content":"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') #設定背景圖\nlevels = create_sprite('0.png','1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png') #關卡地形\nbar = create_sprite('bar.png') #生命條\ndashboard = create_sprite('dashboard.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\ntarget.move_to(1000, 700)\n\nvy = 0 #垂直速度\nvx = 0 #水平速度\ngoal_x = [1000, 1000, 200, 200, 1000, 1000, 1000, 600, 1100, -100] #用來存放每個關卡目標物的 x 座標\ngoal_y = [700, 200, 700, 200, 200, 800, 200, 450, 700, -100] #用來存放每個關卡目標物的 y 座標\nfuel = 1000 #燃料值\n\n\n#遊戲主迴圈\ndef loop ():\n global vx, vy, is_start, fuel\n \n if info.hidden: vy += 0.07\n player.y += vy\n player.x += vx\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 vx = vx * 0.99\n \n #如果太空人碰到目標物就切換下個關卡\n if player.touched(target):\n levels.costume_id += 1\n bar.move_to(250, 46)\n fuel = 1000\n \n #根據關卡造型設定目標物的位置\n target.x = goal_x[levels.costume_id]\n target.y = goal_y[levels.costume_id]\n \n #遊戲獲勝\n if levels.costume_id == 9:\n info.hidden = False\n info.costume_id = 1\n stop()\n \n #上、右、左按鍵按下時消耗燃料\n if key.up or key.right or key.left:\n bar.x -= 0.5\n fuel -= 1\n info.hidden = True\n \n #遊戲失敗\n if player.touched(levels):\n info.hidden = False\n info.costume_id = 2\n stop()\n \n draw_text(fuel, 50, 30, 'black', 30)\n\n#創造火焰球\ndef create_flame ():\n pass\n\n\nforever(loop) #重複不斷執行遊戲回圈\n\n\n\n\n","created_at":"2020-08-06T11:49:57.191+08:00","updated_at":"2021-03-31T16:03:04.455+08:00","name":"太空人(錄影版)","language":"python","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/177609/69b5d8201d84a6848191e4b28075cda2.jpg"},"parent_id":169081,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":254,"hashid":"zpes9zv6","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3033357,"file_name":"coin.wav","project_id":177609,"asset_id":246652,"created_at":"2020-08-06T11:49:57.197+08:00","updated_at":"2020-08-06T11:49:57.197+08:00"},{"id":3033358,"file_name":"effect.wav","project_id":177609,"asset_id":172348,"created_at":"2020-08-06T11:49:57.199+08:00","updated_at":"2020-08-06T11:49:57.199+08:00"},{"id":3033359,"file_name":"bgm.mp3","project_id":177609,"asset_id":246649,"created_at":"2020-08-06T11:49:57.201+08:00","updated_at":"2020-08-06T11:49:57.201+08:00"},{"id":3033360,"file_name":"9.png","project_id":177609,"asset_id":246648,"created_at":"2020-08-06T11:49:57.202+08:00","updated_at":"2020-08-06T11:49:57.202+08:00"},{"id":3033361,"file_name":"8.png","project_id":177609,"asset_id":246647,"created_at":"2020-08-06T11:49:57.203+08:00","updated_at":"2020-08-06T11:49:57.203+08:00"},{"id":3033362,"file_name":"7.png","project_id":177609,"asset_id":246646,"created_at":"2020-08-06T11:49:57.204+08:00","updated_at":"2020-08-06T11:49:57.204+08:00"},{"id":3033363,"file_name":"6.png","project_id":177609,"asset_id":246645,"created_at":"2020-08-06T11:49:57.205+08:00","updated_at":"2020-08-06T11:49:57.205+08:00"},{"id":3033364,"file_name":"5.png","project_id":177609,"asset_id":246644,"created_at":"2020-08-06T11:49:57.206+08:00","updated_at":"2020-08-06T11:49:57.206+08:00"},{"id":3033365,"file_name":"4.png","project_id":177609,"asset_id":246643,"created_at":"2020-08-06T11:49:57.207+08:00","updated_at":"2020-08-06T11:49:57.207+08:00"},{"id":3033366,"file_name":"3.png","project_id":177609,"asset_id":246642,"created_at":"2020-08-06T11:49:57.208+08:00","updated_at":"2020-08-06T11:49:57.208+08:00"},{"id":3033367,"file_name":"2.png","project_id":177609,"asset_id":246641,"created_at":"2020-08-06T11:49:57.209+08:00","updated_at":"2020-08-06T11:49:57.209+08:00"},{"id":3033368,"file_name":"1.png","project_id":177609,"asset_id":246640,"created_at":"2020-08-06T11:49:57.210+08:00","updated_at":"2020-08-06T11:49:57.210+08:00"},{"id":3033369,"file_name":"0.png","project_id":177609,"asset_id":246639,"created_at":"2020-08-06T11:49:57.211+08:00","updated_at":"2020-08-06T11:49:57.211+08:00"},{"id":3033370,"file_name":"arrow.png","project_id":177609,"asset_id":240720,"created_at":"2020-08-06T11:49:57.211+08:00","updated_at":"2020-08-06T11:49:57.211+08:00"},{"id":3033371,"file_name":"bar.png","project_id":177609,"asset_id":240719,"created_at":"2020-08-06T11:49:57.212+08:00","updated_at":"2020-08-06T11:49:57.212+08:00"},{"id":3033372,"file_name":"bg.jpg","project_id":177609,"asset_id":240718,"created_at":"2020-08-06T11:49:57.213+08:00","updated_at":"2020-08-06T11:49:57.213+08:00"},{"id":3033373,"file_name":"dashboard.png","project_id":177609,"asset_id":240717,"created_at":"2020-08-06T11:49:57.214+08:00","updated_at":"2020-08-06T11:49:57.214+08:00"},{"id":3033374,"file_name":"flame.png","project_id":177609,"asset_id":240716,"created_at":"2020-08-06T11:49:57.215+08:00","updated_at":"2020-08-06T11:49:57.215+08:00"},{"id":3033375,"file_name":"gameover.png","project_id":177609,"asset_id":240715,"created_at":"2020-08-06T11:49:57.216+08:00","updated_at":"2020-08-06T11:49:57.216+08:00"},{"id":3033376,"file_name":"player.png","project_id":177609,"asset_id":240714,"created_at":"2020-08-06T11:49:57.217+08:00","updated_at":"2020-08-06T11:49:57.217+08:00"},{"id":3033377,"file_name":"target.png","project_id":177609,"asset_id":240713,"created_at":"2020-08-06T11:49:57.218+08:00","updated_at":"2020-08-06T11:49:57.218+08:00"},{"id":3033379,"file_name":"youwin.png","project_id":177609,"asset_id":240711,"created_at":"2020-08-06T11:49:57.220+08:00","updated_at":"2020-08-06T11:49:57.220+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦