{"id":180631,"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\n\nvy = 0 #垂直速度\nvx = 0 #水平速度\nfuel = 1000 #燃料值\ngoal_x = [1000, 1000, 200, 200, 1000, 1000, 1000, 600, 1100] #用來存放目標物X座標\ngoal_y = [700, 200, 700, 200, 200, 800, 200, 450, 700] #用來存放目標物Y座標\n\n\n#遊戲主迴圈\ndef loop ():\n global vx, vy, is_start, fuel\n \n if info.hidden == True:\n 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 #碰到目標切換關卡\n if player.touched(target):\n levels.costume_id += 1\n bar.x = 250\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 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 #方向按鍵按下時消耗燃料\n if key.up or key.right or key.left:\n bar.x -= 0.5\n fuel -= 1\n info.hidden = True\n \n if fuel % 3 == 0 and fuel \u003e 0: create_flame()\n \n \n # draw_text(fuel, 50, 30, 'red', 30)\n \n #遊戲動畫特效\n target.direction += 1\n player.direction = 90 + vx * 2\n\n\n#創造火焰球\ndef create_flame ():\n f = create_sprite('flame.png')\n f.x = player.x\n f.y = player.y + 50\n f.direction = player.direction + 90 + random.randrange(-15, 15)\n \n def fireloop ():\n f.stepForward(5)\n f.opacity -= 0.01\n f.scale -= 0.01\n \n if f.opacity \u003c 0: f.destroy()\n \n f.forever(fireloop) #重複不斷執行\n\n\nforever(loop) #重複不斷執行遊戲回圈\n\n\n\n\n","created_at":"2020-08-14T16:24:27.651+08:00","updated_at":"2021-03-31T16:04:18.325+08:00","name":"太空人(完整版)","language":"python","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/180631/160a65b2d7bc6c26c079973c2ca243f3.jpg"},"parent_id":177609,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":320,"hashid":"rdvsq8r8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3077725,"file_name":"youwin.png","project_id":180631,"asset_id":240711,"created_at":"2020-08-14T16:24:27.657+08:00","updated_at":"2020-08-14T16:24:27.657+08:00"},{"id":3077726,"file_name":"target.png","project_id":180631,"asset_id":240713,"created_at":"2020-08-14T16:24:27.659+08:00","updated_at":"2020-08-14T16:24:27.659+08:00"},{"id":3077727,"file_name":"player.png","project_id":180631,"asset_id":240714,"created_at":"2020-08-14T16:24:27.660+08:00","updated_at":"2020-08-14T16:24:27.660+08:00"},{"id":3077728,"file_name":"gameover.png","project_id":180631,"asset_id":240715,"created_at":"2020-08-14T16:24:27.661+08:00","updated_at":"2020-08-14T16:24:27.661+08:00"},{"id":3077729,"file_name":"flame.png","project_id":180631,"asset_id":240716,"created_at":"2020-08-14T16:24:27.662+08:00","updated_at":"2020-08-14T16:24:27.662+08:00"},{"id":3077730,"file_name":"dashboard.png","project_id":180631,"asset_id":240717,"created_at":"2020-08-14T16:24:27.663+08:00","updated_at":"2020-08-14T16:24:27.663+08:00"},{"id":3077731,"file_name":"bg.jpg","project_id":180631,"asset_id":240718,"created_at":"2020-08-14T16:24:27.664+08:00","updated_at":"2020-08-14T16:24:27.664+08:00"},{"id":3077732,"file_name":"bar.png","project_id":180631,"asset_id":240719,"created_at":"2020-08-14T16:24:27.665+08:00","updated_at":"2020-08-14T16:24:27.665+08:00"},{"id":3077733,"file_name":"arrow.png","project_id":180631,"asset_id":240720,"created_at":"2020-08-14T16:24:27.666+08:00","updated_at":"2020-08-14T16:24:27.666+08:00"},{"id":3077734,"file_name":"0.png","project_id":180631,"asset_id":246639,"created_at":"2020-08-14T16:24:27.667+08:00","updated_at":"2020-08-14T16:24:27.667+08:00"},{"id":3077735,"file_name":"1.png","project_id":180631,"asset_id":246640,"created_at":"2020-08-14T16:24:27.668+08:00","updated_at":"2020-08-14T16:24:27.668+08:00"},{"id":3077736,"file_name":"2.png","project_id":180631,"asset_id":246641,"created_at":"2020-08-14T16:24:27.669+08:00","updated_at":"2020-08-14T16:24:27.669+08:00"},{"id":3077737,"file_name":"3.png","project_id":180631,"asset_id":246642,"created_at":"2020-08-14T16:24:27.670+08:00","updated_at":"2020-08-14T16:24:27.670+08:00"},{"id":3077738,"file_name":"4.png","project_id":180631,"asset_id":246643,"created_at":"2020-08-14T16:24:27.671+08:00","updated_at":"2020-08-14T16:24:27.671+08:00"},{"id":3077739,"file_name":"5.png","project_id":180631,"asset_id":246644,"created_at":"2020-08-14T16:24:27.672+08:00","updated_at":"2020-08-14T16:24:27.672+08:00"},{"id":3077740,"file_name":"6.png","project_id":180631,"asset_id":246645,"created_at":"2020-08-14T16:24:27.673+08:00","updated_at":"2020-08-14T16:24:27.673+08:00"},{"id":3077741,"file_name":"7.png","project_id":180631,"asset_id":246646,"created_at":"2020-08-14T16:24:27.674+08:00","updated_at":"2020-08-14T16:24:27.674+08:00"},{"id":3077742,"file_name":"8.png","project_id":180631,"asset_id":246647,"created_at":"2020-08-14T16:24:27.675+08:00","updated_at":"2020-08-14T16:24:27.675+08:00"},{"id":3077743,"file_name":"9.png","project_id":180631,"asset_id":246648,"created_at":"2020-08-14T16:24:27.676+08:00","updated_at":"2020-08-14T16:24:27.676+08:00"},{"id":3077744,"file_name":"bgm.mp3","project_id":180631,"asset_id":246649,"created_at":"2020-08-14T16:24:27.677+08:00","updated_at":"2020-08-14T16:24:27.677+08:00"},{"id":3077745,"file_name":"effect.wav","project_id":180631,"asset_id":172348,"created_at":"2020-08-14T16:24:27.678+08:00","updated_at":"2020-08-14T16:24:27.678+08:00"},{"id":3077746,"file_name":"coin.wav","project_id":180631,"asset_id":246652,"created_at":"2020-08-14T16:24:27.679+08:00","updated_at":"2020-08-14T16:24:27.679+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦