{"id":476635,"student_id":26492,"content":"import random #載入產生隨機數套件\nfrom game import (\n set_backdrop, #設定背景圖\n create_sprite, #創造角色\n create_sound, #創造音效\n draw_text, #繪製文字\n forever, #重複不斷執行\n stop, #遊戲暫停\n)\n\nset_backdrop('bg.jpg') #設定背景圖\nplayer = create_sprite('p0.png', 'p1.png') #玩家擋板\nball = create_sprite('ball.png') #球\nbar = create_sprite('bar0.png', 'bar1.png') #下方橘色長條\nhint = create_sprite('hint.png') #遊戲說明\ngameover_text = create_sprite('gameover.png') #遊戲結束文字\n\nblocks = [] #存放磚塊\nspeed = 10 #移動速度\nscore = 0 #遊戲分數\nlife = 3 #生命\nactive = False #是否卷動磚塊\ncombo = 0 #連擊個數\n\nplayer.y = 800\nball.y = 700\nball.layer = 1\nhint.layer = 1\ngameover_text.layer = 1\ngameover_text.hidden = True\nhint.hidden = True\n\nball.direction = 0\n\nfor y in range(5):\n for x in range(10):\n b = create_sprite('b0.png', 'b1.png', 'b2.png', 'b3.png', 'b4.png', 'b5.png', 'b6.png', 'b7.png')\n b.x = x * 120 + 60\n b.y = y *60 + 30\n b.costume_id = random.randrange(7)\n blocks.append(b)\n\n#遊戲主迴圈\ndef loop ():\n global speed, score, life, active, combo, blocks\n \n player.x = cursor.x #滑鼠控制擋版\n \n if active:\n ball.step_forward(speed)\n ball.bounce_edge() #碰到邊界就反彈\n else:\n ball.y = 700 \n ball.x = cursor.x #球跟著擋板一起水平移動\n \n #點擊畫面發球\n if cursor.is_down:\n active = True\n \n #球撞到擋板反彈\n if ball.touched(player):\n #根據球與擋板水平位置,計算出球反彈的角度 \n ball.direction = (ball.x - player.x) * 45 / 100\n \n # 如果球掉超出場景下方邊界\n if ball.y \u003e 850:\n active = False\n ball.direction = 0\n life -= 1\n \n if life \u003c= 0: stop()\n \n for b in blocks:\n if active : b.y += 0.1 #磚塊向下移動\n \n if b.y \u003e 800 and b.hidden == False: stop()\n \n if ball.touched(b):\n b.hidden = True\n ball.direction = -ball.direction + 180\n \n \n \n #如果最上排磚塊完全進入遊戲場景內,就會產生新的一排磚塊 \n if blocks[0].y \u003e 30:\n for x in range(10):\n b = create_sprite('b0.png', 'b1.png', 'b2.png', 'b3.png', 'b4.png', 'b5.png', 'b6.png', 'b7.png')\n b.x = x * 120 + 60\n b.y = -30\n b.costume_id = random.randrange(7)\n blocks = [b] + blocks\n \n draw_text(life, 100, 860, 'white', 40) \n \n\n\n#遊戲結束\ndef gameover():\n pass\n\n\nforever(loop) #重複不斷執行遊戲迴圈\n\n\n","created_at":"2022-12-21T20:53:38.252+08:00","updated_at":"2022-12-28T19:55:35.127+08:00","name":"打磚塊(預設版) 副本","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/476635/ac16a0bf0fae101a1062ce0986697513.jpg"},"parent_id":183413,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":14,"hashid":"6rps2yy5v","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10848095,"file_name":"b0.png","project_id":476635,"asset_id":251763,"created_at":"2022-12-21T20:53:38.257+08:00","updated_at":"2022-12-21T20:53:38.257+08:00"},{"id":10848096,"file_name":"b1.png","project_id":476635,"asset_id":251764,"created_at":"2022-12-21T20:53:38.259+08:00","updated_at":"2022-12-21T20:53:38.259+08:00"},{"id":10848097,"file_name":"b2.png","project_id":476635,"asset_id":251765,"created_at":"2022-12-21T20:53:38.260+08:00","updated_at":"2022-12-21T20:53:38.260+08:00"},{"id":10848098,"file_name":"b3.png","project_id":476635,"asset_id":251766,"created_at":"2022-12-21T20:53:38.261+08:00","updated_at":"2022-12-21T20:53:38.261+08:00"},{"id":10848099,"file_name":"b4.png","project_id":476635,"asset_id":251767,"created_at":"2022-12-21T20:53:38.262+08:00","updated_at":"2022-12-21T20:53:38.262+08:00"},{"id":10848100,"file_name":"b5.png","project_id":476635,"asset_id":251768,"created_at":"2022-12-21T20:53:38.264+08:00","updated_at":"2022-12-21T20:53:38.264+08:00"},{"id":10848101,"file_name":"b6.png","project_id":476635,"asset_id":251769,"created_at":"2022-12-21T20:53:38.265+08:00","updated_at":"2022-12-21T20:53:38.265+08:00"},{"id":10848102,"file_name":"b7.png","project_id":476635,"asset_id":251770,"created_at":"2022-12-21T20:53:38.266+08:00","updated_at":"2022-12-21T20:53:38.266+08:00"},{"id":10848103,"file_name":"ball.png","project_id":476635,"asset_id":251771,"created_at":"2022-12-21T20:53:38.267+08:00","updated_at":"2022-12-21T20:53:38.267+08:00"},{"id":10848104,"file_name":"bar1.png","project_id":476635,"asset_id":251772,"created_at":"2022-12-21T20:53:38.269+08:00","updated_at":"2022-12-21T20:53:38.269+08:00"},{"id":10848105,"file_name":"bg.jpg","project_id":476635,"asset_id":251773,"created_at":"2022-12-21T20:53:38.270+08:00","updated_at":"2022-12-21T20:53:38.270+08:00"},{"id":10848106,"file_name":"bar0.png","project_id":476635,"asset_id":251774,"created_at":"2022-12-21T20:53:38.271+08:00","updated_at":"2022-12-21T20:53:38.271+08:00"},{"id":10848107,"file_name":"gameover.png","project_id":476635,"asset_id":251775,"created_at":"2022-12-21T20:53:38.272+08:00","updated_at":"2022-12-21T20:53:38.272+08:00"},{"id":10848108,"file_name":"hint.png","project_id":476635,"asset_id":251776,"created_at":"2022-12-21T20:53:38.273+08:00","updated_at":"2022-12-21T20:53:38.273+08:00"},{"id":10848109,"file_name":"p0.png","project_id":476635,"asset_id":251777,"created_at":"2022-12-21T20:53:38.275+08:00","updated_at":"2022-12-21T20:53:38.275+08:00"},{"id":10848110,"file_name":"p1.png","project_id":476635,"asset_id":251778,"created_at":"2022-12-21T20:53:38.276+08:00","updated_at":"2022-12-21T20:53:38.276+08:00"},{"id":10848111,"file_name":"1.mp3","project_id":476635,"asset_id":251779,"created_at":"2022-12-21T20:53:38.277+08:00","updated_at":"2022-12-21T20:53:38.277+08:00"},{"id":10848112,"file_name":"2.mp3","project_id":476635,"asset_id":251780,"created_at":"2022-12-21T20:53:38.278+08:00","updated_at":"2022-12-21T20:53:38.278+08:00"},{"id":10848113,"file_name":"3.mp3","project_id":476635,"asset_id":251781,"created_at":"2022-12-21T20:53:38.280+08:00","updated_at":"2022-12-21T20:53:38.280+08:00"},{"id":10848114,"file_name":"4.mp3","project_id":476635,"asset_id":251782,"created_at":"2022-12-21T20:53:38.281+08:00","updated_at":"2022-12-21T20:53:38.281+08:00"},{"id":10848115,"file_name":"5.mp3","project_id":476635,"asset_id":251783,"created_at":"2022-12-21T20:53:38.282+08:00","updated_at":"2022-12-21T20:53:38.282+08:00"},{"id":10848116,"file_name":"6.mp3","project_id":476635,"asset_id":251784,"created_at":"2022-12-21T20:53:38.284+08:00","updated_at":"2022-12-21T20:53:38.284+08:00"},{"id":10848117,"file_name":"7.mp3","project_id":476635,"asset_id":251785,"created_at":"2022-12-21T20:53:38.285+08:00","updated_at":"2022-12-21T20:53:38.285+08:00"},{"id":10848118,"file_name":"bgm.mp3","project_id":476635,"asset_id":251786,"created_at":"2022-12-21T20:53:38.286+08:00","updated_at":"2022-12-21T20:53:38.286+08:00"},{"id":10848119,"file_name":"hit.wav","project_id":476635,"asset_id":251787,"created_at":"2022-12-21T20:53:38.287+08:00","updated_at":"2022-12-21T20:53:38.287+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦