{"id":194473,"student_id":2589,"content":"","created_at":"2020-10-06T18:22:29.570+08:00","updated_at":"2023-03-14T14:37:06.229+08:00","name":"射蘋果高手 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/194473/89edcce60b8890776f43b51e69f48ea4.jpg"},"parent_id":4,"plugin":"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\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 arrow.direction = 135\n bow.direction = 135\n active = False\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","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":146,"hashid":"p93sjjj5","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3330135,"file_name":"gameover.png","project_id":194473,"asset_id":267885,"created_at":"2020-10-06T18:22:43.464+08:00","updated_at":"2020-10-06T18:22:43.464+08:00"},{"id":3330136,"file_name":"bg.jpg","project_id":194473,"asset_id":267886,"created_at":"2020-10-06T18:22:43.472+08:00","updated_at":"2020-10-06T18:22:43.472+08:00"},{"id":3330137,"file_name":"swing_1.png","project_id":194473,"asset_id":267887,"created_at":"2020-10-06T18:22:43.475+08:00","updated_at":"2020-10-06T18:22:43.475+08:00"},{"id":3330138,"file_name":"swing_0.png","project_id":194473,"asset_id":267888,"created_at":"2020-10-06T18:22:43.479+08:00","updated_at":"2020-10-06T18:22:43.479+08:00"},{"id":3330139,"file_name":"0.png","project_id":194473,"asset_id":267889,"created_at":"2020-10-06T18:22:43.483+08:00","updated_at":"2020-10-06T18:22:43.483+08:00"},{"id":3330140,"file_name":"1.png","project_id":194473,"asset_id":267890,"created_at":"2020-10-06T18:22:43.486+08:00","updated_at":"2020-10-06T18:22:43.486+08:00"},{"id":3330141,"file_name":"2.png","project_id":194473,"asset_id":267891,"created_at":"2020-10-06T18:22:43.490+08:00","updated_at":"2020-10-06T18:22:43.490+08:00"},{"id":3330142,"file_name":"3.png","project_id":194473,"asset_id":267892,"created_at":"2020-10-06T18:22:43.494+08:00","updated_at":"2020-10-06T18:22:43.494+08:00"},{"id":3330143,"file_name":"4.png","project_id":194473,"asset_id":267893,"created_at":"2020-10-06T18:22:43.497+08:00","updated_at":"2020-10-06T18:22:43.497+08:00"},{"id":3330144,"file_name":"5.png","project_id":194473,"asset_id":267894,"created_at":"2020-10-06T18:22:43.501+08:00","updated_at":"2020-10-06T18:22:43.501+08:00"},{"id":3330145,"file_name":"arrow_1.png","project_id":194473,"asset_id":267895,"created_at":"2020-10-06T18:22:43.504+08:00","updated_at":"2020-10-06T18:22:43.504+08:00"},{"id":3330146,"file_name":"archer.png","project_id":194473,"asset_id":267896,"created_at":"2020-10-06T18:22:43.508+08:00","updated_at":"2020-10-06T18:22:43.508+08:00"},{"id":3330147,"file_name":"arrow_0.png","project_id":194473,"asset_id":267897,"created_at":"2020-10-06T18:22:43.511+08:00","updated_at":"2020-10-06T18:22:43.511+08:00"},{"id":3330148,"file_name":"bow.png","project_id":194473,"asset_id":267898,"created_at":"2020-10-06T18:22:43.515+08:00","updated_at":"2020-10-06T18:22:43.515+08:00"},{"id":3330149,"file_name":"apple.png","project_id":194473,"asset_id":267899,"created_at":"2020-10-06T18:22:43.518+08:00","updated_at":"2020-10-06T18:22:43.518+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦