{"id":277438,"student_id":1981,"content":"import game\nimport random\n\ngame.set_backdrop('bg.jpg')\nswing = game.create_sprite('swing_0.png', 'swing_1.png') #盪鞦韆與叩叮\napple = game.create_sprite('apple.png') #蘋果\narcher = game.create_sprite('archer.png') #弓箭手\nbow = game.create_sprite('bow.png') #弓\narrow = game.create_sprite('arrow_0.png', 'arrow_1.png') #箭\nlife = game.create_sprite(\"0.png\",\"1.png\",\"2.png\",\"3.png\",\"4.png\",\"5.png\",) #創造角色\n\nlife.x = 200\nlife.y = 75\nlife.costume_id = 5\n\nswing.x = 900\napple.x = 900\nswing.y = 400\napple.y = 400\n\nactive = False #紀錄是否拉過弓\nscore = 0 #玩家得分\nvy = 0 #目標移動速度\n\narcher.x=300\narcher.y=600\n\nbow.x=300\nbow.y=600\nbow.direction=135\n\narrow.x=300\narrow.y=600\narrow.direction=135\n\n\n#遊戲主迴圈\ndef loop ():\n global active, score, vy #存取變數\n \n if game.cursor.is_down == True and bow.direction \u003e 30 and arrow.x == 300: #當按滑鼠,且腳色的角度大於30度,且箭在原本的地方,才可以旋轉\n bow.direction = bow.direction - 2 #弓逆時鐘旋轉\n arrow.direction = arrow.direction - 2 #箭逆時鐘旋轉\n active = True #紀錄是否拉過弓\n \n if game.cursor.is_down == False and active == True: #當滑鼠放開,且已經拉過弓\n arrow.step_forward(25) #箭射出去。速度:25\n arrow.direction = arrow.direction + 1 #順時針方向\n \n if arrow.touched(apple): #如果箭碰到蘋果\n apple.hidden = True #蘋果隱藏\n arrow.costume_id = 1 #箭的圖片更換\n score = score+1 #分數+1\n \n \n if arrow.x \u003e 1200 or arrow.y \u003e900: #如果箭超過畫面\n arrow.x=300 #箭回到原本位子\n arrow.y=600\n active = False #記錄成沒拉過弓\n bow.direction=135\n arrow.direction=135\n apple.hidden = False\n \n if arrow.costume_id == 1: #如果有射到\n rand = random.randrange(100,700)\n swing.y = rand #鞦韆上下移動\n apple.y = rand #蘋果上下移動\n if score\u003e=10: vy = random.randrange(-5,6) #如果分數超過10,隨機上下移動\n else: #否則\n life.costume_id -= 1\n arrow.costume_id = 0\n \n if life.costume_id == 0: #如果沒有箭了\n game.create_sprite(\"gameover.png\") #創造gameover圖片\n game.stop() #遊戲暫停\n\n \n game.draw_text(score, 1080, 50, \"white\", 60)\n \n if arrow.touched(swing) == True: #如果箭碰到叮叮\n swing.costume_id = 1 #切換圖片\n \n else:\n swing.costume_id = 0\n \n if apple.y \u003c 200 or apple.y \u003e 700 : vy=-vy #不斷上下移動\n apple.y = apple.y + vy\n swing.y = swing.y + vy\n\ngame.forever(loop) #重複不斷執行\n","created_at":"2021-07-20T20:19:49.261+08:00","updated_at":"2021-08-21T10:45:40.181+08:00","name":"射箭遊戲(預設版) 副本","language":"python","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/277438/5e2713616acaac3c955c6fb741a914b3.jpg"},"parent_id":194470,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":37,"hashid":"yeysv2eqr","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":5418371,"file_name":"arrow_0.png","project_id":277438,"asset_id":267850,"created_at":"2021-07-20T20:19:49.279+08:00","updated_at":"2021-07-20T20:19:49.279+08:00"},{"id":5418372,"file_name":"bow.png","project_id":277438,"asset_id":267851,"created_at":"2021-07-20T20:19:49.280+08:00","updated_at":"2021-07-20T20:19:49.280+08:00"},{"id":5418373,"file_name":"apple.png","project_id":277438,"asset_id":267852,"created_at":"2021-07-20T20:19:49.281+08:00","updated_at":"2021-07-20T20:19:49.281+08:00"},{"id":5418359,"file_name":"gameover.png","project_id":277438,"asset_id":267838,"created_at":"2021-07-20T20:19:49.267+08:00","updated_at":"2021-07-20T20:19:49.267+08:00"},{"id":5418360,"file_name":"bg.jpg","project_id":277438,"asset_id":267839,"created_at":"2021-07-20T20:19:49.268+08:00","updated_at":"2021-07-20T20:19:49.268+08:00"},{"id":5418361,"file_name":"swing_1.png","project_id":277438,"asset_id":267840,"created_at":"2021-07-20T20:19:49.269+08:00","updated_at":"2021-07-20T20:19:49.269+08:00"},{"id":5418362,"file_name":"swing_0.png","project_id":277438,"asset_id":267841,"created_at":"2021-07-20T20:19:49.270+08:00","updated_at":"2021-07-20T20:19:49.270+08:00"},{"id":5418363,"file_name":"0.png","project_id":277438,"asset_id":267842,"created_at":"2021-07-20T20:19:49.271+08:00","updated_at":"2021-07-20T20:19:49.271+08:00"},{"id":5418364,"file_name":"1.png","project_id":277438,"asset_id":267843,"created_at":"2021-07-20T20:19:49.272+08:00","updated_at":"2021-07-20T20:19:49.272+08:00"},{"id":5418365,"file_name":"2.png","project_id":277438,"asset_id":267844,"created_at":"2021-07-20T20:19:49.273+08:00","updated_at":"2021-07-20T20:19:49.273+08:00"},{"id":5418366,"file_name":"3.png","project_id":277438,"asset_id":267845,"created_at":"2021-07-20T20:19:49.274+08:00","updated_at":"2021-07-20T20:19:49.274+08:00"},{"id":5418367,"file_name":"4.png","project_id":277438,"asset_id":267846,"created_at":"2021-07-20T20:19:49.275+08:00","updated_at":"2021-07-20T20:19:49.275+08:00"},{"id":5418368,"file_name":"5.png","project_id":277438,"asset_id":267847,"created_at":"2021-07-20T20:19:49.276+08:00","updated_at":"2021-07-20T20:19:49.276+08:00"},{"id":5418369,"file_name":"arrow_1.png","project_id":277438,"asset_id":267848,"created_at":"2021-07-20T20:19:49.277+08:00","updated_at":"2021-07-20T20:19:49.277+08:00"},{"id":5418370,"file_name":"archer.png","project_id":277438,"asset_id":267849,"created_at":"2021-07-20T20:19:49.278+08:00","updated_at":"2021-07-20T20:19:49.278+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦