{"id":194782,"student_id":10,"content":"import game\nimport random\n\ntarget = game.create_sprite('target.png')\nsight = game.create_sprite('sight.png')\n\ntarget.scale = 0.1\nholes = []\nleaves = []\nclock = 0\n\nvx = random.random() * 10 - 5\nvy = random.random() * 10 - 5\n\nfor i in range(2):\n l = game.create_sprite('leaf.png')\n l.x = random.randrange(1200)\n l.y = random.randrange(1200)\n leaves.append(l)\n\ndef loop ():\n global clock, vx, vy\n \n clock += 1\n if clock % 300 == 0:\n vx = random.random() * 10 - 5\n vy = random.random() * 10 - 5\n \n if game.key.up: sight.y -= 3\n if game.key.down: sight.y += 3\n if game.key.right: sight.x += 3\n if game.key.left: sight.x -= 3\n \n sight.x += vx / 10\n sight.y += vy / 10\n \n for l in leaves:\n l.x += vx\n l.y += vy\n l.direction += 1\n if l.x \u003c 0: l.x += 1200\n if l.y \u003c 0: l.y += 900\n if l.x \u003e 1200: l.x -= 1200\n if l.y \u003e 900: l.y -= 900\n \n\ndef shoot():\n hole = game.create_sprite('hole.png')\n hole.move_to(sight)\n hole.scale = 0.1\n holes.append(hole)\n \n if len(holes) \u003e= 10: show_result()\n\ndef show_result():\n sight.hidden = True\n target.scale = 1\n score = 0\n for h in holes:\n h.scale = 1\n h.x = (h.x - 600)*10 + 600\n h.y = (h.y - 450)*10 + 450\n \n l = int(target.distance_to(h) / 50)\n if l \u003c 5: score += (5 - l)*100\n \n game.draw_text(score, 100, 100, 'black', 60)\n game.stop()\n \n\ngame.forever(loop) \ngame.on('keydown', 'space', shoot)","created_at":"2020-10-13T15:57:52.503+08:00","updated_at":"2020-11-24T16:11:07.155+08:00","name":"運動會系列 - 射擊競賽","language":"python","screenshot":{"url":"/uploads/project/screenshot/194782/9ce0f967ea61525d4827e140becc2a6c.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":389,"hashid":"d5msvwwpg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3334943,"file_name":"hole.png","project_id":194782,"asset_id":268810,"created_at":"2020-10-13T15:58:18.894+08:00","updated_at":"2020-10-13T15:58:18.894+08:00"},{"id":3334944,"file_name":"sight.png","project_id":194782,"asset_id":268811,"created_at":"2020-10-13T15:58:18.896+08:00","updated_at":"2020-10-13T15:58:18.896+08:00"},{"id":3334945,"file_name":"target.png","project_id":194782,"asset_id":268812,"created_at":"2020-10-13T15:58:19.664+08:00","updated_at":"2020-10-13T15:58:19.664+08:00"},{"id":3334946,"file_name":"leaf.png","project_id":194782,"asset_id":268813,"created_at":"2020-10-13T16:35:10.980+08:00","updated_at":"2020-10-13T16:35:10.980+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