{"id":507130,"student_id":2589,"content":"import game","created_at":"2023-03-14T14:39:40.880+08:00","updated_at":"2023-03-14T14:40:13.864+08:00","name":"牛仔大對決 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"import math #載入數學工具套件\nimport random #載入產生隨機數的套件\n\ncreateSprite('bg_0.png') #背景圖1\nc1 = createSprite('cloud_1.png') #雲朵1\nc2 = createSprite('cloud_2.png') #雲朵2\nc3 = createSprite('cloud_3.png') #雲朵3\ncreateSprite('bg_1.png') #背景圖2\np1 = createSprite('p1_0.png', 'p1_1.png', 'p1_2.png', 'p1_3.png') #左邊牛仔\np2 = createSprite('p2_0.png', 'p2_1.png', 'p2_2.png', 'p2_3.png') #右邊牛仔\ninfo = createSprite('info.png') #遊戲說明\n\nsteps = -1 #移動的剩餘步數\np1_fired = False #p1是否已經開槍\np2_fired = False #p2是否已經開槍\n# bgm = sound.play('bgm.mp3', True)\n\np1.moveTo(600, 700)\np2.moveTo(600, 700)\nc1.moveTo(700, 300)\nc2.moveTo(200, 150)\nc3.moveTo(1100, 50)\n\np1.hidden = True\np2.hidden = True\n\n# 遊戲主迴圈\ndef loop ():\n global steps, p1_fired, p2_fired\n \n if steps \u003e 0:\n p1.x -= 1\n p2.x += 1\n steps -= 1\n \n if steps == 0 and p1.costume_id == 0:\n p1.costume_id = 1\n p2.costume_id = 1\n bgm.mute(True)\n \n if key.space and p2.costume_id == 1 and not p1_fired:\n p1.costume_id = 2\n p2.costume_id = 3\n sound.play('shot.wav')\n\n \n if key.enter and p2.costume_id == 1 and not p2_fired:\n p2.costume_id = 2\n p1.costume_id = 3\n sound.play('shot.wav')\n \n if key.enter:\n p2_fired = True\n \n if key.space:\n p1_fired = True\n\n #重新開始\n if key.r:\n p1.moveTo(600, 700)\n p2.moveTo(600, 700)\n p1.costume_id = 0\n p2.costume_id = 0\n p1_fired = False\n p2_fired = False\n steps = math.floor(random.random()*400 + 100)\n p1.hidden = False\n p2.hidden = False\n info.hidden = True\n bgm.mute(False)\n\n c1.x -= 0.3\n if c1.x \u003c -200:\n c1.x += 1500\n\n c2.x -= 0.5\n if c2.x \u003c -200:\n c2.x += 1500\n \n c3.x -= 0.7\n if c3.x \u003c -200:\n c3.x += 1500\n\nforever(loop) #不斷執行遊戲迴圈","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":56,"hashid":"zpesr6vmj","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":11532108,"file_name":"info.png","project_id":507130,"asset_id":613843,"created_at":"2023-03-14T14:40:02.913+08:00","updated_at":"2023-03-14T14:40:02.913+08:00"},{"id":11532109,"file_name":"p1_0.png","project_id":507130,"asset_id":613844,"created_at":"2023-03-14T14:40:02.920+08:00","updated_at":"2023-03-14T14:40:02.920+08:00"},{"id":11532110,"file_name":"p1_1.png","project_id":507130,"asset_id":613845,"created_at":"2023-03-14T14:40:02.929+08:00","updated_at":"2023-03-14T14:40:02.929+08:00"},{"id":11532111,"file_name":"p1_2.png","project_id":507130,"asset_id":613846,"created_at":"2023-03-14T14:40:02.939+08:00","updated_at":"2023-03-14T14:40:02.939+08:00"},{"id":11532112,"file_name":"p1_3.png","project_id":507130,"asset_id":613847,"created_at":"2023-03-14T14:40:02.945+08:00","updated_at":"2023-03-14T14:40:02.945+08:00"},{"id":11532113,"file_name":"p2_0.png","project_id":507130,"asset_id":613848,"created_at":"2023-03-14T14:40:02.955+08:00","updated_at":"2023-03-14T14:40:02.955+08:00"},{"id":11532114,"file_name":"p2_1.png","project_id":507130,"asset_id":613849,"created_at":"2023-03-14T14:40:02.961+08:00","updated_at":"2023-03-14T14:40:02.961+08:00"},{"id":11532115,"file_name":"p2_2.png","project_id":507130,"asset_id":613850,"created_at":"2023-03-14T14:40:02.969+08:00","updated_at":"2023-03-14T14:40:02.969+08:00"},{"id":11532116,"file_name":"p2_3.png","project_id":507130,"asset_id":613851,"created_at":"2023-03-14T14:40:02.974+08:00","updated_at":"2023-03-14T14:40:02.974+08:00"},{"id":11532102,"file_name":"bg_0.png","project_id":507130,"asset_id":613837,"created_at":"2023-03-14T14:40:02.736+08:00","updated_at":"2023-03-14T14:40:02.736+08:00"},{"id":11532103,"file_name":"bg_1.png","project_id":507130,"asset_id":613838,"created_at":"2023-03-14T14:40:02.746+08:00","updated_at":"2023-03-14T14:40:02.746+08:00"},{"id":11532104,"file_name":"bgm.mp3","project_id":507130,"asset_id":613839,"created_at":"2023-03-14T14:40:02.890+08:00","updated_at":"2023-03-14T14:40:02.890+08:00"},{"id":11532105,"file_name":"cloud_1.png","project_id":507130,"asset_id":613840,"created_at":"2023-03-14T14:40:02.896+08:00","updated_at":"2023-03-14T14:40:02.896+08:00"},{"id":11532106,"file_name":"cloud_2.png","project_id":507130,"asset_id":613841,"created_at":"2023-03-14T14:40:02.901+08:00","updated_at":"2023-03-14T14:40:02.901+08:00"},{"id":11532107,"file_name":"cloud_3.png","project_id":507130,"asset_id":613842,"created_at":"2023-03-14T14:40:02.906+08:00","updated_at":"2023-03-14T14:40:02.906+08:00"},{"id":11532117,"file_name":"shot.wav","project_id":507130,"asset_id":613852,"created_at":"2023-03-14T14:40:02.986+08:00","updated_at":"2023-03-14T14:40:02.986+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦