{"id":169325,"student_id":3232,"content":"import game\nimport random #載入產生隨機數的套件\n\n# 建立角色\nbg = game.create_sprite(\"bg.png\") #創造角色(\"bg.png\") #設定背景\nplayer = game.create_sprite(\"player.png\") #創造角色\nhint = game.create_sprite(\"hint.png\") #創造角色\n #創造角色\nbubbles = []\nvy = 0 #墜落速度\nlevel = 0 #分數\ninitY = 450 #最新產生的障礙物位置\nis_start = False #是否開始遊戲\nrocks = []\n# player.layer = 1\n# hint.scale = 1.5\nc = 0\n\ngame.create_sound('bgm.ogg', True)\n\n# 建立泡泡\n\n# 建立岩石(障礙物)\nfor i in range(1, 18, 1):\n\n rock = game.create_sprite(\"b0.png\", \"b1.png\", \"b2.png\", \"b3.png\", \"b4.png\", \"b5.png\", \"b6.png\", \"b7.png\", \"b8.png\", \"b9.png\", \"b10.png\")\n rock.x = 75*i\n rocks.append(rock)\nfor z in range(0, 21, 1):\n bubble = game.create_sprite(\"bubble.png\")\n bubbles.append(bubble)\n bubbles[z].x = z*30\n#遊戲主迴圈\ndef loop ():\n global level, initY, is_start, vy, rocks, c\n\n# 岩石往後移動\n \n# 場景變化\n for a in range(0, 17, 1):\n rocks[a].x -= 8\n if is_start == True:\n if rocks[a].x \u003c -30:\n rocks[a].y = random.randint(rocks[a-1].y-60, rocks[a-1].y+60)\n if rocks[a-1].y \u003c 360:\n rocks[a].y = rocks[a-1].y + random.randint(0, 60)\n if rocks[a-1].y \u003e 540:\n rocks[a].y = rocks[a-1].y - random.randint(0, 60)\n rocks[a].x += 1275\n rocks[a].costume_id = c\n if player.touched(rocks[a]):\n game.stop()\n else:\n if rocks[a].x \u003c -30:\n rocks[a].x += 1275\n\n\n# 遊戲開始\n if key.space:\n is_start = True\n hint.hidden = True\n if is_start == True:\n level += 0.05\n player.direction = 90+vy*2\n \n \n if level \u003c= 30:\n c = 0 \n elif level \u003c= 60:\n c = 1 \n elif level \u003c= 90:\n c = 2 \n elif level \u003c= 120:\n c = 3 \n elif level \u003c= 150:\n c = 4 \n elif level \u003c= 180:\n c = 5 \n elif level \u003c= 210:\n c = 6 \n elif level \u003c= 240:\n c = 7 \n elif level \u003c= 270:\n c = 8 \n elif level \u003e 270:\n c = 9\n\n\n# 潛艇控制(空白鍵按下)\n if key.space:\n vy -= 0.3\n player.y += vy\n elif is_start == True:\n vy += 0.3\n player.y += vy\n\n# 泡泡\n for k in range(21):\n bubbles[k].x -= 7\n bubbles[k].y -= 2\n if bubbles[k].x \u003c -10:\n bubbles[k].x = player.x - random.random()*20-60\n bubbles[k].y = player.y - random.random()*20\n bubbles[k].scale = bubbles[k].x/600\n bubbles[k].opacity = bubbles[k].x/600\n \n# 背景變化\n bg.x -= 0.3\n if bg.x \u003c -1200:\n bg.x += 2400\n# 顯示Level\n w = round(level, 0)\n game.draw_text(\"Level: \" + str(w), 10, 10, \"black\", 70)\n\ngame.forever(loop) #重複不斷執行遊戲迴圈","created_at":"2020-07-22T10:54:38.504+08:00","updated_at":"2020-07-23T16:29:07.997+08:00","name":"海底探險_S 副本","language":"python","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/169325/b4fe4f73716af0bd16eb28d704402f11.jpg"},"parent_id":162848,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":54,"hashid":"4y3sn9jz","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2926640,"file_name":"b0.png","project_id":169325,"asset_id":200369,"created_at":"2020-07-22T10:54:38.510+08:00","updated_at":"2020-07-22T10:54:38.510+08:00"},{"id":2926641,"file_name":"b1.png","project_id":169325,"asset_id":200370,"created_at":"2020-07-22T10:54:38.511+08:00","updated_at":"2020-07-22T10:54:38.511+08:00"},{"id":2926642,"file_name":"b2.png","project_id":169325,"asset_id":200371,"created_at":"2020-07-22T10:54:38.512+08:00","updated_at":"2020-07-22T10:54:38.512+08:00"},{"id":2926643,"file_name":"b3.png","project_id":169325,"asset_id":200372,"created_at":"2020-07-22T10:54:38.513+08:00","updated_at":"2020-07-22T10:54:38.513+08:00"},{"id":2926644,"file_name":"b4.png","project_id":169325,"asset_id":200373,"created_at":"2020-07-22T10:54:38.514+08:00","updated_at":"2020-07-22T10:54:38.514+08:00"},{"id":2926645,"file_name":"b5.png","project_id":169325,"asset_id":200374,"created_at":"2020-07-22T10:54:38.515+08:00","updated_at":"2020-07-22T10:54:38.515+08:00"},{"id":2926646,"file_name":"b6.png","project_id":169325,"asset_id":200375,"created_at":"2020-07-22T10:54:38.516+08:00","updated_at":"2020-07-22T10:54:38.516+08:00"},{"id":2926647,"file_name":"b7.png","project_id":169325,"asset_id":200376,"created_at":"2020-07-22T10:54:38.517+08:00","updated_at":"2020-07-22T10:54:38.517+08:00"},{"id":2926648,"file_name":"b8.png","project_id":169325,"asset_id":200377,"created_at":"2020-07-22T10:54:38.518+08:00","updated_at":"2020-07-22T10:54:38.518+08:00"},{"id":2926649,"file_name":"b9.png","project_id":169325,"asset_id":200378,"created_at":"2020-07-22T10:54:38.519+08:00","updated_at":"2020-07-22T10:54:38.519+08:00"},{"id":2926650,"file_name":"b10.png","project_id":169325,"asset_id":200379,"created_at":"2020-07-22T10:54:38.520+08:00","updated_at":"2020-07-22T10:54:38.520+08:00"},{"id":2926651,"file_name":"bg.png","project_id":169325,"asset_id":201852,"created_at":"2020-07-22T10:54:38.521+08:00","updated_at":"2020-07-22T10:54:38.521+08:00"},{"id":2926652,"file_name":"bgm_3.ogg","project_id":169325,"asset_id":170604,"created_at":"2020-07-22T10:54:38.521+08:00","updated_at":"2020-07-22T10:54:38.521+08:00"},{"id":2926653,"file_name":"bgm.ogg","project_id":169325,"asset_id":170605,"created_at":"2020-07-22T10:54:38.522+08:00","updated_at":"2020-07-22T10:54:38.522+08:00"},{"id":2926654,"file_name":"bubble.png","project_id":169325,"asset_id":200358,"created_at":"2020-07-22T10:54:38.523+08:00","updated_at":"2020-07-22T10:54:38.523+08:00"},{"id":2926655,"file_name":"hint.png","project_id":169325,"asset_id":189068,"created_at":"2020-07-22T10:54:38.524+08:00","updated_at":"2020-07-22T10:54:38.524+08:00"},{"id":2926656,"file_name":"player.png","project_id":169325,"asset_id":200359,"created_at":"2020-07-22T10:54:38.525+08:00","updated_at":"2020-07-22T10:54:38.525+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦