{"id":173274,"student_id":1874,"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\")\nplayer.y=450\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# 建立泡泡\nbubbles=[]\nfor i in range(17):\n bubble=game.create_sprite(\"bubble.png\")\n bubble.x=i*30\n bubbles.append(bubble)\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=75*i\n rocks.append(rock)\n#遊戲主迴圈\ndef loop ():\n global level, initY, is_start, vy\n \n # 岩石往後移動\n # 場景變化\n for e in range(17):\n r=rocks[e]\n r.x-=8\n if r.x\u003c-30:\n r.x+=1275\n rand=random.randint(-30,30)\n r.y+=rand\n if r.y\u003c300:\n r.y=300\n if r.y\u003e600:\n r.y=600\n if is_start==True:\n initY+=random.randint(-30,30)\n if initY\u003c300:\n initY=300\n if initY\u003e600:\n initY=600\n level+=1\n if level\u003c30:\n r.costume_id=0\n elif level\u003c60:\n r.costume_id=1\n elif level\u003c90:\n r.costume_id=2\n elif level\u003c120:\n r.costume_id=3\n elif level\u003c150:\n r.costume_id=4\n elif level\u003c180:\n r.costume_id=5\n elif level\u003c210:\n r.costume_id=6\n elif level\u003c240:\n r.costume_id=7\n elif level\u003c270:\n r.costume_id=8\n elif level\u003c300:\n r.costume_id=9\n elif level\u003e=300:\n r.costume_id=10\n \n # 遊戲開始\n if key.space:\n is_start=True\n hint.hidden=True\n if is_start==True:\n vy+=0.3\n player.y+=vy\n player.direction=90+vy*2\n # 潛艇控制(空白鍵按下)\n if key.space:\n vy-=0.6\n player.direction=90+vy*2\n # 泡泡\n for i in range(17):\n bubbles[i].y+=2\n bubbles[i].x-=7\n if bubbles[i].x\u003c-10:\n bubbles[i].x=player.x-random.random()*20-60\n bubbles[i].y=player.y-random.random()*20\n bubbles[i].scale=bubbles[i].x/600\n bubbles[i].opacity=bubbles[i].x/600\n # 背景變化\n bg.step_forward(0.3)\n if bg.x\u003c-1200:\n bg.x+=2400\n # 顯示Level\n game.draw_text(\"level:\"+str(level),10,10,\"black\",70)\n if player.touched(rocks):\n game.stop()\ngame.forever(loop) #重複不斷執行遊戲迴圈\n","created_at":"2020-07-29T10:31:50.667+08:00","updated_at":"2020-07-29T17:12:17.092+08:00","name":"海底探險_S 副本","language":"python","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/173274/bfccb5387b7a71769e0c1a70bd1d0c60.jpg"},"parent_id":162848,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":75,"hashid":"ej9s3vne","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2977201,"file_name":"b0.png","project_id":173274,"asset_id":200369,"created_at":"2020-07-29T10:31:50.678+08:00","updated_at":"2020-07-29T10:31:50.678+08:00"},{"id":2977202,"file_name":"b1.png","project_id":173274,"asset_id":200370,"created_at":"2020-07-29T10:31:50.680+08:00","updated_at":"2020-07-29T10:31:50.680+08:00"},{"id":2977203,"file_name":"b2.png","project_id":173274,"asset_id":200371,"created_at":"2020-07-29T10:31:50.681+08:00","updated_at":"2020-07-29T10:31:50.681+08:00"},{"id":2977204,"file_name":"b3.png","project_id":173274,"asset_id":200372,"created_at":"2020-07-29T10:31:50.682+08:00","updated_at":"2020-07-29T10:31:50.682+08:00"},{"id":2977205,"file_name":"b4.png","project_id":173274,"asset_id":200373,"created_at":"2020-07-29T10:31:50.683+08:00","updated_at":"2020-07-29T10:31:50.683+08:00"},{"id":2977206,"file_name":"b5.png","project_id":173274,"asset_id":200374,"created_at":"2020-07-29T10:31:50.683+08:00","updated_at":"2020-07-29T10:31:50.683+08:00"},{"id":2977207,"file_name":"b6.png","project_id":173274,"asset_id":200375,"created_at":"2020-07-29T10:31:50.684+08:00","updated_at":"2020-07-29T10:31:50.684+08:00"},{"id":2977208,"file_name":"b7.png","project_id":173274,"asset_id":200376,"created_at":"2020-07-29T10:31:50.685+08:00","updated_at":"2020-07-29T10:31:50.685+08:00"},{"id":2977209,"file_name":"b8.png","project_id":173274,"asset_id":200377,"created_at":"2020-07-29T10:31:50.686+08:00","updated_at":"2020-07-29T10:31:50.686+08:00"},{"id":2977210,"file_name":"b9.png","project_id":173274,"asset_id":200378,"created_at":"2020-07-29T10:31:50.687+08:00","updated_at":"2020-07-29T10:31:50.687+08:00"},{"id":2977211,"file_name":"b10.png","project_id":173274,"asset_id":200379,"created_at":"2020-07-29T10:31:50.688+08:00","updated_at":"2020-07-29T10:31:50.688+08:00"},{"id":2977212,"file_name":"bg.png","project_id":173274,"asset_id":201852,"created_at":"2020-07-29T10:31:50.689+08:00","updated_at":"2020-07-29T10:31:50.689+08:00"},{"id":2977213,"file_name":"bgm_3.ogg","project_id":173274,"asset_id":170604,"created_at":"2020-07-29T10:31:50.690+08:00","updated_at":"2020-07-29T10:31:50.690+08:00"},{"id":2977214,"file_name":"bgm.ogg","project_id":173274,"asset_id":170605,"created_at":"2020-07-29T10:31:50.691+08:00","updated_at":"2020-07-29T10:31:50.691+08:00"},{"id":2977215,"file_name":"bubble.png","project_id":173274,"asset_id":200358,"created_at":"2020-07-29T10:31:50.692+08:00","updated_at":"2020-07-29T10:31:50.692+08:00"},{"id":2977216,"file_name":"hint.png","project_id":173274,"asset_id":189068,"created_at":"2020-07-29T10:31:50.693+08:00","updated_at":"2020-07-29T10:31:50.693+08:00"},{"id":2977217,"file_name":"player.png","project_id":173274,"asset_id":200359,"created_at":"2020-07-29T10:31:50.694+08:00","updated_at":"2020-07-29T10:31:50.694+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
繁中
简中
English
日本語
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦