{"id":162847,"student_id":2589,"content":"import game\nimport random #載入產生隨機數的套件\n\nbg = game.create_sprite('bg.png') #背景圖\nplayer = game.create_sprite('player.png') #潛水艇\nhint = game.create_sprite('hint.png') #教學提示\n\nvy = 0 #墜落速度\nlevel = 0 #分數\ninitY = 450 #最新產生的障礙物位置\nis_start = False #是否開始遊戲\n\nrocks = [] #存放障礙物\nbubbles = [] #存放泡泡\n\nplayer.layer = 1\nhint.scale = 1.5\n\ngame.create_sound('bgm.ogg', True)\n\nfor i in range(17):\n r = 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 r.x = i*75\n rocks.append(r)\n\nfor i in range(21):\n b = game.create_sprite('bubble.png')\n b.x = i*30\n bubbles.append(b)\n\n#遊戲主迴圈\ndef loop ():\n global level, initY, is_start, vy\n \n for i in range(17):\n r = rocks[i]\n r.x -= 8\n if r.x \u003c -30:\n r.x += 1275\n \n if is_start == True:\n initY += random.randint(-60, 60)\n \n if initY \u003c 300:\n initY = 300\n \n if initY \u003e 600:\n initY = 600\n \n r.y = initY\n\n if level \u003c 30:\n r.costume_id = 0\n elif level \u003c 60:\n r.costume_id = 1\n elif level \u003c 90:\n r.costume_id = 2\n elif level \u003c 120:\n r.costume_id = 3\n elif level \u003c 150:\n r.costume_id = 4\n elif level \u003c 180:\n r.costume_id = 5\n elif level \u003c 210:\n r.costume_id = 6\n elif level \u003c 240:\n r.costume_id = 7\n elif level \u003c 270:\n r.costume_id = 8\n else:\n r.costume_id = 9\n\n if is_start == True:\n level += 1\n \n if key.space:\n vy -= 0.6\n is_start = True\n \n if is_start == True:\n vy += 0.3\n player.y += vy\n player.direction = 90 + vy*2\n hint.hidden = True\n \n if player.touched(rocks):\n game.stop()\n \n for i in range(21):\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 bg.x -= 0.3\n if bg.x \u003c -1200:\n bg.x += 2400\n \n game.draw_text('Level: '+str(level), 10, 10, 'white', 60)\n\ngame.forever(loop) #重複不斷執行遊戲迴圈","created_at":"2020-07-06T01:19:42.776+08:00","updated_at":"2020-07-11T18:31:36.931+08:00","name":"海底探險_T ","language":"python","screenshot":{"url":null},"parent_id":160696,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":146,"hashid":"5j3sypvd","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2832581,"file_name":"b0.png","project_id":162847,"asset_id":200369,"created_at":"2020-07-06T01:19:42.782+08:00","updated_at":"2020-07-06T01:19:42.782+08:00"},{"id":2832582,"file_name":"b1.png","project_id":162847,"asset_id":200370,"created_at":"2020-07-06T01:19:42.784+08:00","updated_at":"2020-07-06T01:19:42.784+08:00"},{"id":2832583,"file_name":"b2.png","project_id":162847,"asset_id":200371,"created_at":"2020-07-06T01:19:42.785+08:00","updated_at":"2020-07-06T01:19:42.785+08:00"},{"id":2832584,"file_name":"b3.png","project_id":162847,"asset_id":200372,"created_at":"2020-07-06T01:19:42.786+08:00","updated_at":"2020-07-06T01:19:42.786+08:00"},{"id":2832585,"file_name":"b4.png","project_id":162847,"asset_id":200373,"created_at":"2020-07-06T01:19:42.787+08:00","updated_at":"2020-07-06T01:19:42.787+08:00"},{"id":2832586,"file_name":"b5.png","project_id":162847,"asset_id":200374,"created_at":"2020-07-06T01:19:42.787+08:00","updated_at":"2020-07-06T01:19:42.787+08:00"},{"id":2832587,"file_name":"b6.png","project_id":162847,"asset_id":200375,"created_at":"2020-07-06T01:19:42.788+08:00","updated_at":"2020-07-06T01:19:42.788+08:00"},{"id":2832588,"file_name":"b7.png","project_id":162847,"asset_id":200376,"created_at":"2020-07-06T01:19:42.789+08:00","updated_at":"2020-07-06T01:19:42.789+08:00"},{"id":2832589,"file_name":"b8.png","project_id":162847,"asset_id":200377,"created_at":"2020-07-06T01:19:42.790+08:00","updated_at":"2020-07-06T01:19:42.790+08:00"},{"id":2832590,"file_name":"b9.png","project_id":162847,"asset_id":200378,"created_at":"2020-07-06T01:19:42.791+08:00","updated_at":"2020-07-06T01:19:42.791+08:00"},{"id":2832591,"file_name":"b10.png","project_id":162847,"asset_id":200379,"created_at":"2020-07-06T01:19:42.792+08:00","updated_at":"2020-07-06T01:19:42.792+08:00"},{"id":2832592,"file_name":"bg.png","project_id":162847,"asset_id":201852,"created_at":"2020-07-06T01:19:42.793+08:00","updated_at":"2020-07-06T01:19:42.793+08:00"},{"id":2832593,"file_name":"bgm_3.ogg","project_id":162847,"asset_id":170604,"created_at":"2020-07-06T01:19:42.794+08:00","updated_at":"2020-07-06T01:19:42.794+08:00"},{"id":2832594,"file_name":"bgm.ogg","project_id":162847,"asset_id":170605,"created_at":"2020-07-06T01:19:42.795+08:00","updated_at":"2020-07-06T01:19:42.795+08:00"},{"id":2832595,"file_name":"bubble.png","project_id":162847,"asset_id":200358,"created_at":"2020-07-06T01:19:42.796+08:00","updated_at":"2020-07-06T01:19:42.796+08:00"},{"id":2832596,"file_name":"hint.png","project_id":162847,"asset_id":189068,"created_at":"2020-07-06T01:19:42.797+08:00","updated_at":"2020-07-06T01:19:42.797+08:00"},{"id":2832597,"file_name":"player.png","project_id":162847,"asset_id":200359,"created_at":"2020-07-06T01:19:42.798+08:00","updated_at":"2020-07-06T01:19:42.798+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦