{"id":183192,"student_id":2589,"content":"game.set({width: 1200, height: 900})\n\nsetBackdrop('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-08-20T12:01:04.437+08:00","updated_at":"2020-08-20T16:09:35.815+08:00","name":"打磚塊(試玩版)","language":"javascript","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/183192/1c908537254d63caae675fd66d01e782.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900});\n\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":81,"hashid":"6rpsv5ny","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3115528,"file_name":"p_1.png","project_id":183192,"asset_id":251286,"created_at":"2020-08-20T12:01:22.739+08:00","updated_at":"2020-08-20T12:01:22.739+08:00"},{"id":3115529,"file_name":"bar_0.png","project_id":183192,"asset_id":251287,"created_at":"2020-08-20T12:01:22.744+08:00","updated_at":"2020-08-20T12:01:22.744+08:00"},{"id":3115530,"file_name":"bar_1.png","project_id":183192,"asset_id":251288,"created_at":"2020-08-20T12:01:22.748+08:00","updated_at":"2020-08-20T12:01:22.748+08:00"},{"id":3115531,"file_name":"ball_1.png","project_id":183192,"asset_id":251289,"created_at":"2020-08-20T12:01:22.752+08:00","updated_at":"2020-08-20T12:01:22.752+08:00"},{"id":3115532,"file_name":"hint.png","project_id":183192,"asset_id":251290,"created_at":"2020-08-20T12:01:22.756+08:00","updated_at":"2020-08-20T12:01:22.756+08:00"},{"id":3115533,"file_name":"hit.wav","project_id":183192,"asset_id":251291,"created_at":"2020-08-20T12:01:22.761+08:00","updated_at":"2020-08-20T12:01:22.761+08:00"},{"id":3115534,"file_name":"bgm.mp3","project_id":183192,"asset_id":251292,"created_at":"2020-08-20T12:01:22.814+08:00","updated_at":"2020-08-20T12:01:22.814+08:00"},{"id":3115535,"file_name":"7.mp3","project_id":183192,"asset_id":251293,"created_at":"2020-08-20T12:01:22.826+08:00","updated_at":"2020-08-20T12:01:22.826+08:00"},{"id":3115536,"file_name":"6.mp3","project_id":183192,"asset_id":251294,"created_at":"2020-08-20T12:01:22.832+08:00","updated_at":"2020-08-20T12:01:22.832+08:00"},{"id":3115537,"file_name":"5.mp3","project_id":183192,"asset_id":251295,"created_at":"2020-08-20T12:01:22.838+08:00","updated_at":"2020-08-20T12:01:22.838+08:00"},{"id":3115538,"file_name":"4.mp3","project_id":183192,"asset_id":251296,"created_at":"2020-08-20T12:01:22.845+08:00","updated_at":"2020-08-20T12:01:22.845+08:00"},{"id":3115539,"file_name":"3.mp3","project_id":183192,"asset_id":251297,"created_at":"2020-08-20T12:01:22.850+08:00","updated_at":"2020-08-20T12:01:22.850+08:00"},{"id":3115540,"file_name":"2.mp3","project_id":183192,"asset_id":251298,"created_at":"2020-08-20T12:01:22.856+08:00","updated_at":"2020-08-20T12:01:22.856+08:00"},{"id":3115541,"file_name":"1.mp3","project_id":183192,"asset_id":251299,"created_at":"2020-08-20T12:01:22.861+08:00","updated_at":"2020-08-20T12:01:22.861+08:00"},{"id":3115542,"file_name":"p_0.png","project_id":183192,"asset_id":251300,"created_at":"2020-08-20T12:01:22.866+08:00","updated_at":"2020-08-20T12:01:22.866+08:00"},{"id":3115543,"file_name":"gameover.png","project_id":183192,"asset_id":251301,"created_at":"2020-08-20T12:01:22.870+08:00","updated_at":"2020-08-20T12:01:22.870+08:00"},{"id":3115544,"file_name":"bg.jpg","project_id":183192,"asset_id":251302,"created_at":"2020-08-20T12:01:22.874+08:00","updated_at":"2020-08-20T12:01:22.874+08:00"},{"id":3115545,"file_name":"ball_0.png","project_id":183192,"asset_id":251303,"created_at":"2020-08-20T12:01:22.878+08:00","updated_at":"2020-08-20T12:01:22.878+08:00"},{"id":3115546,"file_name":"b7.png","project_id":183192,"asset_id":251304,"created_at":"2020-08-20T12:01:22.883+08:00","updated_at":"2020-08-20T12:01:22.883+08:00"},{"id":3115547,"file_name":"b6.png","project_id":183192,"asset_id":251305,"created_at":"2020-08-20T12:01:22.887+08:00","updated_at":"2020-08-20T12:01:22.887+08:00"},{"id":3115548,"file_name":"b5.png","project_id":183192,"asset_id":251306,"created_at":"2020-08-20T12:01:22.891+08:00","updated_at":"2020-08-20T12:01:22.891+08:00"},{"id":3115549,"file_name":"b4.png","project_id":183192,"asset_id":251307,"created_at":"2020-08-20T12:01:22.908+08:00","updated_at":"2020-08-20T12:01:22.908+08:00"},{"id":3115550,"file_name":"b3.png","project_id":183192,"asset_id":251308,"created_at":"2020-08-20T12:01:22.912+08:00","updated_at":"2020-08-20T12:01:22.912+08:00"},{"id":3115551,"file_name":"b2.png","project_id":183192,"asset_id":251309,"created_at":"2020-08-20T12:01:22.916+08:00","updated_at":"2020-08-20T12:01:22.916+08:00"},{"id":3115552,"file_name":"b1.png","project_id":183192,"asset_id":251310,"created_at":"2020-08-20T12:01:22.920+08:00","updated_at":"2020-08-20T12:01:22.920+08:00"},{"id":3115553,"file_name":"b0.png","project_id":183192,"asset_id":251311,"created_at":"2020-08-20T12:01:22.925+08:00","updated_at":"2020-08-20T12:01:22.925+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦