{"id":176226,"student_id":10,"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\nvy = 0 #墜落速度\nlevel = 0 #分數\ninit_y = 450 #當前最新的障礙物座標\nis_start = False #是否開始遊戲\nrocks = [] #存放障礙物\nbubbles = [] #存放泡泡\n\nplayer.layer = 1 #設定潛水挺圖層\nhint.scale = 1.5 #設定教學提示圖大小\n\nsound.play('bgm.ogg', True)\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)\n\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 \n global vy, level, init_y, is_start\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 if is_start:\n init_y += random.random()*120 - 60\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 is_start:\n level+= 1\n \n if key.space:\n vy -= 0.6\n is_start = True\n \n if is_start:\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.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 draw_text(str(level) + 'm', 10, 10, 'white', 60)\n\n\ngame.forever(loop) #重複不斷執行遊戲回圈\n","created_at":"2020-08-03T10:18:11.716+08:00","updated_at":"2020-08-03T10:34:58.335+08:00","name":"w","language":"python","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/176226/d1df25b2738683732bd80fb77933492e.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":230,"hashid":"meys34ej","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3023762,"file_name":"b2.png","project_id":176226,"asset_id":200371,"created_at":"2020-08-03T10:35:27.970+08:00","updated_at":"2020-08-03T10:35:27.970+08:00"},{"id":3023763,"file_name":"b3.png","project_id":176226,"asset_id":200372,"created_at":"2020-08-03T10:35:27.971+08:00","updated_at":"2020-08-03T10:35:27.971+08:00"},{"id":3023766,"file_name":"b6.png","project_id":176226,"asset_id":200375,"created_at":"2020-08-03T10:35:28.980+08:00","updated_at":"2020-08-03T10:35:28.980+08:00"},{"id":3023767,"file_name":"b7.png","project_id":176226,"asset_id":200376,"created_at":"2020-08-03T10:35:28.982+08:00","updated_at":"2020-08-03T10:35:28.982+08:00"},{"id":3023779,"file_name":"_bg.png","project_id":176226,"asset_id":201852,"created_at":"2020-08-03T10:35:57.245+08:00","updated_at":"2020-08-03T10:36:02.894+08:00"},{"id":3023780,"file_name":"_bubble.png","project_id":176226,"asset_id":200358,"created_at":"2020-08-03T10:35:57.247+08:00","updated_at":"2020-08-03T10:36:06.187+08:00"},{"id":3023781,"file_name":"_hint.png","project_id":176226,"asset_id":246016,"created_at":"2020-08-03T10:35:58.228+08:00","updated_at":"2020-08-03T10:36:12.715+08:00"},{"id":3023782,"file_name":"_player.png","project_id":176226,"asset_id":200359,"created_at":"2020-08-03T10:35:58.230+08:00","updated_at":"2020-08-03T10:36:39.521+08:00"},{"id":3023768,"file_name":"b8.png","project_id":176226,"asset_id":200377,"created_at":"2020-08-03T10:35:29.401+08:00","updated_at":"2020-08-03T10:35:29.401+08:00"},{"id":3023769,"file_name":"b9.png","project_id":176226,"asset_id":200378,"created_at":"2020-08-03T10:35:29.403+08:00","updated_at":"2020-08-03T10:35:29.403+08:00"},{"id":3023764,"file_name":"b4.png","project_id":176226,"asset_id":200373,"created_at":"2020-08-03T10:35:28.523+08:00","updated_at":"2020-08-03T10:35:28.523+08:00"},{"id":3023765,"file_name":"b5.png","project_id":176226,"asset_id":200374,"created_at":"2020-08-03T10:35:28.524+08:00","updated_at":"2020-08-03T10:35:28.524+08:00"},{"id":3023761,"file_name":"b1.png","project_id":176226,"asset_id":200370,"created_at":"2020-08-03T10:35:27.299+08:00","updated_at":"2020-08-03T10:35:27.299+08:00"},{"id":3023760,"file_name":"_b0.png","project_id":176226,"asset_id":200369,"created_at":"2020-08-03T10:35:27.297+08:00","updated_at":"2020-08-03T10:36:23.179+08:00"},{"id":3023770,"file_name":"b10.png","project_id":176226,"asset_id":200379,"created_at":"2020-08-03T10:35:30.524+08:00","updated_at":"2020-08-03T10:35:30.524+08:00"},{"id":3023771,"file_name":"bg_2.png","project_id":176226,"asset_id":201851,"created_at":"2020-08-03T10:35:30.526+08:00","updated_at":"2020-08-03T10:35:30.526+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦