{"id":196927,"student_id":10,"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\ncreate_sound('bgm.mp3', True)\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(-200, 1400)\n target.y = 1000\n target.scale = 1\n target.hidden = False\n vy = -randrange(15, 20)\n vx = randrange(5, 10)\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.hidden = True\n score += 1\n create_sound('shot.mp3')\n \n if count == 31: stop() #注意是 31 哦\n \n draw_text('回合: ' + str(count) + '/30', 30, 30, 'white', 50)\n draw_text('得分: ' + str(score), 30, 830, 'white', 50)\n\nforever(loop) #重複不斷執行遊戲迴圈\n\n","created_at":"2020-10-19T15:25:23.206+08:00","updated_at":"2020-12-14T15:47:39.240+08:00","name":"運動會系列 - 射擊競賽(預設版)","language":"python","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/196927/15927256803d0436c7eb462467632bd1.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":208,"hashid":"36ysme5k3","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3429368,"file_name":"target.png","project_id":196927,"asset_id":275095,"created_at":"2020-10-29T15:32:36.497+08:00","updated_at":"2020-10-29T15:32:36.497+08:00"},{"id":3429369,"file_name":"sign_0.png","project_id":196927,"asset_id":275096,"created_at":"2020-10-29T15:32:57.816+08:00","updated_at":"2020-10-29T15:32:57.816+08:00"},{"id":3429370,"file_name":"sign_1.png","project_id":196927,"asset_id":275097,"created_at":"2020-10-29T15:32:57.817+08:00","updated_at":"2020-10-29T15:32:57.817+08:00"},{"id":3631597,"file_name":"bg.jpg","project_id":196927,"asset_id":287273,"created_at":"2020-11-30T17:42:01.676+08:00","updated_at":"2020-11-30T17:42:01.676+08:00"},{"id":3631598,"file_name":"dashboard.png","project_id":196927,"asset_id":284917,"created_at":"2020-11-30T17:54:15.436+08:00","updated_at":"2020-11-30T17:54:15.436+08:00"},{"id":3680794,"file_name":"bgm.mp3","project_id":196927,"asset_id":291682,"created_at":"2020-12-10T23:15:39.255+08:00","updated_at":"2020-12-10T23:15:39.255+08:00"},{"id":3680793,"file_name":"shot.mp3","project_id":196927,"asset_id":280214,"created_at":"2020-12-10T23:15:06.300+08:00","updated_at":"2020-12-10T23:15:06.300+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦