{"id":203252,"student_id":12205,"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-11-13T20:59:10.824+08:00","updated_at":"2020-11-13T20:59:10.824+08:00","name":"皮卡丘打排球 v2 副本","language":"python","screenshot":{"url":null},"parent_id":194899,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":207,"hashid":"meysw43d8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3511392,"file_name":"bgm.mp3","project_id":203252,"asset_id":269126,"created_at":"2020-11-13T20:59:10.830+08:00","updated_at":"2020-11-13T20:59:10.830+08:00"},{"id":3511393,"file_name":"hit.mp3","project_id":203252,"asset_id":269044,"created_at":"2020-11-13T20:59:10.831+08:00","updated_at":"2020-11-13T20:59:10.831+08:00"},{"id":3511394,"file_name":"bg.jpg","project_id":203252,"asset_id":15674,"created_at":"2020-11-13T20:59:10.832+08:00","updated_at":"2020-11-13T20:59:10.832+08:00"},{"id":3511395,"file_name":"p1.png","project_id":203252,"asset_id":268959,"created_at":"2020-11-13T20:59:10.833+08:00","updated_at":"2020-11-13T20:59:10.833+08:00"},{"id":3511396,"file_name":"p2.png","project_id":203252,"asset_id":268960,"created_at":"2020-11-13T20:59:10.834+08:00","updated_at":"2020-11-13T20:59:10.834+08:00"},{"id":3511397,"file_name":"ball.png","project_id":203252,"asset_id":268961,"created_at":"2020-11-13T20:59:10.835+08:00","updated_at":"2020-11-13T20:59:10.835+08:00"},{"id":3511398,"file_name":"stick.png","project_id":203252,"asset_id":268962,"created_at":"2020-11-13T20:59:10.835+08:00","updated_at":"2020-11-13T20:59:10.835+08:00"}]
Orange Apple Learning Platform
My Projects
View Project Page
Export
Remix
Import
Delete
Screenshot
繁中
简中
English
日本語
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer