{"id":252320,"student_id":10,"content":"from game import *\n\nset_backdrop('bg.png') #設定背景圖\nstick = create_sprite('stick.png') #中網\nball = create_sprite('ball.png') #球\np1 = create_sprite('p1_0.png', 'p1_1.png', 'p1_2.png', 'p1_3.png') #左邊玩家\np2 = create_sprite('p2_0.png', 'p2_1.png', 'p2_2.png', 'p2_3.png') #右邊玩家\nboard = create_sprite(\"dashboard.png\") #計分板\n\nboard.move_to(150, 50)\nstick.move_to(600, 750)\np1.move_to(300, 750)\np2.move_to(900, 750)\n\nball.move_to(p1.x, 0) #由左邊玩家發球\n\nvx = 0 #球的水平速度\nvy = 0 #球的垂直速度\np1_vy = 0 #p1玩家墜落速度\np2_vy = 0 #p2玩家墜落速度\np1_score = 0 #p1玩家分數\np2_score = 0 #p2玩家分數\n\n# create_sound('bgm_0.mp3', True)\n# create_sound('bgm_1.mp3', True)\n\n# p1角色控制與更新\ndef update_p1():\n global p1_vy, vx, vy\n \n if key.d and p1.x \u003c 500: p1.x += 7\n if key.a and p1.x \u003e 0: p1.x -= 7\n if key.w and p1.y \u003e= 750: p1_vy = -30\n \n p1_vy += 2\n p1.y += p1_vy\n if p1.y \u003e 750: p1.y = 750 #讓角色不會掉超出垂直座標 750 的位置\n \n if p1.y \u003c 750:\n p1.costume_id = 2\n elif key.s:\n p1.costume_id = 3\n else:\n p1.costume_id = int(p1.x / 50) % 2\n\n# p2角色控制與更新\ndef update_p2():\n global p2_vy, vx, vy\n \n if key.right and p2.x \u003c 1200: p2.x += 7\n if key.left and p2.x \u003e 700: p2.x -= 7\n if key.up and p2.y \u003e= 750: p2_vy = -30\n \n p2.y += p2_vy\n p2_vy += 2\n if p2.y \u003e 750: p2.y = 750 #讓角色不會掉超出垂直座標 750 的位置\n \n if p2.y \u003c 750:\n p2.costume_id = 2\n elif key.down:\n p2.costume_id = 3\n else:\n p2.costume_id = int(p1.x / 50) % 2\n\n\n# 球的碰撞、反彈、玩家得分\ndef update_ball():\n global vy, vx, p1_score, p2_score\n\n \n# 分數顯示\u0026輸贏判斷\ndef update_score():\n pass\n \nforever(update_p1)\nforever(update_p2)\nforever(update_ball)\nforever(update_score)\n\n","created_at":"2021-05-12T11:04:03.256+08:00","updated_at":"2022-11-02T15:52:36.528+08:00","name":"叩叮打排球_除錯模擬","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/252320/7e1fe06fb010baa279961d3d5bc85d32.jpg"},"parent_id":194894,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":217,"hashid":"rdvs6z3v3","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4772327,"file_name":"bgm_1.mp3","project_id":252320,"asset_id":291421,"created_at":"2021-05-12T11:04:03.265+08:00","updated_at":"2021-05-12T11:04:03.265+08:00"},{"id":4772328,"file_name":"dashboard.png","project_id":252320,"asset_id":291422,"created_at":"2021-05-12T11:04:03.267+08:00","updated_at":"2021-05-12T11:04:03.267+08:00"},{"id":4772329,"file_name":"stick.png","project_id":252320,"asset_id":291423,"created_at":"2021-05-12T11:04:03.269+08:00","updated_at":"2021-05-12T11:04:03.269+08:00"},{"id":4772330,"file_name":"p2_3.png","project_id":252320,"asset_id":291424,"created_at":"2021-05-12T11:04:03.270+08:00","updated_at":"2021-05-12T11:04:03.270+08:00"},{"id":4772331,"file_name":"p2_2.png","project_id":252320,"asset_id":291425,"created_at":"2021-05-12T11:04:03.272+08:00","updated_at":"2021-05-12T11:04:03.272+08:00"},{"id":4772332,"file_name":"p2_1.png","project_id":252320,"asset_id":291426,"created_at":"2021-05-12T11:04:03.273+08:00","updated_at":"2021-05-12T11:04:03.273+08:00"},{"id":4772333,"file_name":"p2_0.png","project_id":252320,"asset_id":291427,"created_at":"2021-05-12T11:04:03.275+08:00","updated_at":"2021-05-12T11:04:03.275+08:00"},{"id":4772334,"file_name":"p1_3.png","project_id":252320,"asset_id":291428,"created_at":"2021-05-12T11:04:03.276+08:00","updated_at":"2021-05-12T11:04:03.276+08:00"},{"id":4772335,"file_name":"p1_2.png","project_id":252320,"asset_id":291429,"created_at":"2021-05-12T11:04:03.277+08:00","updated_at":"2021-05-12T11:04:03.277+08:00"},{"id":4772336,"file_name":"p1_1.png","project_id":252320,"asset_id":291430,"created_at":"2021-05-12T11:04:03.279+08:00","updated_at":"2021-05-12T11:04:03.279+08:00"},{"id":4772337,"file_name":"p1_0.png","project_id":252320,"asset_id":291431,"created_at":"2021-05-12T11:04:03.281+08:00","updated_at":"2021-05-12T11:04:03.281+08:00"},{"id":4772338,"file_name":"bg.png","project_id":252320,"asset_id":291432,"created_at":"2021-05-12T11:04:03.282+08:00","updated_at":"2021-05-12T11:04:03.282+08:00"},{"id":4772339,"file_name":"ball.png","project_id":252320,"asset_id":291433,"created_at":"2021-05-12T11:04:03.284+08:00","updated_at":"2021-05-12T11:04:03.284+08:00"},{"id":4772340,"file_name":"bgm_0.mp3","project_id":252320,"asset_id":291434,"created_at":"2021-05-12T11:04:03.285+08:00","updated_at":"2021-05-12T11:04:03.285+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦