{"id":226850,"student_id":2589,"content":"from game import *\nfrom random import randrange\n\n\nset_backdrop('bg.jpg') #設定背景圖\ntarget = create_sprite('target.png') #目標物\nboard1 = create_sprite('dashboard.png') #左上計分板\nboard2 = create_sprite('dashboard.png') #左下計分板\n\ntarget.move_to(0, 900)\nboard1.move_to(150, 50)\nboard2.move_to(150, 850)\n\nvx = 15 #目標物水平速度\nvy = -15 #目標物垂直速度\nscore = 0 #玩家得分\ncount = 0 #回合次數\nsigns = [] #存放準星的串列\n\nfor y in range(3):\n for x in range(3):\n s = create_sprite('sign_0.png', 'sign_1.png')\n s.x = 300 + x * 300\n s.y = 200 + y * 200\n signs.append(s)\n\n#遊戲主迴圈\ndef loop ():\n global vx, vy, score, count\n \n for s in signs: s.costume_id = 0\n \n if key.q: signs[0].costume_id = 1\n elif key.w: signs[1].costume_id = 1\n elif key.e: signs[2].costume_id = 1\n elif key.a: signs[3].costume_id = 1\n elif key.s: signs[4].costume_id = 1\n elif key.d: signs[5].costume_id = 1\n elif key.z: signs[6].costume_id = 1\n elif key.x: signs[7].costume_id = 1\n elif key.c: signs[8].costume_id = 1\n \n target.x += vx\n target.y += vy\n vy += 0.2\n target.scale -= 0.005\n \n if target.y \u003e 1000:\n target.x = randrange(-100, 1300)\n target.y = 1000\n target.scale = 1\n target.opacity = 1\n vy = -randrange(15, 20)\n vx = randrange(4, 8)\n if target.x \u003e 600: vx = -vx\n count += 1\n \n for s in signs:\n if s.costume_id == 1 and target.touched(s) and target.opacity == 1:\n target.opacity = 0.3\n score += 1\n \n if count == 30: stop()\n \n draw_text('回合: ' + str(count) + '/30', 30, 30, 'white', 50)\n draw_text('得分: ' + str(score), 30, 830, 'white', 50)\n\nforever(loop) #重複不斷執行遊戲迴圈","created_at":"2021-02-04T19:12:28.278+08:00","updated_at":"2021-02-04T19:12:55.266+08:00","name":"運動會系列 - 射擊競賽(解答)","language":"python","screenshot":{"url":null},"parent_id":210506,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":100,"hashid":"gk4sknyww","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4039955,"file_name":"dashboard.png","project_id":226850,"asset_id":291349,"created_at":"2021-02-04T19:12:28.283+08:00","updated_at":"2021-02-04T19:12:28.283+08:00"},{"id":4039956,"file_name":"bg.jpg","project_id":226850,"asset_id":291350,"created_at":"2021-02-04T19:12:28.285+08:00","updated_at":"2021-02-04T19:12:28.285+08:00"},{"id":4039957,"file_name":"sign_1.png","project_id":226850,"asset_id":291351,"created_at":"2021-02-04T19:12:28.285+08:00","updated_at":"2021-02-04T19:12:28.285+08:00"},{"id":4039958,"file_name":"sign_0.png","project_id":226850,"asset_id":291352,"created_at":"2021-02-04T19:12:28.286+08:00","updated_at":"2021-02-04T19:12:28.286+08:00"},{"id":4039959,"file_name":"target.png","project_id":226850,"asset_id":291353,"created_at":"2021-02-04T19:12:28.287+08:00","updated_at":"2021-02-04T19:12:28.287+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦