{"id":194759,"student_id":10,"content":"import game\nimport random\n\nbg = game.create_sprite('bg.jpg')\nplayer = game.create_sprite('0.png')\n\nbtn_1 = game.create_sprite('1.png', '2.png', '3.png', '4.png')\nbtn_1.move_to(100, 100)\nbtn_1.costume_id = random.randrange(4)\n\nvx = 0\nvy = 0\nis_start = False\nscore = 0\n\nbtns = [btn_1]\n\ntarget = 0\n\ndef loop ():\n global vx, vy, is_start, btns, btn\n \n if is_start: vy += 0.1\n bg.y -= vy\n \n if bg.y \u003c -450:\n is_start = False\n vy -= 0.2\n if vy \u003c -3: vy = -3\n \n game.draw_text(score, 10, 10, 'black', 30)\n \n if btns[target].x \u003e 100:\n for btn in btns: btn.x -= 5\n \n\ndef press_down():\n if btns[target].costume_id == 0: next_btn()\n \ndef press_left():\n if btns[target].costume_id == 1: next_btn()\n\ndef press_right():\n if btns[target].costume_id == 2: next_btn()\n\ndef press_up():\n if btns[target].costume_id == 3: next_btn()\n \n\ndef add_btn ():\n btn = game.create_sprite('1.png', '2.png', '3.png', '4.png')\n btn.costume_id = random.randrange(4)\n btn.x = btns[-1].x + 150\n btn.y = 100\n btns.append(btn)\n\ndef next_btn():\n global score, vx, vy, is_start, target\n \n if is_start == False:\n vy = -10\n is_start = True\n \n btns[target].opacity = 0.2\n add_btn()\n target += 1\n score += 1\n player.direction += 120\n \n\nadd_btn()\nadd_btn()\nadd_btn()\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)\n\ngame.forever(loop)","created_at":"2020-10-13T14:19:44.123+08:00","updated_at":"2021-03-18T15:47:47.692+08:00","name":"運動會系列 - 跳水競賽","language":"python","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/194759/4e50336323ceef2757582ea494874e98.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":205,"hashid":"9ygspqq2z","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3334820,"file_name":"bg.jpg","project_id":194759,"asset_id":268803,"created_at":"2020-10-13T14:20:14.589+08:00","updated_at":"2020-10-13T14:20:14.589+08:00"},{"id":3334821,"file_name":"0.png","project_id":194759,"asset_id":268790,"created_at":"2020-10-13T14:20:39.450+08:00","updated_at":"2020-10-13T14:20:39.450+08:00"},{"id":3334824,"file_name":"3.png","project_id":194759,"asset_id":268806,"created_at":"2020-10-13T14:26:37.638+08:00","updated_at":"2020-10-13T14:48:07.154+08:00"},{"id":3334825,"file_name":"4.png","project_id":194759,"asset_id":268807,"created_at":"2020-10-13T14:26:37.639+08:00","updated_at":"2020-10-13T14:48:10.886+08:00"},{"id":3334822,"file_name":"1.png","project_id":194759,"asset_id":268804,"created_at":"2020-10-13T14:26:36.992+08:00","updated_at":"2020-10-13T14:48:02.781+08:00"},{"id":3334823,"file_name":"2.png","project_id":194759,"asset_id":268805,"created_at":"2020-10-13T14:26:36.993+08:00","updated_at":"2020-10-13T14:48:04.477+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦