{"id":199143,"student_id":10,"content":"import game\nimport random\n\nbg = game.create_sprite('b.jpg')\np1 = game.create_sprite('p1_0.png', 'p1_1.png')\np2 = game.create_sprite('p1_0.png', 'p1_1.png')\np2.y += 100\n\np1.direction += 90\np2.direction += 90\n\np1_cmds = []\np2_cmds = []\n\np1_target = 0\np2_target = 0\n\nbg.x += 1200\np1_speed = 0\np2_speed = 0\np1_distance = 0\np2_distance = 0\n\nfor i in range(100):\n rand = random.randrange(4)\n \n cmd = game.create_sprite('1.png', '2.png', '3.png', '4.png')\n cmd.move_to(100 + i * 150, 100)\n cmd.costume_id = rand\n p1_cmds.append(cmd)\n \n cmd = game.create_sprite('1.png', '2.png', '3.png', '4.png')\n cmd.move_to(100 + i * 150, 800)\n cmd.costume_id = rand\n p2_cmds.append(cmd)\n \n\ndef loop ():\n global p1_speed, p2_speed, p1_distance, p2_distance\n \n p1_distance += p1_speed\n p2_distance += p2_speed\n \n first = max(p1_distance, p2_distance)\n \n bg.x = 1650 - first\n p1.x = 450 + p1_distance - first\n p2.x = 450 + p2_distance - first\n \n \n if p1_speed \u003e 1: p1_speed -= 0.02\n if p2_speed \u003e 1: p2_speed -= 0.02\n \n p1.costume_id = int(p1_distance / 50) % 2\n p2.costume_id = int(p2_distance / 50) % 2\n \n for i in range(100):\n cmd = p1_cmds[i]\n if p1_cmds[p1_target].x \u003e 100: cmd.x -= 10\n cmd.opacity = (1200 - cmd.x) / 1200\n \n for i in range(100):\n cmd = p2_cmds[i]\n if p2_cmds[p2_target].x \u003e 100: cmd.x -= 10\n cmd.opacity = (1200 - cmd.x) / 1200\n \ndef press_down(): p1_onpress(0)\ndef press_left(): p1_onpress(1)\ndef press_right(): p1_onpress(2)\ndef press_up(): p1_onpress(3)\ndef press_s(): p2_onpress(0)\ndef press_a(): p2_onpress(1)\ndef press_d(): p2_onpress(2)\ndef press_w(): p2_onpress(3)\n\n\ndef p1_onpress(costume_id):\n global p1_target, p1_speed\n if p1_cmds[p1_target].costume_id == costume_id:\n p1_target += 1\n p1_speed += 1\n else:\n p1_speed -= 1\n \ndef p2_onpress(costume_id):\n global p2_target, p2_speed\n if p2_cmds[p2_target].costume_id == costume_id:\n p2_target += 1\n p2_speed += 1\n else:\n p2_speed -= 1\n \n\ngame.on('keydown', 'left', press_left)\ngame.on('keydown', 'right', press_right)\ngame.on('keydown', 'up', press_up)\ngame.on('keydown', 'down', press_down)\ngame.on('keydown', 'a', press_a)\ngame.on('keydown', 'd', press_d)\ngame.on('keydown', 'w', press_w)\ngame.on('keydown', 's', press_s)\ngame.forever(loop)\n\n","created_at":"2020-10-26T12:05:39.975+08:00","updated_at":"2020-11-27T00:43:30.975+08:00","name":"游泳競賽","language":"python","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/199143/da796349e8069d613d0e2b897a268750.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":251,"hashid":"zpesjd46d","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3425620,"file_name":"2.png","project_id":199143,"asset_id":268805,"created_at":"2020-10-26T12:08:10.292+08:00","updated_at":"2020-10-26T12:08:10.292+08:00"},{"id":3425615,"file_name":"p1_1.png","project_id":199143,"asset_id":268791,"created_at":"2020-10-26T12:07:43.283+08:00","updated_at":"2020-10-26T12:07:43.283+08:00"},{"id":3425621,"file_name":"b.jpg","project_id":199143,"asset_id":274803,"created_at":"2020-10-26T13:14:03.526+08:00","updated_at":"2020-10-26T13:14:29.062+08:00"},{"id":3425617,"file_name":"3.png","project_id":199143,"asset_id":268806,"created_at":"2020-10-26T12:08:05.266+08:00","updated_at":"2020-10-26T12:08:05.266+08:00"},{"id":3425618,"file_name":"4.png","project_id":199143,"asset_id":268807,"created_at":"2020-10-26T12:08:06.860+08:00","updated_at":"2020-10-26T12:08:06.860+08:00"},{"id":3425616,"file_name":"p1_0.png","project_id":199143,"asset_id":268790,"created_at":"2020-10-26T12:07:45.771+08:00","updated_at":"2020-10-26T12:07:45.771+08:00"},{"id":3425619,"file_name":"1.png","project_id":199143,"asset_id":268804,"created_at":"2020-10-26T12:08:08.370+08:00","updated_at":"2020-10-26T12:08:08.370+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦