{"id":242686,"student_id":2002,"content":"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\n\nvy = 0 #墜落速度\nlevel = 0 #分數\ninit_y = 450 #當前最新的障礙物座標\nrocks = [] #存放障礙物\nbubbles = [] #存放泡泡\n\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)\nfor i in range(21):\n b = create_sprite(\"bubble.png\")\n b.x = i * 30\n bubbles.append(b)\n\n#遊戲主迴圈\ndef loop ():\n global vy, level, init_y\n \n bg.x -= 0.3\n if bg.x \u003c -1200:\n bg.x += 2400\n \n if hint.hidden == True:\n vy += 0.3\n player.y += vy\n player.direction = 90 + vy * 2.5\n if key.space:\n vy -= 0.6\n hint.hidden = True\n if player.touched(rocks):\n stop()\n \n for i in range(17):\n rocks[i].x -= 8\n if rocks[i].x \u003c 0 :\n rocks[i].x += 1200\n if hint.hidden == True:\n init_y += random.randrange(-60, 60)\n level += 1\n if init_y \u003e 600:\n init_y = 600\n if init_y \u003c 300:\n init_y = 300\n rocks[i].y = init_y\n if level \u003c 300:\n rocks[i].costume_id = level // 30 \n else:\n rocks[i].costume_id = 10\n draw_text(str(level) + \"m\", 10, 10, \"white\", 60)\n for i in range(21):\n bubbles[i].x -= 7\n bubbles[i].y -= 2\n bubbles[i].opacity = bubbles[i].x / 600\n bubbles[i].scale = bubbles[i].x / 600\n if bubbles[i].x \u003c -10:\n bubbles[i].x = player.x - 60 - random.randrange(20)\n bubbles[i].y = player.y - random.randrange(20)\ngame.forever(loop) #重複不斷執行遊戲回圈\n\n\n","created_at":"2021-04-11T14:31:21.034+08:00","updated_at":"2021-04-11T15:33:48.301+08:00","name":"海底探險(預設版) 副本","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/242686/3f88e48fb400300e2ec55798a5cc6df2.jpg"},"parent_id":183416,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":36,"hashid":"jzmserz64","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4485969,"file_name":"b5.png","project_id":242686,"asset_id":251826,"created_at":"2021-04-11T14:31:21.039+08:00","updated_at":"2021-04-11T14:31:21.039+08:00"},{"id":4485970,"file_name":"b4.png","project_id":242686,"asset_id":251827,"created_at":"2021-04-11T14:31:21.040+08:00","updated_at":"2021-04-11T14:31:21.040+08:00"},{"id":4485971,"file_name":"b3.png","project_id":242686,"asset_id":251828,"created_at":"2021-04-11T14:31:21.041+08:00","updated_at":"2021-04-11T14:31:21.041+08:00"},{"id":4485972,"file_name":"b2.png","project_id":242686,"asset_id":251829,"created_at":"2021-04-11T14:31:21.042+08:00","updated_at":"2021-04-11T14:31:21.042+08:00"},{"id":4485973,"file_name":"b1.png","project_id":242686,"asset_id":251830,"created_at":"2021-04-11T14:31:21.042+08:00","updated_at":"2021-04-11T14:31:21.042+08:00"},{"id":4485974,"file_name":"b0.png","project_id":242686,"asset_id":251831,"created_at":"2021-04-11T14:31:21.043+08:00","updated_at":"2021-04-11T14:31:21.043+08:00"},{"id":4485975,"file_name":"player.png","project_id":242686,"asset_id":251832,"created_at":"2021-04-11T14:31:21.044+08:00","updated_at":"2021-04-11T14:31:21.044+08:00"},{"id":4485976,"file_name":"hint.png","project_id":242686,"asset_id":251833,"created_at":"2021-04-11T14:31:21.045+08:00","updated_at":"2021-04-11T14:31:21.045+08:00"},{"id":4485977,"file_name":"bubble.png","project_id":242686,"asset_id":251818,"created_at":"2021-04-11T14:31:21.046+08:00","updated_at":"2021-04-11T14:31:21.046+08:00"},{"id":4485978,"file_name":"bg.png","project_id":242686,"asset_id":251819,"created_at":"2021-04-11T14:31:21.047+08:00","updated_at":"2021-04-11T14:31:21.047+08:00"},{"id":4485979,"file_name":"bg_2.png","project_id":242686,"asset_id":251820,"created_at":"2021-04-11T14:31:21.048+08:00","updated_at":"2021-04-11T14:31:21.048+08:00"},{"id":4485980,"file_name":"b10.png","project_id":242686,"asset_id":251821,"created_at":"2021-04-11T14:31:21.049+08:00","updated_at":"2021-04-11T14:31:21.049+08:00"},{"id":4485981,"file_name":"b9.png","project_id":242686,"asset_id":251822,"created_at":"2021-04-11T14:31:21.049+08:00","updated_at":"2021-04-11T14:31:21.049+08:00"},{"id":4485982,"file_name":"b8.png","project_id":242686,"asset_id":251823,"created_at":"2021-04-11T14:31:21.050+08:00","updated_at":"2021-04-11T14:31:21.050+08:00"},{"id":4485983,"file_name":"b7.png","project_id":242686,"asset_id":251824,"created_at":"2021-04-11T14:31:21.051+08:00","updated_at":"2021-04-11T14:31:21.051+08:00"},{"id":4485984,"file_name":"b6.png","project_id":242686,"asset_id":251825,"created_at":"2021-04-11T14:31:21.052+08:00","updated_at":"2021-04-11T14:31:21.052+08:00"},{"id":4485985,"file_name":"bgm.ogg","project_id":242686,"asset_id":251834,"created_at":"2021-04-11T14:31:21.053+08:00","updated_at":"2021-04-11T14:31:21.053+08:00"},{"id":4485986,"file_name":"level.wav","project_id":242686,"asset_id":251835,"created_at":"2021-04-11T14:31:21.054+08:00","updated_at":"2021-04-11T14:31:21.054+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦