{"id":332187,"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');\nnextShape.moveTo(175, 175);\n\nlet moving = []; //存放移動的磚塊\nlet fixed = []; //存放固定的磚塊\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\nforever(loop); //重複不斷執行遊戲迴圈\n\n// 載入磚塊\nfunction loadBlocks () {\n nextShape.costumeId = Math.floor(Math.random() * 7);\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}\n\n// 遊戲主迴圈\nfunction loop () {\n drawText(score, 920, 70, 'black', 80); // 顯示分數\n checkGameover(); //檢查遊戲是否結束\n checkLines(); //檢查是否要消除磚塊\n updateLines(); // 更新提示光\n\n // clock++;\n // if (clock % 30 == 0) moveDown(); // 自動墜落\n}\n\n//向下移動\nfunction moveDown () {\n for (let i = 0; i \u003c moving.length; i++) {\n moving[i].y += 50; // 向下移動一格\n }\n\n // 如果超出範圍或碰到固定的方塊就退回\n if (invalid()) moveUp();\n}\n\n//向上移動\nfunction moveUp () {\n \n}\n\n//向右移動\nfunction moveRight () {\n \n}\n\n//向左移動\nfunction moveLeft () {\n \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\n // 紀錄一共 18 層的每一層方塊數量\n let arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 'red', 50);\n // }\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) stop();\n }\n}\n\n// 遊戲結束特效\nfunction gameover () {\n \n}\n\n// 快速向下移動\nfunction moveToEnd () {\n \n}\n\n// 更新提示光\nfunction updateLines () {\n \n}\n\n","created_at":"2021-12-30T18:58:20.340+08:00","updated_at":"2022-01-04T19:17:57.744+08:00","name":"俄羅斯方塊(預設版)","language":"javascript","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/332187/8579c9f991d616677af78b14ccb28cef.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":205,"hashid":"36ysmnq54","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":7051928,"file_name":"s_6.png","project_id":332187,"asset_id":458616,"created_at":"2022-01-03T15:43:31.437+08:00","updated_at":"2022-01-03T15:43:31.437+08:00"},{"id":7051929,"file_name":"s_5.png","project_id":332187,"asset_id":458617,"created_at":"2022-01-03T15:43:31.441+08:00","updated_at":"2022-01-03T15:43:31.441+08:00"},{"id":7051923,"file_name":"drop.mp3","project_id":332187,"asset_id":458611,"created_at":"2022-01-03T15:43:31.418+08:00","updated_at":"2022-01-03T15:43:31.418+08:00"},{"id":7051924,"file_name":"line.png","project_id":332187,"asset_id":458612,"created_at":"2022-01-03T15:43:31.421+08:00","updated_at":"2022-01-03T15:43:31.421+08:00"},{"id":7051925,"file_name":"score.mp3","project_id":332187,"asset_id":458613,"created_at":"2022-01-03T15:43:31.425+08:00","updated_at":"2022-01-03T15:43:31.425+08:00"},{"id":7051926,"file_name":"move.mp3","project_id":332187,"asset_id":458614,"created_at":"2022-01-03T15:43:31.428+08:00","updated_at":"2022-01-03T15:43:31.428+08:00"},{"id":7051927,"file_name":"bgm.mp3","project_id":332187,"asset_id":458615,"created_at":"2022-01-03T15:43:31.433+08:00","updated_at":"2022-01-03T15:43:31.433+08:00"},{"id":7051930,"file_name":"s_4.png","project_id":332187,"asset_id":458618,"created_at":"2022-01-03T15:43:31.444+08:00","updated_at":"2022-01-03T15:43:31.444+08:00"},{"id":7051931,"file_name":"s_3.png","project_id":332187,"asset_id":458619,"created_at":"2022-01-03T15:43:31.447+08:00","updated_at":"2022-01-03T15:43:31.447+08:00"},{"id":7051932,"file_name":"s_2.png","project_id":332187,"asset_id":458620,"created_at":"2022-01-03T15:43:31.451+08:00","updated_at":"2022-01-03T15:43:31.451+08:00"},{"id":7051933,"file_name":"s_1.png","project_id":332187,"asset_id":458621,"created_at":"2022-01-03T15:43:31.454+08:00","updated_at":"2022-01-03T15:43:31.454+08:00"},{"id":7051934,"file_name":"s_0.png","project_id":332187,"asset_id":458622,"created_at":"2022-01-03T15:43:31.457+08:00","updated_at":"2022-01-03T15:43:31.457+08:00"},{"id":7051935,"file_name":"gameover.png","project_id":332187,"asset_id":458623,"created_at":"2022-01-03T15:43:31.462+08:00","updated_at":"2022-01-03T15:43:31.462+08:00"},{"id":7051936,"file_name":"bg.png","project_id":332187,"asset_id":458624,"created_at":"2022-01-03T15:43:31.468+08:00","updated_at":"2022-01-03T15:43:31.468+08:00"},{"id":7051937,"file_name":"7.png","project_id":332187,"asset_id":458625,"created_at":"2022-01-03T15:43:31.472+08:00","updated_at":"2022-01-03T15:43:31.472+08:00"},{"id":7051938,"file_name":"6.png","project_id":332187,"asset_id":458626,"created_at":"2022-01-03T15:43:31.475+08:00","updated_at":"2022-01-03T15:43:31.475+08:00"},{"id":7051939,"file_name":"5.png","project_id":332187,"asset_id":458627,"created_at":"2022-01-03T15:43:31.478+08:00","updated_at":"2022-01-03T15:43:31.478+08:00"},{"id":7051940,"file_name":"4.png","project_id":332187,"asset_id":458628,"created_at":"2022-01-03T15:43:31.482+08:00","updated_at":"2022-01-03T15:43:31.482+08:00"},{"id":7051941,"file_name":"3.png","project_id":332187,"asset_id":458629,"created_at":"2022-01-03T15:43:31.485+08:00","updated_at":"2022-01-03T15:43:31.485+08:00"},{"id":7051942,"file_name":"2.png","project_id":332187,"asset_id":458630,"created_at":"2022-01-03T15:43:31.488+08:00","updated_at":"2022-01-03T15:43:31.488+08:00"},{"id":7051943,"file_name":"1.png","project_id":332187,"asset_id":458631,"created_at":"2022-01-03T15:43:31.492+08:00","updated_at":"2022-01-03T15:43:31.492+08:00"},{"id":7051944,"file_name":"0.png","project_id":332187,"asset_id":458632,"created_at":"2022-01-03T15:43:31.495+08:00","updated_at":"2022-01-03T15:43:31.495+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦