{"id":169372,"student_id":139,"content":"import game\nimport random #載入產生隨機數的套件\n\n# 建立角色\nbg = game.create_sprite(\"bg.png\") #創造角色\nplayer = game.create_sprite(\"player.png\") #創造角色\nhint = game.create_sprite(\"hint.png\") #創造角色\nvy = 0 #墜落速度\nlevel = 0 #分數\ninitY = 450 #最新產生的障礙物位置\nis_start = False #是否開始遊戲\n\n# player.layer = 1\n# hint.scale = 1.5\n\ngame.create_sound('bgm.ogg', True)\n\n# 建立泡泡\nbubbles = []\nfor i in range(20):\n b = game.create_sprite(\"bubble.png\") #創造角色\n b.x = 0\n b.x = b.x + i*30\n bubbles.append(b)\n# 建立岩石(障礙物)\nrocks = []\nfor i in range(17):\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 = 0\n rock.x = rock.x + 75*i\n rocks.append(rock)\n#遊戲主迴圈\ndef loop ():\n global level, initY, is_start, vy\n \n # 岩石往後移動\n # 場景變化\n for rock in rocks:\n if player.touched(rock):\n game.stop()\n rock.x = rock.x - 8\n if rock.x \u003c 0:\n rock.x = 1275\n rock.y = random.randint(300,600)\n level = level + 1\n if level \u003e 30 and level \u003c=60:\n rock.costume_id = 1\n elif level \u003e 60 and level \u003c= 90:\n rock.costume_id = 2\n elif level \u003e 90 and level \u003c= 120:\n rock.costume_id = 3\n elif level \u003e 120 and level \u003c= 150:\n costume_id = 4\n elif level \u003e 150 and level \u003c= 180:\n rock.costume_id = 5\n elif level \u003e 180 and level \u003c= 210:\n rock.costume_id = 6\n elif level \u003e 210 and level \u003c= 240:\n rock.costume_id = 7\n elif level \u003e 240 and level \u003c= 270:\n rock.costume_id = 8\n elif level \u003e 270 and level \u003c= 300:\n rock.costume_id = 9\n elif level \u003e 300 and level \u003c= 330:\n rock.costume_id = 10\n # 遊戲開始\n if is_start:\n # game.drawText(player.y, 500,10,\"white\", 90) \n hint.hidden = True;\n player.y = player.y + vy\n vy = vy + 0.3\n # 潛艇控制(空白鍵按下)\n if key.space:\n is_start = True;\n vy = vy - 0.6 \n # 泡泡\n for i in range(20):\n b = bubbles[i]\n b.x -= 7\n b.y -= 2\n b.scale = b.x/600\n b.opacity = b.x/600\n if b.x \u003c -10:\n b.x = player.x - random.random()*20 - 60\n b.y = player.y + random.random()*20\n # 背景變化\n \n # 顯示Level\n\ngame.forever(loop) #重複不斷執行遊戲迴圈\n\n","created_at":"2020-07-22T13:14:11.727+08:00","updated_at":"2020-07-22T15:32:01.596+08:00","name":"海底探險_S 副本","language":"python","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/169372/63f0ee7b85ce3fdaa49121242e664425.jpg"},"parent_id":162848,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":126,"hashid":"d5msd6vg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2927319,"file_name":"b0.png","project_id":169372,"asset_id":200369,"created_at":"2020-07-22T13:14:11.732+08:00","updated_at":"2020-07-22T13:14:11.732+08:00"},{"id":2927320,"file_name":"b1.png","project_id":169372,"asset_id":200370,"created_at":"2020-07-22T13:14:11.733+08:00","updated_at":"2020-07-22T13:14:11.733+08:00"},{"id":2927321,"file_name":"b2.png","project_id":169372,"asset_id":200371,"created_at":"2020-07-22T13:14:11.735+08:00","updated_at":"2020-07-22T13:14:11.735+08:00"},{"id":2927322,"file_name":"b3.png","project_id":169372,"asset_id":200372,"created_at":"2020-07-22T13:14:11.736+08:00","updated_at":"2020-07-22T13:14:11.736+08:00"},{"id":2927323,"file_name":"b4.png","project_id":169372,"asset_id":200373,"created_at":"2020-07-22T13:14:11.737+08:00","updated_at":"2020-07-22T13:14:11.737+08:00"},{"id":2927324,"file_name":"b5.png","project_id":169372,"asset_id":200374,"created_at":"2020-07-22T13:14:11.738+08:00","updated_at":"2020-07-22T13:14:11.738+08:00"},{"id":2927325,"file_name":"b6.png","project_id":169372,"asset_id":200375,"created_at":"2020-07-22T13:14:11.739+08:00","updated_at":"2020-07-22T13:14:11.739+08:00"},{"id":2927326,"file_name":"b7.png","project_id":169372,"asset_id":200376,"created_at":"2020-07-22T13:14:11.745+08:00","updated_at":"2020-07-22T13:14:11.745+08:00"},{"id":2927327,"file_name":"b8.png","project_id":169372,"asset_id":200377,"created_at":"2020-07-22T13:14:11.746+08:00","updated_at":"2020-07-22T13:14:11.746+08:00"},{"id":2927328,"file_name":"b9.png","project_id":169372,"asset_id":200378,"created_at":"2020-07-22T13:14:11.747+08:00","updated_at":"2020-07-22T13:14:11.747+08:00"},{"id":2927329,"file_name":"b10.png","project_id":169372,"asset_id":200379,"created_at":"2020-07-22T13:14:11.748+08:00","updated_at":"2020-07-22T13:14:11.748+08:00"},{"id":2927330,"file_name":"bg.png","project_id":169372,"asset_id":201852,"created_at":"2020-07-22T13:14:11.749+08:00","updated_at":"2020-07-22T13:14:11.749+08:00"},{"id":2927331,"file_name":"bgm_3.ogg","project_id":169372,"asset_id":170604,"created_at":"2020-07-22T13:14:11.750+08:00","updated_at":"2020-07-22T13:14:11.750+08:00"},{"id":2927332,"file_name":"bgm.ogg","project_id":169372,"asset_id":170605,"created_at":"2020-07-22T13:14:11.751+08:00","updated_at":"2020-07-22T13:14:11.751+08:00"},{"id":2927333,"file_name":"bubble.png","project_id":169372,"asset_id":200358,"created_at":"2020-07-22T13:14:11.752+08:00","updated_at":"2020-07-22T13:14:11.752+08:00"},{"id":2927334,"file_name":"hint.png","project_id":169372,"asset_id":189068,"created_at":"2020-07-22T13:14:11.753+08:00","updated_at":"2020-07-22T13:14:11.753+08:00"},{"id":2927335,"file_name":"player.png","project_id":169372,"asset_id":200359,"created_at":"2020-07-22T13:14:11.754+08:00","updated_at":"2020-07-22T13:14:11.754+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
繁中
简中
English
日本語
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦