{"id":190006,"student_id":10,"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\nswing.x = 900\napple.x = 900\nswing.y = 400\napple.y = 400\n\narcher.x = 300\nbow.x = 300\narrow.x = 300\n\narcher.y = 600\nbow.y = 600\narrow.y = 600\n\nbow.direction = 135\narrow.direction = 135\n\nlife.costume_id = 5\nlife.x = 200\nlife.y = 75\n\nactive = False #紀錄是否拉過弓\nscore = 0 #玩家得分\nvy = 0 #目標移動速度\n\n#遊戲主迴圈\ndef loop ():\n global active, score, vy\n \n #按住滑鼠拉動弓箭\n if cursor.is_down == True and arrow.direction \u003e 30 and arrow.x == 300:\n arrow.direction -= 2 #箭逆時間旋轉\n bow.direction -= 2 #弓逆時間旋轉\n active = True\n \n #放開滑鼠且已經拉過弓箭\n if cursor.is_down == False and active == True:\n arrow.step_forward(25) #箭向前移動\n arrow.direction += 1 #箭順時間旋轉\n\n # #如果箭碰到蘋果\n if arrow.touched(apple):\n arrow.costume_id = 1 #切換到插著蘋果的造型\n apple.hidden = True #隱藏蘋果\n score += 1\n \n # #如果超出場景下方或右邊邊界\n if arrow.y \u003e 900 or arrow.x \u003e 1300:\n arrow.move_to(300, 600)\n active = False\n arrow.direction = 135\n bow.direction = 135\n apple.hidden = False\n \n #必須寫在箭重置造型前面\n if arrow.costume_id == 1:\n rand = random.randrange(200, 700)\n swing.y = rand\n apple.y = rand\n if score \u003e= 10: vy = random.randrange(-5, 5)\n else:\n life.costume_id -= 1\n\n arrow.costume_id = 0 #切換成沒有蘋果的造型\n\n if life.costume_id == 0:\n game.create_sprite(\"gameover.png\") #結束的文字\n game.stop()\n \n game.draw_text(score, 1080, 50, 'white', 60)\n \n #目標物的移動\n if swing.y \u003c 200 or swing.y \u003e 700: vy = -vy\n swing.y -= vy\n apple.y -= vy\n \n if arrow.touched(swing):\n swing.costume_id = 1\n else:\n swing.costume_id = 0\n\ngame.forever(loop) #重複不斷執行\n","created_at":"2020-09-08T18:42:44.424+08:00","updated_at":"2020-09-26T10:45:24.661+08:00","name":"射箭遊戲(預設版)","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/190006/d4093b8f0cb2b9540a10969c042642c4.jpg"},"parent_id":189995,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":225,"hashid":"gk4s6ydz","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3317057,"file_name":"apple.png","project_id":190006,"asset_id":266297,"created_at":"2020-09-24T11:02:04.657+08:00","updated_at":"2020-09-24T11:02:04.657+08:00"},{"id":3317058,"file_name":"bow.png","project_id":190006,"asset_id":266298,"created_at":"2020-09-24T11:02:04.659+08:00","updated_at":"2020-09-24T11:02:04.659+08:00"},{"id":3317059,"file_name":"arrow_0.png","project_id":190006,"asset_id":266299,"created_at":"2020-09-24T11:02:04.879+08:00","updated_at":"2020-09-24T11:02:04.879+08:00"},{"id":3317060,"file_name":"archer.png","project_id":190006,"asset_id":266300,"created_at":"2020-09-24T11:02:04.880+08:00","updated_at":"2020-09-24T11:02:04.880+08:00"},{"id":3317061,"file_name":"arrow_1.png","project_id":190006,"asset_id":266301,"created_at":"2020-09-24T11:02:05.074+08:00","updated_at":"2020-09-24T11:02:05.074+08:00"},{"id":3317062,"file_name":"5.png","project_id":190006,"asset_id":266302,"created_at":"2020-09-24T11:02:05.075+08:00","updated_at":"2020-09-24T11:02:05.075+08:00"},{"id":3317063,"file_name":"4.png","project_id":190006,"asset_id":266303,"created_at":"2020-09-24T11:02:05.268+08:00","updated_at":"2020-09-24T11:02:05.268+08:00"},{"id":3317064,"file_name":"3.png","project_id":190006,"asset_id":266304,"created_at":"2020-09-24T11:02:05.270+08:00","updated_at":"2020-09-24T11:02:05.270+08:00"},{"id":3317065,"file_name":"2.png","project_id":190006,"asset_id":266305,"created_at":"2020-09-24T11:02:05.463+08:00","updated_at":"2020-09-24T11:02:05.463+08:00"},{"id":3317066,"file_name":"1.png","project_id":190006,"asset_id":266306,"created_at":"2020-09-24T11:02:05.464+08:00","updated_at":"2020-09-24T11:02:05.464+08:00"},{"id":3317067,"file_name":"0.png","project_id":190006,"asset_id":266307,"created_at":"2020-09-24T11:02:05.649+08:00","updated_at":"2020-09-24T11:02:05.649+08:00"},{"id":3317106,"file_name":"swing_0.png","project_id":190006,"asset_id":266310,"created_at":"2020-09-24T14:55:24.348+08:00","updated_at":"2020-09-24T14:55:24.348+08:00"},{"id":3317107,"file_name":"swing_1.png","project_id":190006,"asset_id":266311,"created_at":"2020-09-24T14:55:24.350+08:00","updated_at":"2020-09-24T14:55:24.350+08:00"},{"id":3317151,"file_name":"bg.jpg","project_id":190006,"asset_id":266313,"created_at":"2020-09-24T17:11:06.873+08:00","updated_at":"2020-09-24T17:11:06.873+08:00"},{"id":3317160,"file_name":"gameover.png","project_id":190006,"asset_id":266314,"created_at":"2020-09-24T17:49:36.548+08:00","updated_at":"2020-09-24T17:49:36.548+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦