{"id":196937,"student_id":2589,"content":"","created_at":"2020-10-19T17:07:44.116+08:00","updated_at":"2023-03-14T14:42:19.201+08:00","name":"海底探險 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"import random #載入產生隨機數的套件\nfrom game import (\n set_backdrop, #設定背景\n create_sprite, #創造角色\n create_sound, #創造音效\n draw_text, #繪製文字\n key, #鍵盤狀態\n forever, #重複不斷執行\n stop, #遊戲結束\n)\n\nbg = create_sprite('bg.png') #背景圖\nplayer = create_sprite('player.png') #潛水艇\nhint = create_sprite('hint.png') #提示教學\n\nvy = 0 #墜落速度\nlevel = 0 #分數\ninit_y = 450 #當前最新的障礙物座標\nrocks = [] #存放障礙物\nbubbles = [] #存放泡泡\n\ncreate_sound('bgm.ogg', True)\n\n#初始化 17 個障礙物角色\nfor i in range(17):\n r = 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 \n#初始化 21 個泡泡角色\nfor i in range(21):\n b = create_sprite('bubble.png')\n b.x = i*30\n bubbles.append(b)\n\n\n#遊戲主迴圈\ndef loop ():\n global vy, level, init_y\n \n for i in range(17):\n r = rocks[i]\n r.x -= 8\n \n #重置障礙物\n if r.x \u003c -30:\n r.x += 1275\n if hint.hidden :\n init_y += random.randrange(-60, 60)\n level += 1\n \n if init_y \u003c 300:\n init_y = 300\n \n if init_y \u003e 600:\n init_y = 600\n \n r.y = init_y\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 key.space:\n vy -= 0.6\n hint.hidden = True\n \n if hint.hidden:\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 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.randrange(20) - 60\n b.y = player.y + random.randrange(20)\n\n bg.x -= 0.3\n if bg.x \u003c -1200:\n bg.x += 2400\n \n draw_text(str(level) + 'm', 10, 10, 'white', 60)\n\n\ngame.forever(loop) #重複不斷執行遊戲回圈\n\n\n","description":null,"note":null,"status":"public","like_student_ids":[11579,1998,12971,11097,6683,27952,15558,9254,16638,11149,35397,20819,4730,22240,22072,12895,17411,19419,28328,23619,27192,24495,33563,21074,28540,26704,27966,38763,23594,43026,35408,34483,24155,35917,41370,31784,32685,40624,40231,27948,45534,55116,42279,40009,32561],"is_featured":false,"views":2470,"hashid":"gk4skg526","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3378054,"file_name":"level.wav","project_id":196937,"asset_id":270933,"created_at":"2020-10-19T17:07:55.120+08:00","updated_at":"2020-10-19T17:07:55.120+08:00"},{"id":3378055,"file_name":"bgm.ogg","project_id":196937,"asset_id":270934,"created_at":"2020-10-19T17:07:55.136+08:00","updated_at":"2020-10-19T17:07:55.136+08:00"},{"id":3378056,"file_name":"hint.png","project_id":196937,"asset_id":270935,"created_at":"2020-10-19T17:07:55.144+08:00","updated_at":"2020-10-19T17:07:55.144+08:00"},{"id":3378057,"file_name":"player.png","project_id":196937,"asset_id":270936,"created_at":"2020-10-19T17:07:55.150+08:00","updated_at":"2020-10-19T17:07:55.150+08:00"},{"id":3378058,"file_name":"b0.png","project_id":196937,"asset_id":270937,"created_at":"2020-10-19T17:07:55.155+08:00","updated_at":"2020-10-19T17:07:55.155+08:00"},{"id":3378059,"file_name":"b1.png","project_id":196937,"asset_id":270938,"created_at":"2020-10-19T17:07:55.159+08:00","updated_at":"2020-10-19T17:07:55.159+08:00"},{"id":3378060,"file_name":"b2.png","project_id":196937,"asset_id":270939,"created_at":"2020-10-19T17:07:55.164+08:00","updated_at":"2020-10-19T17:07:55.164+08:00"},{"id":3378061,"file_name":"b3.png","project_id":196937,"asset_id":270940,"created_at":"2020-10-19T17:07:55.169+08:00","updated_at":"2020-10-19T17:07:55.169+08:00"},{"id":3378062,"file_name":"b4.png","project_id":196937,"asset_id":270941,"created_at":"2020-10-19T17:07:55.174+08:00","updated_at":"2020-10-19T17:07:55.174+08:00"},{"id":3378063,"file_name":"b5.png","project_id":196937,"asset_id":270942,"created_at":"2020-10-19T17:07:55.178+08:00","updated_at":"2020-10-19T17:07:55.178+08:00"},{"id":3378064,"file_name":"b6.png","project_id":196937,"asset_id":270943,"created_at":"2020-10-19T17:07:55.184+08:00","updated_at":"2020-10-19T17:07:55.184+08:00"},{"id":3378065,"file_name":"b7.png","project_id":196937,"asset_id":270944,"created_at":"2020-10-19T17:07:55.188+08:00","updated_at":"2020-10-19T17:07:55.188+08:00"},{"id":3378066,"file_name":"b8.png","project_id":196937,"asset_id":270945,"created_at":"2020-10-19T17:07:55.194+08:00","updated_at":"2020-10-19T17:07:55.194+08:00"},{"id":3378067,"file_name":"b9.png","project_id":196937,"asset_id":270946,"created_at":"2020-10-19T17:07:55.199+08:00","updated_at":"2020-10-19T17:07:55.199+08:00"},{"id":3378068,"file_name":"b10.png","project_id":196937,"asset_id":270947,"created_at":"2020-10-19T17:07:55.204+08:00","updated_at":"2020-10-19T17:07:55.204+08:00"},{"id":3378069,"file_name":"bg_2.png","project_id":196937,"asset_id":270948,"created_at":"2020-10-19T17:07:55.211+08:00","updated_at":"2020-10-19T17:07:55.211+08:00"},{"id":3378070,"file_name":"bg.png","project_id":196937,"asset_id":270949,"created_at":"2020-10-19T17:07:55.217+08:00","updated_at":"2020-10-19T17:07:55.217+08:00"},{"id":3378071,"file_name":"bubble.png","project_id":196937,"asset_id":270950,"created_at":"2020-10-19T17:07:55.222+08:00","updated_at":"2020-10-19T17:07:55.222+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦