{"id":452615,"student_id":10,"content":"setBackdrop('bg.png');\nlet nextShape = createSprite('s_0.png', 's_1.png', 's_2.png', 's_3.png', 's_4.png', 's_5.png', 's_6.png');\nlet moving = []; //存放移動的磚塊\nlet fixed = []; //存放固定的磚塊\nlet lines = []; //存放提示燈角色\nlet score = 0; //分數\nlet clock = 0; //紀錄遊戲迴圈執行次數\n\nlet shapeList = [\n [[0, 0], [0, 1], [0, 2], [0, 3]], //長條形\n [[0, 0], [1, 0], [0, 1], [1, 1]], //正方形\n [[1, 0], [2, 0], [0, 1], [1, 1]], //反Z形\n [[0, 0], [1, 0], [1, 1], [2, 1]], //Z形\n [[0, 0], [1, 0], [2, 0], [2, 1]], //反L形\n [[0, 0], [1, 0], [2, 0], [0, 1]], //L形\n [[0, 0], [1, 0], [2, 0], [1, 1]], //山形\n]\n\non('keydown', 'up', moveUp); //當按上鍵\non('keydown', 'down', moveDown); //當按下鍵\non('keydown', 'right', moveRight); //當按右鍵\non('keydown', 'left', moveLeft); //當按左鍵\n\nnextShape.moveTo(175, 175); //移動至右上角\nnextShape.costumeId = Math.floor(Math.random() * 7); //隨機切換造型\nforever(loop); //重複不斷執行遊戲迴圈\n\n// createSound('bgm.mp3', true);\n\n// 載入磚塊\nfunction loadBlocks () {\n let shape = shapeList[nextShape.costumeId]; //根據提示形狀載入磚塊\n for (let i = 0; i \u003c 4; i++) {\n let b = createSprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png');\n b.x = shape[i][0] * 50 + 375;\n b.y = shape[i][1] * 50 + 25;\n b.costumeId = nextShape.costumeId; //根據形狀切換對應顏色\n moving.push(b); // 存入陣列中\n }\n nextShape.costumeId = Math.floor(Math.random() * 7); //隨機切換造型作為下個形狀\n createSound('drop.mp3');\n}\n\n// 遊戲主迴圈\nfunction loop () {\n drawText(score, 920, 70, '#444', 80); // 顯示分數\n checkGameover(); //檢查遊戲是否結束\n checkLines(); //檢查是否要消除磚塊\n autoMove(); //自動墜落\n}\n\n//向下移動\nfunction moveDown () {\n for (let i = 0; i \u003c moving.length; i++) {\n moving[i].y += 50;\n }\n if (invalid()) {\n moveUp();\n }\n}\n\n//向上移動\nfunction moveUp () {\n for (let i = 0; i \u003c moving.length; i++) {\n moving[i].y -= 50;\n }\n}\n\n//向右移動\nfunction moveRight () {\n \n}\n\n//向左移動\nfunction moveLeft () {\n \n}\n\n// 自動墜落\nfunction autoMove() {\n // clock++;\n // if (clock % 30 == 0) moveDown();\n}\n\n//順時針選轉\nfunction turnRight (angle = 90) {\n let center = moving[1]; // 中心點磚塊\n for (let i = 0; i \u003c moving.length; i++) {\n let b = moving[i];\n let d = b.distanceTo(center); // 算出要旋轉的磚塊與中心之間的距離\n b.toward(center); // 朝向中心磚塊\n b.stepForward(d); // 向前移動 d 距離\n b.direction -= angle; // 左轉 90 度\n b.stepForward(d); // 向前移動 d 距離\n b.direction = 90; // 恢復方向\n }\n}\n\n// 移動後檢查是否超過範圍或碰到固定磚塊\nfunction invalid () {\n for (let i = 0; i \u003c moving.length; i++) {\n let b = moving[i];\n if (b.y \u003e 900 || b.x \u003c 350 || b.x \u003e 850) {\n return true; //發現有不合法磚塊\n }\n }\n return false; //檢查沒問題\n}\n\n//檢查是否佔滿一行\nfunction checkLines () {\n let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; //紀錄 18 層每層磚塊數量\n let line = 0; //消除的行數\n\n for (let i = 0; i \u003c fixed.length; i++) {\n f = Math.floor(fixed[i].y / 50); // 算出該磚塊所在層數\n arr[f] += 1; //將該行磚塊數存入陣列\n }\n\n for (let i = 0; i \u003c 18; i++) {\n //drawText(arr[i], 300, i*50, 'white', 50);\n if (arr[i] == 10) { //如果該行填滿 10 個磚塊\n eraseLine(i); //消除該行\n line += 1; //行數增加\n createSound('score.mp3');\n }\n }\n \n // 根據消除行數增加分數\n if (line == 1) score += 40;\n if (line == 2) score += 100;\n if (line == 3) score += 300;\n if (line == 4) score += 1200;\n}\n\n// 清除一行\nfunction eraseLine (f) {\n for (let i = 0; i \u003c fixed.length; i++) {\n let floor = Math.floor(fixed[i].y / 50); // 取得該磚塊所在層\n if (floor == f) fixed[i].y = 1000; // f 層移出遊戲場景外\n if (floor \u003c f) fixed[i].y += 50; // f 層以上向下移動一格\n }\n}\n\n// 檢查遊戲是否結束\nfunction checkGameover () {\n for (let i = 0; i \u003c fixed.length; i++) {\n if (fixed[i].y \u003c 50) gameover(); //如果有磚塊超出上方就結束遊戲\n }\n}\n\n// 遊戲結束特效\nfunction gameover () {\n for (let i = 0; i \u003c fixed.length; i++) {\n fixed[i].costumeId = 7; //將所有磚塊變成深色\n }\n stop();\n}\n\n// 快速向下移動\nfunction moveToEnd () {\n \n}\n","created_at":"2022-10-27T17:25:02.742+08:00","updated_at":"2022-10-27T17:25:20.370+08:00","name":"俄羅斯方塊(預設版) (2)","language":"javascript","screenshot":{"url":null},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":150,"hashid":"npmszrp5z","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10250332,"file_name":"drop.mp3","project_id":452615,"asset_id":576796,"created_at":"2022-10-27T17:25:14.044+08:00","updated_at":"2022-10-27T17:25:14.044+08:00"},{"id":10250333,"file_name":"bgm.mp3","project_id":452615,"asset_id":576797,"created_at":"2022-10-27T17:25:14.050+08:00","updated_at":"2022-10-27T17:25:14.050+08:00"},{"id":10250334,"file_name":"line.png","project_id":452615,"asset_id":576798,"created_at":"2022-10-27T17:25:14.054+08:00","updated_at":"2022-10-27T17:25:14.054+08:00"},{"id":10250335,"file_name":"score.mp3","project_id":452615,"asset_id":576799,"created_at":"2022-10-27T17:25:14.058+08:00","updated_at":"2022-10-27T17:25:14.058+08:00"},{"id":10250336,"file_name":"s_6.png","project_id":452615,"asset_id":576800,"created_at":"2022-10-27T17:25:14.061+08:00","updated_at":"2022-10-27T17:25:14.061+08:00"},{"id":10250337,"file_name":"s_5.png","project_id":452615,"asset_id":576801,"created_at":"2022-10-27T17:25:14.065+08:00","updated_at":"2022-10-27T17:25:14.065+08:00"},{"id":10250338,"file_name":"s_4.png","project_id":452615,"asset_id":576802,"created_at":"2022-10-27T17:25:14.069+08:00","updated_at":"2022-10-27T17:25:14.069+08:00"},{"id":10250339,"file_name":"s_3.png","project_id":452615,"asset_id":576803,"created_at":"2022-10-27T17:25:14.073+08:00","updated_at":"2022-10-27T17:25:14.073+08:00"},{"id":10250340,"file_name":"s_2.png","project_id":452615,"asset_id":576804,"created_at":"2022-10-27T17:25:14.077+08:00","updated_at":"2022-10-27T17:25:14.077+08:00"},{"id":10250341,"file_name":"s_1.png","project_id":452615,"asset_id":576805,"created_at":"2022-10-27T17:25:14.081+08:00","updated_at":"2022-10-27T17:25:14.081+08:00"},{"id":10250342,"file_name":"s_0.png","project_id":452615,"asset_id":576806,"created_at":"2022-10-27T17:25:14.085+08:00","updated_at":"2022-10-27T17:25:14.085+08:00"},{"id":10250343,"file_name":"gameover.png","project_id":452615,"asset_id":576807,"created_at":"2022-10-27T17:25:14.090+08:00","updated_at":"2022-10-27T17:25:14.090+08:00"},{"id":10250344,"file_name":"bg.png","project_id":452615,"asset_id":576808,"created_at":"2022-10-27T17:25:14.095+08:00","updated_at":"2022-10-27T17:25:14.095+08:00"},{"id":10250345,"file_name":"7.png","project_id":452615,"asset_id":576809,"created_at":"2022-10-27T17:25:14.099+08:00","updated_at":"2022-10-27T17:25:14.099+08:00"},{"id":10250346,"file_name":"6.png","project_id":452615,"asset_id":576810,"created_at":"2022-10-27T17:25:14.103+08:00","updated_at":"2022-10-27T17:25:14.103+08:00"},{"id":10250347,"file_name":"5.png","project_id":452615,"asset_id":576811,"created_at":"2022-10-27T17:25:14.106+08:00","updated_at":"2022-10-27T17:25:14.106+08:00"},{"id":10250348,"file_name":"4.png","project_id":452615,"asset_id":576812,"created_at":"2022-10-27T17:25:14.110+08:00","updated_at":"2022-10-27T17:25:14.110+08:00"},{"id":10250349,"file_name":"3.png","project_id":452615,"asset_id":576813,"created_at":"2022-10-27T17:25:14.113+08:00","updated_at":"2022-10-27T17:25:14.113+08:00"},{"id":10250350,"file_name":"2.png","project_id":452615,"asset_id":576814,"created_at":"2022-10-27T17:25:14.117+08:00","updated_at":"2022-10-27T17:25:14.117+08:00"},{"id":10250351,"file_name":"1.png","project_id":452615,"asset_id":576815,"created_at":"2022-10-27T17:25:14.121+08:00","updated_at":"2022-10-27T17:25:14.121+08:00"},{"id":10250352,"file_name":"0.png","project_id":452615,"asset_id":576816,"created_at":"2022-10-27T17:25:14.124+08:00","updated_at":"2022-10-27T17:25:14.124+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦