{"id":149957,"student_id":10,"content":"setBackdrop('bg.jpg'); //設定背景圖\nvar player = createSprite('p_0.png', 'p_1.png'); //玩家擋板\nvar ball = createSprite('ball_0.png', 'ball_1.png'); //球\nvar bar = createSprite('bar_0.png', 'bar_1.png'); //下方橘色長條\nvar hint = createSprite('hint.png'); //遊戲說明\nvar gameoverText = createSprite('gameover.png'); //遊戲結束文字\n\nplayer.y = 800;\nball.direction = 0;\ngameoverText.layer = 1;\nball.layer = 1;\nhint.layer = 1;\nball.y = 700;\ngameoverText.hidden = true;\n\nvar blocks = []; //存放所有磚塊角色\nvar speed = 10; //移動速度\nvar score = 0; //遊戲分數\nvar life = 3; //生命\nvar active = false; //是否卷動磚塊\nvar combo = 0; //連擊個數\n\ncreateSound('bgm.mp3');\n\nforever(loop); //重複不斷執行遊戲迴圈\n\n//初始化 10*5 磚塊\nfor (var x = 0; x \u003c 10; x++) {\n for (var y = 0; y \u003c 5; y++) {\n var b = createSprite('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.costumeId = Math.floor(Math.random()*6);\n blocks.push(b);\n }\n}\n\n//遊戲主迴圈\nfunction loop () {\n\n player.x = cursor.x;\n\n if (active) {\n ball.stepForward(speed);\n ball.bounceEdge();\n } else {\n ball.x = player.x;\n }\n\n if (cursor.isDown) {\n active = true;\n hint.hidden = true;\n }\n\n if (ball.y \u003e= 850) {\n ball.direction = 0;\n active = false;\n ball.y = 700;\n ball.x = player.x;\n life--;\n speed = 10;\n }\n\n if (ball.touched(player)) {\n ball.direction = ((ball.x - player.x)/100)*45;\n createSound('hit.mp3');\n combo = 0;\n }\n\n for (var i = 0; i \u003c blocks.length; i++) {\n if (ball.touched(blocks[i])) {\n blocks[i].hidden = true;\n ball.direction = -ball.direction + 180;\n if (speed \u003c 20) {\n speed += 0.2;\n }\n combo += 1;\n score += combo;\n createSound((combo % 7 + 1) + '.mp3'); //根據連擊數播放不同音效\n }\n if (active) {\n blocks[i].y += speed/100; //磚塊下降會隨球速等比例變快\n }\n if (blocks[i].hidden == false \u0026\u0026 blocks[i].y \u003e 800) {\n gameover();\n }\n }\n \n //如果最上排磚塊完全進入遊戲場景中,就創造新的一排磚塊\n if (blocks[0].y \u003e= 30) {\n for (var x = 0; x \u003c 10; x++) {\n var b = createSprite('b0.png', 'b1.png', 'b2.png', 'b3.png', 'b4.png', 'b5.png', 'b6.png', 'b7.png');\n b.costumeId = Math.floor(Math.random()*6);\n b.x = x*120 + 60;\n b.y = -30;\n blocks.unshift(b); //為了方便偵測最上排的磚塊位置,要從陣列前方加入\n }\n }\n\n if (life \u003c 0) {\n gameover();\n }\n\n drawText('life: ' + life, 500, 860, 'white', 40);\n drawText('score: ' + score, 900, 860, 'white', 40);\n drawText('combo: ' + combo, 100, 860, 'white', 40);\n}\n\n//遊戲結束\nfunction gameover () {\n stop();\n for (var i = 0; i \u003c blocks.length; i++) {\n blocks[i].costumeId = 7;\n }\n player.costumeId = 1;\n bar.costumeId = 1;\n ball.costumeId = 1;\n gameoverText.hidden = false;\n}\n","created_at":"2020-05-17T16:30:32.748+08:00","updated_at":"2020-08-20T15:59:28.402+08:00","name":"打磚塊(完整版)","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/149957/8aa9a2cbc9d7b1a0566cc58c70ef9fcb.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900});","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":340,"hashid":"9ygsyrqm","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2601170,"file_name":"hit.wav","project_id":149957,"asset_id":172284,"created_at":"2020-05-17T16:47:36.650+08:00","updated_at":"2020-05-17T16:47:36.650+08:00"},{"id":2601157,"file_name":"gameover.png","project_id":149957,"asset_id":215183,"created_at":"2020-05-17T16:31:25.193+08:00","updated_at":"2020-05-17T16:31:25.193+08:00"},{"id":2601166,"file_name":"5.mp3","project_id":149957,"asset_id":209240,"created_at":"2020-05-17T16:47:27.782+08:00","updated_at":"2020-05-17T16:47:27.782+08:00"},{"id":2601167,"file_name":"6.mp3","project_id":149957,"asset_id":209241,"created_at":"2020-05-17T16:47:27.784+08:00","updated_at":"2020-05-17T16:47:27.784+08:00"},{"id":2601151,"file_name":"b4.png","project_id":149957,"asset_id":215177,"created_at":"2020-05-17T16:31:24.182+08:00","updated_at":"2020-05-17T16:31:24.182+08:00"},{"id":2601152,"file_name":"b5.png","project_id":149957,"asset_id":215178,"created_at":"2020-05-17T16:31:24.184+08:00","updated_at":"2020-05-17T16:31:24.184+08:00"},{"id":2601156,"file_name":"bg.jpg","project_id":149957,"asset_id":215182,"created_at":"2020-05-17T16:31:24.781+08:00","updated_at":"2020-05-17T16:31:24.781+08:00"},{"id":2601162,"file_name":"1.mp3","project_id":149957,"asset_id":209236,"created_at":"2020-05-17T16:47:25.411+08:00","updated_at":"2020-05-17T16:47:25.411+08:00"},{"id":2601163,"file_name":"2.mp3","project_id":149957,"asset_id":209237,"created_at":"2020-05-17T16:47:25.413+08:00","updated_at":"2020-05-17T16:47:25.413+08:00"},{"id":2601164,"file_name":"3.mp3","project_id":149957,"asset_id":209238,"created_at":"2020-05-17T16:47:26.884+08:00","updated_at":"2020-05-17T16:47:26.884+08:00"},{"id":2601165,"file_name":"4.mp3","project_id":149957,"asset_id":209239,"created_at":"2020-05-17T16:47:26.885+08:00","updated_at":"2020-05-17T16:47:26.885+08:00"},{"id":2601155,"file_name":"ball_0.png","project_id":149957,"asset_id":215181,"created_at":"2020-05-17T16:31:24.780+08:00","updated_at":"2020-08-20T11:35:33.385+08:00"},{"id":2601149,"file_name":"b2.png","project_id":149957,"asset_id":215175,"created_at":"2020-05-17T16:31:23.937+08:00","updated_at":"2020-05-17T16:31:23.937+08:00"},{"id":2601150,"file_name":"b3.png","project_id":149957,"asset_id":215176,"created_at":"2020-05-17T16:31:23.939+08:00","updated_at":"2020-05-17T16:31:23.939+08:00"},{"id":2601168,"file_name":"7.mp3","project_id":149957,"asset_id":209242,"created_at":"2020-05-17T16:47:36.368+08:00","updated_at":"2020-05-17T16:47:36.368+08:00"},{"id":2601169,"file_name":"bgm.mp3","project_id":149957,"asset_id":172287,"created_at":"2020-05-17T16:47:36.370+08:00","updated_at":"2020-05-17T16:47:36.370+08:00"},{"id":2601147,"file_name":"b0.png","project_id":149957,"asset_id":215173,"created_at":"2020-05-17T16:31:23.651+08:00","updated_at":"2020-05-17T16:31:23.651+08:00"},{"id":2601148,"file_name":"b1.png","project_id":149957,"asset_id":215174,"created_at":"2020-05-17T16:31:23.653+08:00","updated_at":"2020-05-17T16:31:23.653+08:00"},{"id":2601153,"file_name":"b6.png","project_id":149957,"asset_id":215179,"created_at":"2020-05-17T16:31:24.468+08:00","updated_at":"2020-05-17T16:31:24.468+08:00"},{"id":2601154,"file_name":"b7.png","project_id":149957,"asset_id":215180,"created_at":"2020-05-17T16:31:24.470+08:00","updated_at":"2020-05-17T16:31:24.470+08:00"},{"id":2601159,"file_name":"p_0.png","project_id":149957,"asset_id":215185,"created_at":"2020-05-17T16:31:25.429+08:00","updated_at":"2020-08-20T11:36:37.697+08:00"},{"id":2874123,"file_name":"hint.png","project_id":149957,"asset_id":237134,"created_at":"2020-07-14T15:08:14.730+08:00","updated_at":"2020-07-14T15:08:14.730+08:00"},{"id":2601171,"file_name":"bar_0.png","project_id":149957,"asset_id":215195,"created_at":"2020-05-17T18:43:25.507+08:00","updated_at":"2020-08-20T11:36:19.728+08:00"},{"id":2874121,"file_name":"p_1.png","project_id":149957,"asset_id":237132,"created_at":"2020-07-14T15:08:06.677+08:00","updated_at":"2020-08-20T11:36:33.634+08:00"},{"id":3115523,"file_name":"ball_1.png","project_id":149957,"asset_id":249473,"created_at":"2020-08-20T11:35:11.691+08:00","updated_at":"2020-08-20T11:35:20.039+08:00"},{"id":2874122,"file_name":"bar_1.png","project_id":149957,"asset_id":237133,"created_at":"2020-07-14T15:08:08.981+08:00","updated_at":"2020-08-20T11:36:16.363+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦