{"id":194899,"student_id":10,"content":"import game\n\ngame.set_backdrop('bg.jpg')\nstick = game.create_sprite('stick.png')\nball = game.create_sprite('ball.png')\np1 = game.create_sprite('p1.png')\np2 = game.create_sprite('p2.png')\n\nstick.y = 800\np1.x = 900\np1.y = 800\np2.x = 300\np2.y = 800\n\nball.scale = 0.8\nball.x = p1.x\n\np1_vy = 0\np2_vy = 0\nvx = 0\nvy = 0\np1_score = 0\np2_score = 0\n\ngame.create_sound('bgm.mp3', True)\n\ndef loop():\n global p1_vy, p2_vy, vx, vy, p1_score, p2_score\n \n if key.right and p1.x \u003c 1200: p1.x += 10\n if key.left and p1.x \u003e 700: p1.x -= 10\n if key.up and p1.y \u003e= 750: p1_vy = -30\n \n p1_vy += 2\n p1.y += p1_vy\n if p1.y \u003e 800: p1.y = 800\n \n if ball.touched(p1):\n vx = (ball.x - p1.x) / 7\n vy = (ball.y - p1.y) / 7\n \n if key.d and p2.x \u003c 500: p2.x += 10\n if key.a and p2.x \u003e 0: p2.x -= 10\n if key.w and p2.y \u003e= 750: p2_vy = -30\n \n p2.y += p2_vy\n p2_vy += 2\n if p2.y \u003e 800: p2.y = 800\n \n if ball.touched(p2):\n vx = (ball.x - p2.x) / 7\n vy = (ball.y - p2.y) / 7\n \n ball.x += vx\n ball.y += vy\n vy += 0.4\n \n if ball.touched(stick):\n if ball.x \u003c 600: vx = -abs(vx)\n else: vx = abs(vx)\n \n if ball.x \u003c 0 and vx \u003c 0:\n vx = -vx\n \n if ball.x \u003e 1200 and vx \u003e 0:\n vx = -vx\n \n if ball.y \u003c 0 and vy \u003c 0:\n vy = -vy\n \n if ball.y \u003e 900 and vy \u003e 0:\n ball.y = 200\n vx = 0\n vy = 0\n if ball.x \u003c 600:\n ball.x = p2.x\n p2_score += 1\n else:\n ball.x = p1.x\n p1_score += 1\n \n game.draw_text('p2: ' + str(p2_score), 1000, 10, 'red', 70)\n game.draw_text('p2: ' + str(p1_score), 10, 10, 'red', 70)\n \n ball.direction += vx / 2\n \n if p1_score \u003e= 15:\n game.stop()\n game.draw_text('p1 win', 100, 100, 'red', '80')\n \n if p2_score \u003e= 15:\n game.stop()\n game.draw_text('p2 win', 100, 100, 'red', '80')\n \n\ngame.forever(loop)","created_at":"2020-10-14T17:11:00.593+08:00","updated_at":"2020-10-14T17:35:03.459+08:00","name":"皮卡丘打排球 v2","language":"python","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/194899/8f9cd87dd2d2ebdad94d0b7acafe7209.jpg"},"parent_id":194894,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":777,"hashid":"4y3sgdd44","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3337182,"file_name":"stick.png","project_id":194899,"asset_id":268962,"created_at":"2020-10-14T17:11:00.600+08:00","updated_at":"2020-10-14T17:11:00.600+08:00"},{"id":3337183,"file_name":"ball.png","project_id":194899,"asset_id":268961,"created_at":"2020-10-14T17:11:00.602+08:00","updated_at":"2020-10-14T17:11:00.602+08:00"},{"id":3337184,"file_name":"p2.png","project_id":194899,"asset_id":268960,"created_at":"2020-10-14T17:11:00.603+08:00","updated_at":"2020-10-14T17:11:00.603+08:00"},{"id":3337185,"file_name":"p1.png","project_id":194899,"asset_id":268959,"created_at":"2020-10-14T17:11:00.604+08:00","updated_at":"2020-10-14T17:11:00.604+08:00"},{"id":3337186,"file_name":"bg.jpg","project_id":194899,"asset_id":15674,"created_at":"2020-10-14T17:11:00.605+08:00","updated_at":"2020-10-14T17:11:00.605+08:00"},{"id":3337276,"file_name":"hit.mp3","project_id":194899,"asset_id":269044,"created_at":"2020-10-14T17:32:07.514+08:00","updated_at":"2020-10-14T17:32:10.698+08:00"},{"id":3337358,"file_name":"bgm.mp3","project_id":194899,"asset_id":269126,"created_at":"2020-10-14T17:34:46.712+08:00","updated_at":"2020-10-14T17:34:46.712+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦